Robot Devastation
StateDirector.hpp
1 // Authors: see AUTHORS.md at project root.
2 // CopyPolicy: released under the terms of the LGPLv2.1, see LICENSE at project root.
3 // URL: https://github.com/asrob-uc3m/robotDevastation
4 
5 #ifndef __RD_STATE_DIRECTOR_HPP__
6 #define __RD_STATE_DIRECTOR_HPP__
7 
8 #include <map>
9 
10 #include "State.hpp"
11 
12 namespace rd{
13 
20 {
21  public:
23  StateDirector(State * state);
24  virtual ~StateDirector();
25 
27  std::string getStateId() const;
28 
35  virtual bool Start() = 0;
36 
43  virtual bool Stop() = 0;
44 
50  virtual bool addTransition( StateDirector * nextState, int condition);
51 
53  virtual bool isActive() const;
54 
55  protected:
56  State * state;
57  bool active;
58  std::map<int, StateDirector * > nextStates;
59 };
60 }
61 #endif // __RD_STATE_DIRECTOR_HPP__
rd::StateDirector::Stop
virtual bool Stop()=0
Function to stop the attached State.
rd::StateDirector::StateDirector
StateDirector(State *state)
Creates a StateDirector attached to a State.
Definition: StateDirector.cpp:11
rd
The main, catch-all namespace for Robot Devastation.
Definition: groups.dox:4
rd::StateDirector::isActive
virtual bool isActive() const
Returns the current state of the State.
Definition: StateDirector.cpp:48
rd::StateDirector::Start
virtual bool Start()=0
Function that starts the attached State.
rd::State
Base class for each of the states of a FiniteStateMachine.
Definition: State.hpp:18
rd::StateDirector::getStateId
std::string getStateId() const
Allows access to the id of the attached State.
Definition: StateDirector.cpp:25
rd::StateDirector::addTransition
virtual bool addTransition(StateDirector *nextState, int condition)
Adds a transition to a given state depending on a given condition.
Definition: StateDirector.cpp:33
rd::StateDirector
A base class for controlling flow of States of a Finite State Machine.
Definition: StateDirector.hpp:19