#include <rtctk/componentFramework/stateMachineEngine.hpp>
|
| | StateMachineEngine () |
| |
| | ~StateMachineEngine () |
| |
| void | RegisterExitEvent (rad::UniqueEvent exit_event) |
| | Register an exit event.
|
| |
| void | RegisterModel (const std::string &name, const std::string &model) |
| | Register a new state machine model.
|
| |
| void | AppendModel (const std::string &name, const std::string &model) |
| | Append state machine model fragment.
|
| |
| void | RegisterAction (const std::string &id, ActionMethod action) |
| | Register action.
|
| |
| template<class Event > |
| void | RegisterActionStatic (const std::string &id, std::function< void(const Event &)> action) |
| | Register action for statically known event type.
|
| |
| void | RegisterGuard (const std::string &id, GuardMethod guard) |
| | Register guard.
|
| |
| template<class Event > |
| void | RegisterGuardStatic (const std::string &id, std::function< bool(const Event &)> guard) |
| | Register guard for statically known event type.
|
| |
| void | RegisterActivity (const std::string &id, ActivityMethod activity, SuccessMethod on_success, FailureMethod on_failure) |
| | Register activity.
|
| |
| void | RegisterRejectHandler (const std::string &id, RejectMethod reject) |
| | Register reject handler.
|
| |
| template<typename T , typename Ex > |
| void | RegisterRejectHandler () |
| | Register default reject handler.
|
| |
| void | RegisterStateChangeHandler (StateMethod on_statechange) |
| | Register state changed handler.
|
| |
| void | PostEvent (rad::SharedEvent s) |
| | Injects a new event into the state machine engine.
|
| |
| std::string | GetState () |
| | Queries the current state.
|
| |
| void | Work () |
| | Runs the event loop of the state machine.
|
| |
| void | Stop () |
| | Stops execution of the state machine event loop.
|
| |
◆ StateMachineEngine()
| rtctk::componentFramework::StateMachineEngine::StateMachineEngine |
( |
| ) |
|
◆ ~StateMachineEngine()
| rtctk::componentFramework::StateMachineEngine::~StateMachineEngine |
( |
| ) |
|
◆ AppendModel()
| void rtctk::componentFramework::StateMachineEngine::AppendModel |
( |
const std::string & | name, |
|
|
const std::string & | model ) |
Append state machine model fragment.
Appends a state machine model fragment to the current model. The fragment must be a well-formed SCXML model. The fragment will be superimposed and merged with the existing model.
- Parameters
-
| name | Name of the model. |
| model | SCXML model as a string. |
◆ GetState()
| std::string rtctk::componentFramework::StateMachineEngine::GetState |
( |
| ) |
|
Queries the current state.
- Returns
- the current state as a string.
◆ PostEvent()
| void rtctk::componentFramework::StateMachineEngine::PostEvent |
( |
rad::SharedEvent | s | ) |
|
Injects a new event into the state machine engine.
- Parameters
-
◆ RegisterAction()
| void rtctk::componentFramework::StateMachineEngine::RegisterAction |
( |
const std::string & | id, |
|
|
ActionMethod | action ) |
Register action.
Usually the provided action method is not supposed to throw, in case it does throw all exceptions will be caught and logged.
- Parameters
-
| id | SCXML guard id. |
| action | Action handler. |
◆ RegisterActionStatic()
| void rtctk::componentFramework::StateMachineEngine::RegisterActionStatic |
( |
const std::string & | id, |
|
|
std::function< void(const Event &)> | action ) |
|
inline |
Register action for statically known event type.
- Precondition
- action must be valid.
- Template Parameters
-
- Parameters
-
| id | SCXML action id. |
| action | Action handler. |
◆ RegisterActivity()
Register activity.
Registers a state machine activity that is executed in a dedicated thread. When the activity terminates gracefully the success handler will be executed, this allows to add subsequent behaviour (e.g. posting a Done event). In case the activity throws an exception the exception is caught, logged and the failure handler is invoked, this allows the addition of behavour after errors (e.g. posting a Error event).
- Parameters
-
| id | SCXML activity id. |
| activity | Activity handler. |
| on_success | Success handler. |
| on_failure | Failure handler. |
◆ RegisterExitEvent()
| void rtctk::componentFramework::StateMachineEngine::RegisterExitEvent |
( |
rad::UniqueEvent | exit_event | ) |
|
Register an exit event.
Registers an exit event that is used to terminate the state machine engine when signals SIGINT, SIGTERM or SIGHUP are received.
- Parameters
-
| exit_event | rad event wrapped in unique_ptr. |
◆ RegisterGuard()
| void rtctk::componentFramework::StateMachineEngine::RegisterGuard |
( |
const std::string & | id, |
|
|
GuardMethod | guard ) |
Register guard.
Usually the provided guard method is not supposed to throw, in case it does throw all exceptions will be caught and logged. A guard that throws is automatically blocked so that the destination state is not reached. This is equivalent to returning false in the guard method.
- Parameters
-
| id | SCXML guard id. |
| guard | Guard handler. |
◆ RegisterGuardStatic()
| void rtctk::componentFramework::StateMachineEngine::RegisterGuardStatic |
( |
const std::string & | id, |
|
|
std::function< bool(const Event &)> | guard ) |
|
inline |
Register guard for statically known event type.
- Precondition
- guard must be valid.
- Template Parameters
-
- Parameters
-
| id | SCXML guard id. |
| guard | Guard handler. |
◆ RegisterModel()
| void rtctk::componentFramework::StateMachineEngine::RegisterModel |
( |
const std::string & | name, |
|
|
const std::string & | model ) |
Register a new state machine model.
Registers a SCXML state machine model to the engine.
- Parameters
-
| name | Name of the model. |
| model | SCXML model as a string. |
◆ RegisterRejectHandler() [1/2]
| void rtctk::componentFramework::StateMachineEngine::RegisterRejectHandler |
( |
| ) |
|
|
inline |
Register default reject handler.
Provides a default implementation for reject handlers that responds with with a message that the event was rejected. The default was provided to allow for uniform solutions and little typing.
◆ RegisterRejectHandler() [2/2]
| void rtctk::componentFramework::StateMachineEngine::RegisterRejectHandler |
( |
const std::string & | id, |
|
|
RejectMethod | reject ) |
Register reject handler.
Reject handlers can be registered for individual event types and they are called when events are not accepted by the state machine in certain states or when guards evaluate to false.
- Parameters
-
| id | Event id. |
| reject | Reject handler. |
◆ RegisterStateChangeHandler()
| void rtctk::componentFramework::StateMachineEngine::RegisterStateChangeHandler |
( |
StateMethod | on_statechange | ) |
|
Register state changed handler.
The provided method on_statechange will be called every time the state machine changes its state. It will include the actual state the state machine is in now.
- Parameters
-
| on_statechange | State change handler. |
◆ Stop()
| void rtctk::componentFramework::StateMachineEngine::Stop |
( |
| ) |
|
Stops execution of the state machine event loop.
◆ Work()
| void rtctk::componentFramework::StateMachineEngine::Work |
( |
| ) |
|
Runs the event loop of the state machine.
Does not return until the state machine is stopped.
The documentation for this class was generated from the following files: