CORC Project
CANOpen Robot Controller Software Documentation
StateMachine.h
Go to the documentation of this file.
1 
14 #ifndef EXO_STATEMACHINE_H
15 #define EXO_STATEMACHINE_H
16 
17 class State;
18 
19 #include "State.h"
25 class StateMachine {
26  public:
31  StateMachine(void);
37  void initialize(State *i);
38 
44  State *getCurState(void);
45 
50  void activate(void);
51 
58  virtual void update(void);
59 
60  private:
66 };
67 
72 #define EventObject(_name_) \
73  class _name_; \
74  friend class _name_; \
75  class _name_ : public Event { \
76  public: \
77  _name_(StateMachine *m, \
78  const char *name = NULL) \
79  : Event(m, name){}; \
80  bool check(void); \
81  }; \
82  _name_
83 
89 #define NewTransition(_from_, _event_, _to_) \
90  _from_->addArc(new Transition(_to_, _event_))
91 
92 #endif //EXO_STATEMACHINE_H
Abstract class representing a state machine. Includes a number of State and Transition objects...
Definition: StateMachine.h:25
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:65
Abstract class representing a state in a StateMachine.
Definition: State.h:28
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...