diff options
Diffstat (limited to 'generator/group.h')
-rw-r--r-- | generator/group.h | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/generator/group.h b/generator/group.h new file mode 100644 index 0000000..efb8c5d --- /dev/null +++ b/generator/group.h | |||
@@ -0,0 +1,80 @@ | |||
1 | #ifndef GROUP_H_EDAFB5DC | ||
2 | #define GROUP_H_EDAFB5DC | ||
3 | |||
4 | #include <map> | ||
5 | #include <set> | ||
6 | #include <string> | ||
7 | #include <cassert> | ||
8 | #include "role.h" | ||
9 | |||
10 | namespace verbly { | ||
11 | namespace generator { | ||
12 | |||
13 | class frame; | ||
14 | class database; | ||
15 | |||
16 | class group { | ||
17 | public: | ||
18 | |||
19 | // Constructor | ||
20 | |||
21 | group(); | ||
22 | |||
23 | // Mutators | ||
24 | |||
25 | void setParent(const group& parent); | ||
26 | |||
27 | void addRole(std::string name, role r); | ||
28 | |||
29 | void addFrame(const frame& f); | ||
30 | |||
31 | // Accessors | ||
32 | |||
33 | int getId() const | ||
34 | { | ||
35 | return id_; | ||
36 | } | ||
37 | |||
38 | bool hasParent() const | ||
39 | { | ||
40 | return (parent_ != nullptr); | ||
41 | } | ||
42 | |||
43 | const group& getParent() const | ||
44 | { | ||
45 | // Calling code should always call hasParent first | ||
46 | assert(parent_ != nullptr); | ||
47 | |||
48 | return *parent_; | ||
49 | } | ||
50 | |||
51 | std::set<std::string> getRoles() const; | ||
52 | |||
53 | const role& getRole(std::string name) const; | ||
54 | |||
55 | std::set<const frame*> getFrames() const; | ||
56 | |||
57 | private: | ||
58 | |||
59 | static int nextId_; | ||
60 | |||
61 | const int id_; | ||
62 | |||
63 | const group* parent_ = nullptr; | ||
64 | std::map<std::string, role> roles_; | ||
65 | std::set<const frame*> frames_; | ||
66 | |||
67 | // Caches | ||
68 | |||
69 | std::set<std::string> roleNames_; | ||
70 | |||
71 | }; | ||
72 | |||
73 | // Serializer | ||
74 | |||
75 | database& operator<<(database& db, const group& arg); | ||
76 | |||
77 | }; | ||
78 | }; | ||
79 | |||
80 | #endif /* end of include guard: GROUP_H_EDAFB5DC */ | ||