CORC Project
CANOpen Robot Controller Software Documentation
State.h
Go to the documentation of this file.
1 
11 #ifndef EXO_STATE_H
12 #define EXO_STATE_H
13 
14 #include <cstddef>
15 #include <iostream>
16 
17 class StateMachine;
18 class Transition;
19 
20 #include "StateMachine.h"
21 #include "Transition.h"
22 #define MAXARCS 10 /*<!Define the max number of arcs (transitions) any state can have*/
23 
28 class State {
29  friend class StateMachine;
30  // A State machine class can access the private and protected members of a state class */
31  public:
37 
44  State(StateMachine *p, const char n[] = NULL) {
45  owner = p;
46  numarcs = 0;
47  name = n; // name of state
48  };
49  ~State();
50  // Arc creating and accessing functions
51  bool addArc(Transition *t);
52  Transition *getActiveArc(void);
53 
58  virtual void entry(void) = 0;
59 
64  virtual void during(void) = 0;
65 
70  virtual void exit(void) = 0;
71 
77  const char *getName(void);
78 
83  void printName(void);
84 
85  private:
90  Transition *arclist[MAXARCS]; /*<!Array of transition objects this state can transition to on exit*/
91  const char *name; /*<!Pointer to the name of this State*/
92  int numarcs;
93 };
94 
95 #endif //EXO_STATE_H
Transition * arclist[MAXARCS]
List of possible transitions.
Definition: State.h:90
State(StateMachine *p, const char n[]=NULL)
Construct a new State object.
Definition: State.h:44
int numarcs
Definition: State.h:92
void printName(void)
Prints the name of the state.
Definition: State.cpp:30
Abstract class representing a state machine. Includes a number of State and Transition objects...
Definition: StateMachine.h:25
const char * name
Definition: State.h:91
StateMachine * owner
Pointer to the owning state machine.
Definition: State.h:36
const char * getName(void)
Returns the name of the state - Note that this.
Definition: State.cpp:26
bool addArc(Transition *t)
Definition: State.cpp:18
Transition * getActiveArc(void)
Definition: State.cpp:8
Abstract class representing a state in a StateMachine.
Definition: State.h:28
virtual void during(void)=0
Called continuously whilst in that state. Pure virtual function, must be overwritten by each state...
Represents possible transitions linking two State objects with an Event.
Definition: Transition.h:27
virtual void entry(void)=0
Called once when the state is entered. Pure virtual function, must be overwritten by each state...
~State()
Definition: State.cpp:34
virtual void exit(void)=0
Called once when the state exits. Pure virtual function, must be overwritten by each state...
#define MAXARCS
Definition: State.h:22