summary refs log tree commit diff stats
path: root/lib/group.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/group.h')
-rw-r--r--lib/group.h87
1 files changed, 87 insertions, 0 deletions
diff --git a/lib/group.h b/lib/group.h new file mode 100644 index 0000000..dd53503 --- /dev/null +++ b/lib/group.h
@@ -0,0 +1,87 @@
1#ifndef GROUP_H_BD6933C0
2#define GROUP_H_BD6933C0
3
4#include <stdexcept>
5#include <list>
6#include <vector>
7#include "field.h"
8#include "filter.h"
9
10struct sqlite3_stmt;
11
12namespace verbly {
13
14 class database;
15 class frame;
16
17 class group {
18 public:
19
20 // Default constructor
21
22 group() = default;
23
24 // Construct from database
25
26 group(const database& db, sqlite3_stmt* row);
27
28 // Accessors
29
30 operator bool() const
31 {
32 return valid_;
33 }
34
35 int getId() const
36 {
37 if (!valid_)
38 {
39 throw std::domain_error("Bad access to uninitialized group");
40 }
41
42 return id_;
43 }
44
45 const std::vector<frame>& getFrames() const;
46
47 // Type info
48
49 static const object objectType;
50
51 static const std::list<std::string> select;
52
53 // Query fields
54
55 static const field id;
56
57 operator filter() const
58 {
59 if (!valid_)
60 {
61 throw std::domain_error("Bad access to uninitialized group");
62 }
63
64 return (id == id_);
65 }
66
67 // Relationships to other objects
68
69 static const field frame;
70
71 static const field word;
72
73 private:
74 bool valid_ = false;
75
76 int id_;
77
78 const database* db_;
79
80 mutable bool initializedFrames_ = false;
81 mutable std::vector<class frame> frames_;
82
83 };
84
85};
86
87#endif /* end of include guard: GROUP_H_BD6933C0 */