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< stateget_next_state (const long state_id, const StatusType status) const
 

Protected Attributes

Tm_context
 
std::optional< statem_default_fail_state
 
std::optional< statem_init_from_state
 
std::optional< statem_init_to_state
 
std::optional< statem_start_state
 
std::map< long, std::optional< state > > m_states
 
std::map< std::tuple< long, StatusType >, long > m_transitions
 

Detailed Description

template<typename T, typename ChainType, typename StatusType, StatusType failure_status>
class armarx::FiniteStateMachine< T, ChainType, StatusType, failure_status >

Definition at line 41 of file FiniteStateMachine.h.

Member Typedef Documentation

◆ state

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

Definition at line 46 of file FiniteStateMachine.h.

Constructor & Destructor Documentation

◆ FiniteStateMachine() [1/3]

FiniteStateMachine ( T context)
inline

Definition at line 61 of file FiniteStateMachine.h.

◆ FiniteStateMachine() [2/3]

FiniteStateMachine ( std::shared_ptr< T context)
inline

Definition at line 66 of file FiniteStateMachine.h.

◆ FiniteStateMachine() [3/3]

FiniteStateMachine ( T context)
inline

Definition at line 71 of file FiniteStateMachine.h.

Member Function Documentation

◆ from()

ChainType& from ( state  from_state)
inline

Definition at line 84 of file FiniteStateMachine.h.

◆ get_id() [1/2]

long get_id ( const state fn) const
inlineprotected

Definition at line 231 of file FiniteStateMachine.h.

◆ get_id() [2/2]

long get_id ( std::optional< state fn) const
inlineprotected

Definition at line 224 of file FiniteStateMachine.h.

+ Here is the caller graph for this function:

◆ get_next_state()

std::optional<state> get_next_state ( const long  state_id,
const StatusType  status 
) const
inlineprotected

Definition at line 210 of file FiniteStateMachine.h.

+ Here is the caller graph for this function:

◆ on()

ChainType& on ( StatusType  status)
inline

Definition at line 116 of file FiniteStateMachine.h.

+ Here is the caller graph for this function:

◆ on_any_failure()

ChainType& on_any_failure ( )
inline

Definition at line 154 of file FiniteStateMachine.h.

◆ on_failure()

ChainType& on_failure ( )
inline

Definition at line 148 of file FiniteStateMachine.h.

◆ run()

virtual StatusType run ( ) const
inlinevirtual

Definition at line 169 of file FiniteStateMachine.h.

◆ start_from()

ChainType& start_from ( state  start_state)
inline

Definition at line 77 of file FiniteStateMachine.h.

◆ to()

ChainType& to ( state  to_state)
inline

Definition at line 100 of file FiniteStateMachine.h.

Member Data Documentation

◆ failure_status_value

const StatusType failure_status_value = failure_status
static

Definition at line 47 of file FiniteStateMachine.h.

◆ m_context

T* m_context
mutableprotected

Definition at line 51 of file FiniteStateMachine.h.

◆ m_default_fail_state

std::optional<state> m_default_fail_state
protected

Definition at line 55 of file FiniteStateMachine.h.

◆ m_init_from_state

std::optional<state> m_init_from_state
protected

Definition at line 53 of file FiniteStateMachine.h.

◆ m_init_to_state

std::optional<state> m_init_to_state
protected

Definition at line 54 of file FiniteStateMachine.h.

◆ m_start_state

std::optional<state> m_start_state
protected

Definition at line 52 of file FiniteStateMachine.h.

◆ m_states

std::map<long, std::optional<state> > m_states
protected

Definition at line 56 of file FiniteStateMachine.h.

◆ m_transitions

std::map<std::tuple<long, StatusType>, long> m_transitions
protected

Definition at line 57 of file FiniteStateMachine.h.


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