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