DiaDes  0.1
DIAgnosis of Discrete-Event System
StateTable.hh
Go to the documentation of this file.
1 #ifndef __DIADES__AUTOMATA__STATETABLE__HH
2 #define __DIADES__AUTOMATA__STATETABLE__HH
3 
4 
5 #include <vector>
7 #include <diades/graph/Graph.hh>
8 
9 
10 
11 
12 using namespace std;
13 using namespace Diades::Graph;
14 namespace Diades
15 {
16  namespace Automata
17  {
18 
19  typedef Node State;
20 
24  class StateTableInvalid : public runtime_error, public domain_error
25  {
26 
27  public:
31  StateTableInvalid(const string& whatArg) : runtime_error(whatArg), domain_error(whatArg)
32  {
33  cerr << "EXCEPTION StateTable -> " << whatArg << endl;
34  }
35  };
36 
37 
38 
39 
40 
41 
42 
43 
47  class StateNode
48  {
49  private:
50  State _state; // state associated to the node
52  // StateNode ** _array; // array of nodes associated to the current node
53  // // _array must contain StateNodes associated to
54  // // another and unique graph
55  // // the size of the array depends on this graph
56  // unsigned _size;
57  vector<StateNode *> _array;
58 
59 
60  public:
61 
62  StateNode(State s, unsigned size);
63  ~StateNode();
64  void setState(State s) { _state = s; }
65  State getState() const { return _state; }
66  StateNode * getSynchronisedState() const { return _array[0]; }
67  StateNode * getNext(State s) const;
68  StateNode * setNext(State s, unsigned size);
69  StateNode * setNext(State s, const Graph::Graph & graph);
70  StateNode * getDown() const { return _down; }
71  void setDown(StateNode * down) { _down = down; }
72  void printNode(int tabNb) const;
73  };
74 
75 
76 
83  class StateTable
84  {
85  private:
86  vector<StateNode *> _roots;
87 
88  public:
89 
91  StateTable(unsigned size):_roots(size){}
92 
93 
94 
96  ~StateTable();
97 
98 
99 
109  State insert(const vector<State> & states, State synchronisedState);
110 
111 
112 
113 
114 
120  State getSynchronisedState(const vector<State> & states) const;
121 
122 
126  void printTable() const;
127  };
128 
129 
130 
131  };
132 
133 };
134 
135 
136 
137 #endif
STL namespace.
StateNode * getSynchronisedState() const
Definition: StateTable.hh:66
void setDown(StateNode *down)
Definition: StateTable.hh:71
StIndexes states
Definition: Run.cc:266
StateNode * getDown() const
Definition: StateTable.hh:70
StateTableInvalid(const string &whatArg)
Definition: StateTable.hh:31
AutFsm::State State
Definition: Run.cc:72
StateTable(unsigned size)
Default constructor.
Definition: StateTable.hh:91
Namespace of the Diades project.
vector< StateNode * > _array
Definition: StateTable.hh:57
vector< StateNode * > _roots
Definition: StateTable.hh:86
boost::adjacency_list Graph
Definition: ScaleFree.cc:9
Namespace of the Graph library (libGraph)
Definition: BFS.hh:9