Embedded Template Library  1.0
etl::state_chart< TObject > Class Template Reference

Simple Finite State Machine. More...

#include <state_chart.h>

Classes

struct  state
 State definition. More...
 
struct  transition
 Transition definition. More...
 

Public Member Functions

ETL_CONSTEXPR state_chart (TObject &object_, const transition *transition_table_begin_, const transition *transition_table_end_, const state_id_t state_id_)
 
ETL_CONSTEXPR state_chart (TObject &object_, const transition *transition_table_begin_, const transition *transition_table_end_, const state *state_table_begin_, const state *state_table_end_, const state_id_t state_id_)
 
void set_transition_table (const transition *transition_table_begin_, const transition *transition_table_end_)
 
void set_state_table (const state *state_table_begin_, const state *state_table_end_)
 
TObject & get_object ()
 
const TObject & get_object () const
 
const statefind_state (state_id_t state_id)
 
virtual void start (const bool on_entry_initial=true)
 
virtual void process_event (const event_id_t event_id)
 
- Public Member Functions inherited from etl::istate_chart
state_id_t get_state_id () const
 

Additional Inherited Members

- Public Types inherited from etl::istate_chart
typedef int state_id_t
 
typedef int event_id_t
 
- Protected Member Functions inherited from etl::istate_chart
 istate_chart (state_id_t current_state_id_)
 
- Protected Attributes inherited from etl::istate_chart
state_id_t current_state_id
 The current state id.
 

Detailed Description

template<typename TObject>
class etl::state_chart< TObject >

Simple Finite State Machine.

Constructor & Destructor Documentation

◆ state_chart() [1/2]

template<typename TObject >
ETL_CONSTEXPR etl::state_chart< TObject >::state_chart ( TObject &  object_,
const transition transition_table_begin_,
const transition transition_table_end_,
const state_id_t  state_id_ 
)
inline

Constructor.

Parameters
object_A reference to the implementation object.
transition_table_begin_The start of the table of transitions.
transition_table_end_The end of the table of transitions.
state_id_The initial state id.

◆ state_chart() [2/2]

template<typename TObject >
ETL_CONSTEXPR etl::state_chart< TObject >::state_chart ( TObject &  object_,
const transition transition_table_begin_,
const transition transition_table_end_,
const state state_table_begin_,
const state state_table_end_,
const state_id_t  state_id_ 
)
inline

Constructor.

Parameters
object_A reference to the implementation object.
transition_table_begin_The start of the table of transitions.
transition_table_end_The end of the table of transitions.
state_table_begin_The start of the state table.
state_table_end_The end of the state table.
state_id_The initial state id.

Member Function Documentation

◆ find_state()

template<typename TObject >
const state* etl::state_chart< TObject >::find_state ( state_id_t  state_id)
inline

Gets the current state id.

Returns
The current state id.

◆ get_object() [1/2]

template<typename TObject >
TObject& etl::state_chart< TObject >::get_object ( )
inline

Gets a reference to the implementation object.

Returns
Reference to the implementation object.

◆ get_object() [2/2]

template<typename TObject >
const TObject& etl::state_chart< TObject >::get_object ( ) const
inline

Gets a const reference to the implementation object.

Returns
Const reference to the implementation object.

◆ process_event()

template<typename TObject >
virtual void etl::state_chart< TObject >::process_event ( const event_id_t  event_id)
inlinevirtual

Processes the specified event. The state machine will action the first item in the transition table that satisfies the conditions for executing the action.

Parameters
event_idThe id of the event to process.

Implements etl::istate_chart.

◆ set_state_table()

template<typename TObject >
void etl::state_chart< TObject >::set_state_table ( const state state_table_begin_,
const state state_table_end_ 
)
inline

Sets the state table.

Parameters
state_table_begin_The start of the state table.
state_table_end_The end of the state table.

◆ set_transition_table()

template<typename TObject >
void etl::state_chart< TObject >::set_transition_table ( const transition transition_table_begin_,
const transition transition_table_end_ 
)
inline

Sets the transition table.

Parameters
state_table_begin_The start of the state table.
state_table_end_The end of the state table.

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