Robot Devastation
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
rd::State Class Referenceabstract

Base class for each of the states of a FiniteStateMachine.

#include <State.hpp>

Inheritance diagram for rd::State:
rd::DeadState rd::GameState rd::InitState rd::MockState

Public Member Functions

virtual bool setup ()=0
 Function executed just before the loop function, when the state is enabled. More...
 
virtual bool loop ()=0
 Function executed periodically when the state is active. More...
 
virtual bool cleanup ()=0
 Function excuted when this state is going to be stopped (due to an error or a transition) More...
 
virtual int evaluateConditions ()=0
 This function is called after each call to loop() in order to know the transition to make. More...
 
const std::string & getStateId () const
 Returns the string that identifies the state.
 

Static Public Member Functions

static StategetEndState ()
 

Protected Attributes

std::string state_id
 Name of the current state.
 

Member Function Documentation

◆ cleanup()

virtual bool rd::State::cleanup ( )
pure virtual
Returns
False if some problem ocurred

Implemented in rd::GameState, rd::InitState, rd::DeadState, and rd::MockState.

◆ evaluateConditions()

virtual int rd::State::evaluateConditions ( )
pure virtual

An integer value is assigned to each possible transition to identify them.

Returns
Transition selected depending on the conditions of the state

Implemented in rd::GameState, rd::InitState, rd::DeadState, and rd::MockState.

◆ loop()

virtual bool rd::State::loop ( )
pure virtual
Returns
False if some problem ocurred

Implemented in rd::GameState, rd::InitState, rd::DeadState, and rd::MockState.

◆ setup()

virtual bool rd::State::setup ( )
pure virtual
Returns
False if some problem ocurred

Implemented in rd::GameState, rd::InitState, rd::DeadState, and rd::MockState.


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