Alex exoskeleton
ALEX SoftwareDocumentation
StateMachine.h
Go to the documentation of this file.
1 
11 // Created by William Campbell on 2019-09-24.
12 *
13 #ifndef EXO_STATEMACHINE_H
14 #define EXO_STATEMACHINE_H
15  //#include <cstddef>
16 
17  class State;
18 
19 #include "State.h"
20 /* Forward declarations*/
21 
26 class StateMachine {
27  public:
32  StateMachine(void);
38  void initialize(State *i);
39 
45  State *getCurState(void);
46 
51  void activate(void);
52 
59  virtual void update(void);
60 
61  private:
67 };
68 
73 #define EventObject(_name_) \
74  class _name_; \
75  friend class _name_; \
76  class _name_ : public Event { \
77  public: \
78  _name_(StateMachine *m, \
79  const char *name = NULL) \
80  : Event(m, name){}; \
81  bool check(void); \
82  }; \
83  _name_
84 
90 #define NewTransition(_from_, _event_, _to_) \
91  _from_->addArc(new Transition(_to_, _event_))
92 
93 #endif //EXO_STATEMACHINE_H
Abstract class representing a state machine. Includes a number of State and Transition objects...
Definition: StateMachine.h:26
StateMachine(void)
Construct a new State Machine object.
void activate(void)
Calls the entry method of the current state.
State * currentState
Pointer to the current state.
Definition: StateMachine.h:66
Abstract class representing a state in a StateMachine.
Definition: State.h:30
State * getCurState(void)
Returns a pointer to the current state.
void initialize(State *i)
Sets the current state. Note: No check made.
virtual void update(void)
Processes the state machine. For each possible transition, checks if that transition should be made I...