nodestack: add class NodeStack and class Node
[model-checker.git] / action.h
1 #ifndef __ACTION_H__
2 #define __ACTION_H__
3
4 #include <list>
5
6 #include "threads.h"
7 #include "libatomic.h"
8
9 #define VALUE_NONE -1
10
11 typedef enum action_type {
12         THREAD_CREATE,
13         THREAD_YIELD,
14         THREAD_JOIN,
15         ATOMIC_READ,
16         ATOMIC_WRITE
17 } action_type_t;
18
19 /* Forward declaration */
20 class TreeNode;
21 class Node;
22
23 class ModelAction {
24 public:
25         ModelAction(action_type_t type, memory_order order, void *loc, int value);
26         void print(void);
27
28         thread_id_t get_tid() { return tid; }
29         action_type get_type() { return type; }
30         memory_order get_mo() { return order; }
31         void * get_location() { return location; }
32         int get_seq_number() { return seq_number; }
33
34         TreeNode * get_treenode() { return treenode; }
35         void set_node(TreeNode *n) { treenode = n; }
36         void set_node(Node *n) { node = n; }
37
38         bool is_read();
39         bool is_write();
40         bool is_acquire();
41         bool is_release();
42         bool same_var(ModelAction *act);
43         bool same_thread(ModelAction *act);
44         bool is_dependent(ModelAction *act);
45 private:
46         action_type type;
47         memory_order order;
48         void *location;
49         thread_id_t tid;
50         int value;
51         TreeNode *treenode;
52         Node *node;
53         int seq_number;
54 };
55
56 typedef std::list<class ModelAction *> action_list_t;
57
58 #endif /* __ACTION_H__ */