yasmine
sxy::sync_state_machine Class Reference

Class for the "single-threaded version" of the state machine. It provides the methods to start the state machine, to fire events, to check the state machine for possible defects and to get the root state reference. More...

#include <sync_state_machine.hpp>

Inheritance diagram for sxy::sync_state_machine:
sxy::state_machine_base sxy::state_machine_introspection sxy::event_collector sxy::interruptible

Public Member Functions

 sync_state_machine (const std::string &_name, event_processing_callback *const _event_processing_callback=SX_NULLPTR)
 Constructor. More...
 
virtual ~sync_state_machine () SX_NOEXCEPT SX_OVERRIDE
 
virtual bool push (const event_sptr &_event) SX_OVERRIDE
 
virtual bool fire_event (const event_sptr &_event) SX_OVERRIDE
 Fire the given event. More...
 
virtual bool run () SX_OVERRIDE
 Starts the state machine. More...
 
- Public Member Functions inherited from sxy::state_machine_base
 state_machine_base (const std::string &_name, event_processing_callback *const _event_processing_callback=SX_NULLPTR)
 Constructor. More...
 
virtual ~state_machine_base () SX_NOEXCEPT SX_OVERRIDE
 
composite_stateget_root_state () const
 Returns the root state of the state machine. Commonly used to add regions to the root state and to create transitions from and to the root state. More...
 
virtual transitionadd_transition (transition_uptr _transition)
 Add a transition to the state machine. The state machine takes ownership of the transition. More...
 
virtual transitionadd_transition (const event_id _event_id, vertex &_source, vertex &_target, const sxy::transition_kind _kind=transition_kind::EXTERNAL, const constraint_function &_guard=constraint_function(), const behavior_function &_behavior=behavior_function())
 Creates a transition with the given name, kind, event, guard and behavior between the given source and target and adds it to the state machine. More...
 
virtual transitionadd_transition (const event_ids &_event_ids, vertex &_source, vertex &_target, const sxy::transition_kind _kind=transition_kind::EXTERNAL, const constraint_function &_guard=constraint_function(), const behavior_function &_behavior=behavior_function())
 Creates a transition with the given name, kind, event, guard and behavior between the given source and target and adds it to the state machine. More...
 
virtual transitionadd_transition (const event_id _event_id, vertex &_source, vertex &_target, const constraint_function &_guard, const sxy::transition_kind _kind=transition_kind::EXTERNAL)
 Creates a transition with the given name, kind, event, guard between the given source and target and adds it to the state machine. No behavior is provided. More...
 
virtual transitionadd_transition (const event_ids &_event_ids, vertex &_source, vertex &_target, const constraint_function &_guard, const sxy::transition_kind _kind=transition_kind::EXTERNAL)
 Creates a transition with the given name, kind, events, guard between the given source and target and adds it to the state machine. No behavior is provided. More...
 
virtual transitionadd_transition (const event_id _event_id, vertex &_source, vertex &_target, const constraint_function &_guard, const behavior_function &_behavior, const sxy::transition_kind _kind=transition_kind::EXTERNAL)
 Creates a transition with the given name, kind, event, guard and behavior between the given source and target and adds it to the state machine. More...
 
virtual transitionadd_transition (const event_ids &_event_ids, vertex &_source, vertex &_target, const constraint_function &_guard, const behavior_function &_behavior, const sxy::transition_kind _kind=transition_kind::EXTERNAL)
 Creates a transition with the given name, kind, events, guard and behavior between the given source and target and adds it to the state machine. More...
 
virtual transitionadd_transition (const event_id _event_id, vertex &_source, vertex &_target, const behavior_function &_behavior, const sxy::transition_kind _kind=transition_kind::EXTERNAL)
 Creates a transition with the given name, kind, event and behavior between the given source and target and adds it to the state machine. No guard is provided. More...
 
virtual transitionadd_transition (const event_ids &_event_ids, vertex &_source, vertex &_target, const behavior_function &_behavior, const sxy::transition_kind _kind=transition_kind::EXTERNAL)
 Creates a transition with the given name, kind, events and behavior between the given source and target and adds it to the state machine. No guard is provided. More...
 
bool check (state_machine_defects &_defects) const
 Check the state machine for defects by checking the constraints of each component. More...
 
virtual void halt ()
 Stops the state machine. It checks for active asynchronous simple states and stops their do behaviors. More...
 
virtual void interrupt ()
 Set the internal flag of the state machine, to interrupt all processes inside the state machine and to stop the state machine. More...
 
virtual bool is_interrupted () const SX_OVERRIDE
 Get the internal flag of the state machine that specify if the run of state machine is interrupted. More...
 
virtual void set_behavior_of_unhandled_event_handler (const behavior_function &_behavior)
 Sets the behavior for handler of unhandled events. More...
 
virtual std::string get_name () const
 Get the name of the state machine. More...
 
- Public Member Functions inherited from sxy::event_collector
 event_collector ()
 
virtual ~event_collector () SX_NOEXCEPT
 

Additional Inherited Members

- Protected Member Functions inherited from sxy::state_machine_base
bool run (async_event_handler *const _async_event_handler)
 Starts the state machine. More...
 
bool process_event (const event_sptr &_event, async_event_handler *const _async_event_handler)
 
- Static Protected Member Functions inherited from sxy::state_machine_base
static void stop_all_async_states (state &_state)
 

Detailed Description

Class for the "single-threaded version" of the state machine. It provides the methods to start the state machine, to fire events, to check the state machine for possible defects and to get the root state reference.

Constructor & Destructor Documentation

◆ sync_state_machine()

sxy::sync_state_machine::sync_state_machine ( const std::string &  _name,
event_processing_callback *const  _event_processing_callback = SX_NULLPTR 
)
explicit

Constructor.

Parameters
_nameName of the state machine.
_event_processing_callbackEvent processing callback interface pointer. It can be a nullptr if no callback interface should be used.

◆ ~sync_state_machine()

sxy::sync_state_machine::~sync_state_machine ( )
virtual

Member Function Documentation

◆ fire_event()

bool sxy::sync_state_machine::fire_event ( const event_sptr _event)
virtual

Fire the given event.

Parameters
_eventEvent to be fired.
Returns
true if event was successfully fired, else false what means that a terminate pseudostate has been reached, the state machine was stopped and no further events can be fired.

Implements sxy::state_machine_base.

◆ push()

bool sxy::sync_state_machine::push ( const event_sptr _event)
virtual

Implements sxy::event_collector.

◆ run()

bool sxy::sync_state_machine::run ( )
virtual

Starts the state machine.

Returns
bool true if state machine can be started, else false what means that a terminate pseudostate has been reached and the state machine is stopped.

Implements sxy::state_machine_base.


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