A finite state machine class. More...
#include <state_machine.h>


Public Member Functions | |
| StateMachine (std::string name) | |
| Construct a new StateMachine with the given name. | |
| StateMachine () | |
| Construct an unnamed StateMachine. | |
| StateMachine & | set_initial (State &s) |
| StateMachine & | add_transition (std::string event_name, State &from, State &to) |
| StateMachine & | set_propagate (bool val) |
| State & | current () |
| void | init () |
| Do not override init() for a state machine. | |
| void | start () |
| Do not override init() for a state machine. | |
| void | update () |
| Do not override init() for a state machine. | |
| void | stop () |
| Do not override init() for a state machine. | |
Public Member Functions inherited from elma::Process | |
| Process () | |
| Default constructor. Names process "no name". | |
| Process (std::string name) | |
| Constructor that takes a name for the process. More... | |
| string | name () |
| status_type | status () |
| high_resolution_clock::duration | period () |
| int | num_updates () |
| time_point< high_resolution_clock > | start_time () |
| high_resolution_clock::duration | last_update () |
| high_resolution_clock::duration | previous_update () |
| Channel & | channel (string name) |
| Access a channel with the given name. More... | |
| double | milli_time () |
| The time since the last update in millisconds, as a double. More... | |
| double | delta () |
| The most recent amount of time between updates. More... | |
| void | watch (string event_name, std::function< void(Event &)> handler) |
| void | emit (const Event &event) |
| void | http_get (std::string url, std::function< void(json &)> handler) |
Additional Inherited Members | |
Public Types inherited from elma::Process | |
| enum | status_type { UNINITIALIZED, STOPPED, RUNNING } |
A finite state machine class.
Together with the State and Transition classes, this class is used to make a finite state machine process. For example, here is a toggle switch machine
Definition at line 13 of file state_machine.h.
| StateMachine & elma::StateMachine::add_transition | ( | std::string | event_name, |
| State & | from, | ||
| State & | to | ||
| ) |
Add a transition to the state machine
| event_name | Events with this name will trigger the transition |
| from | The state the machine must be in to take the transition |
| to | The state the machine will go to upon taking the transition |
Definition at line 13 of file state_machine.cc.
|
inline |
Definition at line 41 of file state_machine.h.
| StateMachine & elma::StateMachine::set_initial | ( | State & | s | ) |
Set the initial state of the state machine
| s | An instantiation of a class derived from State |
Definition at line 8 of file state_machine.cc.
|
inline |
Set whether the state machine should propagate transitions (default = false)
| val | True or false |
Definition at line 38 of file state_machine.h.
1.8.8