cyclegraph: add destructor, use 'const' appropriately
[model-checker.git] / cyclegraph.h
1 #ifndef CYCLEGRAPH_H
2 #define CYCLEGRAPH_H
3
4 #include "hashtable.h"
5 #include <vector>
6 #include <inttypes.h>
7
8 class CycleNode;
9 class ModelAction;
10
11 /** @brief A graph of Model Actions for tracking cycles. */
12 class CycleGraph {
13  public:
14         CycleGraph();
15         ~CycleGraph();
16         void addEdge(const ModelAction *from, const ModelAction *to);
17         bool checkForCycles();
18
19  private:
20         CycleNode * getNode(const ModelAction *);
21         HashTable<const ModelAction *, CycleNode *, uintptr_t, 4> actionToNode;
22         bool checkReachable(CycleNode *from, CycleNode *to);
23         bool hasCycles;
24 };
25
26 class CycleNode {
27  public:
28         CycleNode(const ModelAction *action);
29         void addEdge(CycleNode * node);
30         std::vector<CycleNode *> * getEdges();
31
32  private:
33         const ModelAction *action;
34         std::vector<CycleNode *> edges;
35 };
36
37 #endif