DiaDes  0.1
DIAgnosis of Discrete-Event System
MarkingTable.hh
Go to the documentation of this file.
1 #ifndef __DIADES__PETRI__MARKINGTABLE__HH
2 #define __DIADES__PETRI__MARKINGTABLE__HH
3 
4 #include<unordered_map>
5 #include "Marking.hh"
6 
7 using std::unordered_map;
8 
9 namespace Diades
10 {
11  namespace Petri
12  {
14  {
15  private:
16  unordered_map<Marking,Graph::Node> _table;
17  Graph::Node _null;
18 
19  public:
20  MarkingTable():_table(){}
21 
22 
23 
24 
25  const Marking & assign(const Marking & marking, const Graph::Node & node)
26  {
27  _table[marking] = node;
28  return _table.find(marking)->first;
29  }
30 
31  const Graph::Node & get(const Marking & marking) const
32  {
33  unordered_map<Marking,Graph::Node>::const_iterator it = _table.find(marking);
34  if(it==_table.end())
35  {
36  return _null;
37  }
38  return it->second;
39  }
40 
41  unordered_map<Marking,Graph::Node>::const_iterator begin() const
42  {
43  return _table.begin();
44  }
45  unordered_map<Marking,Graph::Node>::const_iterator end() const
46  {
47  return _table.end();
48  }
49 
50 
51  };
52 
53 
54  };
55 };
56 
57 
58 
59 #endif
unordered_map< Marking, Graph::Node > _table
Definition: MarkingTable.hh:16
Namespace of the Diades project.
unordered_map< Marking, Graph::Node >::const_iterator begin() const
Definition: MarkingTable.hh:41
const Marking & assign(const Marking &marking, const Graph::Node &node)
Definition: MarkingTable.hh:25
unordered_map< Marking, Graph::Node >::const_iterator end() const
Definition: MarkingTable.hh:45