diff options
| author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2017-01-23 11:49:51 -0500 |
|---|---|---|
| committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2017-01-23 11:49:51 -0500 |
| commit | 9bd863c9002b525b7827f9158d9136143393be5c (patch) | |
| tree | 6b210e9d55286c93a0f3ddd55d2b10d1efa88e99 /lib/group.h | |
| parent | 9e36dbbe74fd9541f0431b7715d3f97895384d28 (diff) | |
| download | verbly-9bd863c9002b525b7827f9158d9136143393be5c.tar.gz verbly-9bd863c9002b525b7827f9158d9136143393be5c.tar.bz2 verbly-9bd863c9002b525b7827f9158d9136143393be5c.zip | |
Added verb frame parsing
Diffstat (limited to 'lib/group.h')
| -rw-r--r-- | lib/group.h | 60 |
1 files changed, 32 insertions, 28 deletions
| diff --git a/lib/group.h b/lib/group.h index dd53503..fe62d39 100644 --- a/lib/group.h +++ b/lib/group.h | |||
| @@ -6,82 +6,86 @@ | |||
| 6 | #include <vector> | 6 | #include <vector> |
| 7 | #include "field.h" | 7 | #include "field.h" |
| 8 | #include "filter.h" | 8 | #include "filter.h" |
| 9 | #include "frame.h" | ||
| 10 | #include "role.h" | ||
| 9 | 11 | ||
| 10 | struct sqlite3_stmt; | 12 | struct sqlite3_stmt; |
| 11 | 13 | ||
| 12 | namespace verbly { | 14 | namespace verbly { |
| 13 | 15 | ||
| 14 | class database; | 16 | class database; |
| 15 | class frame; | 17 | |
| 16 | |||
| 17 | class group { | 18 | class group { |
| 18 | public: | 19 | public: |
| 19 | 20 | ||
| 20 | // Default constructor | 21 | // Default constructor |
| 21 | 22 | ||
| 22 | group() = default; | 23 | group() = default; |
| 23 | 24 | ||
| 24 | // Construct from database | 25 | // Construct from database |
| 25 | 26 | ||
| 26 | group(const database& db, sqlite3_stmt* row); | 27 | group(const database& db, sqlite3_stmt* row); |
| 27 | 28 | ||
| 28 | // Accessors | 29 | // Accessors |
| 29 | 30 | ||
| 30 | operator bool() const | 31 | operator bool() const |
| 31 | { | 32 | { |
| 32 | return valid_; | 33 | return valid_; |
| 33 | } | 34 | } |
| 34 | 35 | ||
| 35 | int getId() const | 36 | int getId() const |
| 36 | { | 37 | { |
| 37 | if (!valid_) | 38 | if (!valid_) |
| 38 | { | 39 | { |
| 39 | throw std::domain_error("Bad access to uninitialized group"); | 40 | throw std::domain_error("Bad access to uninitialized group"); |
| 40 | } | 41 | } |
| 41 | 42 | ||
| 42 | return id_; | 43 | return id_; |
| 43 | } | 44 | } |
| 44 | 45 | ||
| 45 | const std::vector<frame>& getFrames() const; | 46 | const std::vector<frame>& getFrames() const; |
| 46 | 47 | ||
| 48 | const role& getRole(std::string roleName) const; | ||
| 49 | |||
| 47 | // Type info | 50 | // Type info |
| 48 | 51 | ||
| 49 | static const object objectType; | 52 | static const object objectType; |
| 50 | 53 | ||
| 51 | static const std::list<std::string> select; | 54 | static const std::list<std::string> select; |
| 52 | 55 | ||
| 53 | // Query fields | 56 | // Query fields |
| 54 | 57 | ||
| 55 | static const field id; | 58 | static const field id; |
| 56 | 59 | ||
| 57 | operator filter() const | 60 | operator filter() const |
| 58 | { | 61 | { |
| 59 | if (!valid_) | 62 | if (!valid_) |
| 60 | { | 63 | { |
| 61 | throw std::domain_error("Bad access to uninitialized group"); | 64 | throw std::domain_error("Bad access to uninitialized group"); |
| 62 | } | 65 | } |
| 63 | 66 | ||
| 64 | return (id == id_); | 67 | return (id == id_); |
| 65 | } | 68 | } |
| 66 | 69 | ||
| 67 | // Relationships to other objects | 70 | // Relationships to other objects |
| 68 | 71 | ||
| 69 | static const field frame; | 72 | static const field frame; |
| 70 | 73 | ||
| 71 | static const field word; | 74 | static const field word; |
| 72 | 75 | ||
| 73 | private: | 76 | private: |
| 74 | bool valid_ = false; | 77 | bool valid_ = false; |
| 75 | 78 | ||
| 76 | int id_; | 79 | int id_; |
| 77 | 80 | std::map<std::string, role> roles_; | |
| 81 | |||
| 78 | const database* db_; | 82 | const database* db_; |
| 79 | 83 | ||
| 80 | mutable bool initializedFrames_ = false; | 84 | mutable bool initializedFrames_ = false; |
| 81 | mutable std::vector<class frame> frames_; | 85 | mutable std::vector<class frame> frames_; |
| 82 | 86 | ||
| 83 | }; | 87 | }; |
| 84 | 88 | ||
| 85 | }; | 89 | }; |
| 86 | 90 | ||
| 87 | #endif /* end of include guard: GROUP_H_BD6933C0 */ | 91 | #endif /* end of include guard: GROUP_H_BD6933C0 */ |
