Elma
An event loop manager for embedded systems
Public Member Functions | Friends | List of all members
elma::State Class Referenceabstract

States for the StateMachine class. More...

#include <state.h>

+ Inheritance diagram for elma::State:

Public Member Functions

 State ()
 Construct an unnamed State.
 
 State (std::string name)
 Construct a state with the given name.
 
std::string name ()
 
int id ()
 
virtual void entry (const Event &e)=0
 
virtual void during ()=0
 
virtual void exit (const Event &e)=0
 
void emit (const Event &e)
 
StateMachinestate_machine ()
 

Friends

class StateMachine
 

Detailed Description

States for the StateMachine class.

States are used with the StateMachine class. For example usage, see the documentation for that class.

Definition at line 14 of file state.h.

Member Function Documentation

◆ during()

virtual void elma::State::during ( )
pure virtual

A method that derived instances should define. It is called repeatedly by the update() method of the containing StateMachine when the state is active.

Implemented in microwave_example::DoorOpen, microwave_example::DoorClosedOn, microwave_example::DoorClosedOff, and toggle_switch_example::Mode.

◆ emit()

void elma::State::emit ( const Event e)

Emit an event. A wrapper around the emit() method of Manager

Parameters
eThe event to emit

Definition at line 5 of file state.cc.

◆ entry()

virtual void elma::State::entry ( const Event e)
pure virtual

A method that derived instances should define. It is called when the state is entered by the state machine either when the machine starts or when a transition to the state is fired.

Parameters
eThe event that led to the transition into the state

Implemented in microwave_example::DoorOpen, microwave_example::DoorClosedOn, microwave_example::DoorClosedOff, and toggle_switch_example::Mode.

◆ exit()

virtual void elma::State::exit ( const Event e)
pure virtual

A method that derived instances should define. It is called just before the state is exited by the state machine when a transition from the state is fired.

Parameters
eThe event that led to the transition out of the state

Implemented in microwave_example::DoorOpen, microwave_example::DoorClosedOn, microwave_example::DoorClosedOff, and toggle_switch_example::Mode.

◆ id()

int elma::State::id ( )
inline
Returns
The id of the state (used internally, do not depend on its result)

Definition at line 34 of file state.h.

◆ name()

std::string elma::State::name ( )
inline
Returns
The name of the state

Definition at line 31 of file state.h.

◆ state_machine()

StateMachine& elma::State::state_machine ( )
inline
Returns
Get a reference to the parent state machine.

Definition at line 57 of file state.h.


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