FiniteStateMachine< T, ChainType, StatusType, failure_status > Class Template Reference

#include <ArmarXCore/core/util/FiniteStateMachine.h>

Public Types

using state = std::function<StatusType(T*)>
 

Public Member Functions

 FiniteStateMachine (std::shared_ptr< T > context)
 
 FiniteStateMachine (T &context)
 
 FiniteStateMachine (T *context)
 
ChainType & from (state from_state)
 
ChainType & on (StatusType status)
 
ChainType & on_any_failure ()
 
ChainType & on_failure ()
 
virtual StatusType run () const
 
ChainType & start_from (state start_state)
 
ChainType & to (state to_state)
 

Static Public Attributes

static const StatusType failure_status_value = failure_status
 

Protected Member Functions

long get_id (const state &fn) const
 
long get_id (std::optional< state > fn) const
 
std::optional< state > get_next_state (const long state_id, const StatusType status) const
 

Protected Attributes

T * m_context
 
std::optional< state > m_default_fail_state
 
std::optional< state > m_init_from_state
 
std::optional< state > m_init_to_state
 
std::optional< state > m_start_state
 
std::map< long, std::optional< state > > m_states
 
std::map< std::tuple< long, StatusType >, long > m_transitions
 

Member Typedef Documentation

◆ state

template<typename T, typename ChainType, typename StatusType, StatusType failure_status>
using state = std::function<StatusType(T*)>

Constructor & Destructor Documentation

◆ FiniteStateMachine() [1/3]

template<typename T, typename ChainType, typename StatusType, StatusType failure_status>
FiniteStateMachine ( T & context)
inline

◆ FiniteStateMachine() [2/3]

template<typename T, typename ChainType, typename StatusType, StatusType failure_status>
FiniteStateMachine ( std::shared_ptr< T > context)
inline

◆ FiniteStateMachine() [3/3]

template<typename T, typename ChainType, typename StatusType, StatusType failure_status>
FiniteStateMachine ( T * context)
inline

Member Function Documentation

◆ from()

template<typename T, typename ChainType, typename StatusType, StatusType failure_status>
ChainType & from ( state from_state)
inline

◆ get_id() [1/2]

template<typename T, typename ChainType, typename StatusType, StatusType failure_status>
long get_id ( const state & fn) const
inlineprotected

◆ get_id() [2/2]

template<typename T, typename ChainType, typename StatusType, StatusType failure_status>
long get_id ( std::optional< state > fn) const
inlineprotected

◆ get_next_state()

template<typename T, typename ChainType, typename StatusType, StatusType failure_status>
std::optional< state > get_next_state ( const long state_id,
const StatusType status ) const
inlineprotected

◆ on()

template<typename T, typename ChainType, typename StatusType, StatusType failure_status>
ChainType & on ( StatusType status)
inline

◆ on_any_failure()

template<typename T, typename ChainType, typename StatusType, StatusType failure_status>
ChainType & on_any_failure ( )
inline

◆ on_failure()

template<typename T, typename ChainType, typename StatusType, StatusType failure_status>
ChainType & on_failure ( )
inline

◆ run()

template<typename T, typename ChainType, typename StatusType, StatusType failure_status>
virtual StatusType run ( ) const
inlinevirtual

◆ start_from()

template<typename T, typename ChainType, typename StatusType, StatusType failure_status>
ChainType & start_from ( state start_state)
inline

◆ to()

template<typename T, typename ChainType, typename StatusType, StatusType failure_status>
ChainType & to ( state to_state)
inline

Member Data Documentation

◆ failure_status_value

template<typename T, typename ChainType, typename StatusType, StatusType failure_status>
const StatusType failure_status_value = failure_status
static

◆ m_context

template<typename T, typename ChainType, typename StatusType, StatusType failure_status>
T* m_context
mutableprotected

◆ m_default_fail_state

template<typename T, typename ChainType, typename StatusType, StatusType failure_status>
std::optional<state> m_default_fail_state
protected

◆ m_init_from_state

template<typename T, typename ChainType, typename StatusType, StatusType failure_status>
std::optional<state> m_init_from_state
protected

◆ m_init_to_state

template<typename T, typename ChainType, typename StatusType, StatusType failure_status>
std::optional<state> m_init_to_state
protected

◆ m_start_state

template<typename T, typename ChainType, typename StatusType, StatusType failure_status>
std::optional<state> m_start_state
protected

◆ m_states

template<typename T, typename ChainType, typename StatusType, StatusType failure_status>
std::map<long, std::optional<state> > m_states
protected

◆ m_transitions

template<typename T, typename ChainType, typename StatusType, StatusType failure_status>
std::map<std::tuple<long, StatusType>, long> m_transitions
protected

The documentation for this class was generated from the following file: