yasmine
|
#include <state_machine_base.hpp>
Public Member Functions | |
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_state & | get_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 transition & | add_transition (transition_uptr _transition) |
Add a transition to the state machine. The state machine takes ownership of the transition. More... | |
virtual transition & | add_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 transition & | add_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 transition & | add_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 transition & | add_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 transition & | add_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 transition & | add_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 transition & | add_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 transition & | add_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... | |
virtual bool | fire_event (const event_sptr &_event)=0 |
bool | check (state_machine_defects &_defects) const |
Check the state machine for defects by checking the constraints of each component. More... | |
virtual bool | run ()=0 |
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 |
virtual bool | push (const event_sptr &_event)=0 |
Protected Member Functions | |
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 | |
static void | stop_all_async_states (state &_state) |
|
explicit |
Constructor.
_name | Name of the state machine. |
_event_processing_callback | Event processing callback interface pointer. It can be a nullptr if no callback interface should be used. |
|
virtual |
|
virtual |
Add a transition to the state machine. The state machine takes ownership of the transition.
_transition | A transition. |
|
virtual |
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.
_event_id | ID of the event for which the transition is enabled. |
_source | The source vertex. |
_target | The target vertex. |
_kind | Transition kind. Default is EXTERNAL. |
_guard | The guard of the transition. Default is an empty function. |
_behavior | The behavior of the transition. Default is an empty function. |
|
virtual |
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.
event_ids | List of IDs of the events for which the transition is enabled. |
_source | The source vertex. |
_target | The target vertex. |
_kind | Transition kind. Default is EXTERNAL. |
_guard | The guard of the transition. Default is an empty function. |
_behavior | The behavior of the transition. Default is an empty function. |
|
virtual |
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.
_event_id | ID of the event for which the transition is enabled. |
_source | The source vertex. |
_target | The target vertex. |
_guard | The guard of the transition. |
_kind | Transition kind. Default is EXTERNAL. |
|
virtual |
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.
_event_ids | IDs of the events for which the transition is enabled. |
_source | The source vertex. |
_target | The target vertex. |
_guard | The guard of the transition. |
_kind | Transition kind. Default is EXTERNAL. |
|
virtual |
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.
_event_id | ID of the event for which the transition is enabled. |
_source | The source vertex. |
_target | The target vertex. |
_guard | The guard of the transition. |
_behavior | The behavior of the transition. |
_kind | Transition kind. Default is EXTERNAL. |
|
virtual |
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.
_event_ids | IDs of the events for which the transition is enabled. |
_source | The source vertex. |
_target | The target vertex. |
_guard | The guard of the transition. |
_behavior | The behavior of the transition. |
_kind | Transition kind. Default is EXTERNAL. |
|
virtual |
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.
_event_id | ID of the event for which the transition is enabled. |
_source | The source vertex. |
_target | The target vertex. |
_behavior | The behavior of the transition. |
_kind | Transition kind. Default is EXTERNAL. |
|
virtual |
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.
_event_ids | IDs of the events for which the transition is enabled. |
_source | The source vertex. |
_target | The target vertex. |
_behavior | The behavior of the transition. |
_kind | Transition kind. Default is EXTERNAL. |
bool sxy::state_machine_base::check | ( | state_machine_defects & | _defects | ) | const |
Check the state machine for defects by checking the constraints of each component.
_defects | Collected for all found defects. |
|
pure virtual |
Implemented in sxy::SX_FINAL, and sxy::sync_state_machine.
|
virtual |
Get the name of the state machine.
composite_state & sxy::state_machine_base::get_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.
|
virtual |
Stops the state machine. It checks for active asynchronous simple states and stops their do behaviors.
Reimplemented in sxy::SX_FINAL, and sxy::SX_FINAL.
|
virtual |
Set the internal flag of the state machine, to interrupt all processes inside the state machine and to stop the state machine.
|
virtual |
Get the internal flag of the state machine that specify if the run of state machine is interrupted.
Implements sxy::interruptible.
|
protected |
|
pure virtual |
Implemented in sxy::SX_FINAL, sxy::SX_FINAL, and sxy::sync_state_machine.
|
protected |
Starts the state machine.
_async_event_handler | Pointer to an asynchronous event handler. It's used by the asynchronous state machine if it has to process asynchronous errors that occur in the asynchronous behavior of asynchronous simple states. |
|
virtual |
Sets the behavior for handler of unhandled events.
_behavior |
|
staticprotected |