Alex exoskeleton
ALEX SoftwareDocumentation
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 20
23 
24 /* Forward declarations*/
25 
30 class State {
31  friend class StateMachine;
32  // A State machine class can access the private and protected members of a state class */
33  public:
39 
46  State(StateMachine *p, const char n[] = NULL) {
47  owner = p;
48  numarcs = 0;
49  name = n; // name of state
50  };
51  ~State();
52  // Arc creating and accessing functions
53  bool addArc(Transition *t);
54  Transition *getActiveArc(void);
55 
60  virtual void entry(void) = 0;
61 
66  virtual void during(void) = 0;
67 
72  virtual void exit(void) = 0;
73 
79  const char *getName(void);
80 
85  void printName(void);
86 
87  private:
93  const char *name; // Pointer to the name of this State
94  int numarcs;
95 };
96 
97 #endif //EXO_STATE_H
Transition * arclist[MAXARCS]
List of possible transitions.
Definition: State.h:92
State(StateMachine *p, const char n[]=NULL)
Construct a new State object.
Definition: State.h:46
int numarcs
Definition: State.h:94
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:26
const char * name
Definition: State.h:93
StateMachine * owner
Pointer to the owning state machine.
Definition: State.h:38
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:30
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:26
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