Virtual Testbed
Ship dynamics simulator for extreme conditions
db/entity.hh
1 #ifndef VTESTBED_DB_ENTITY_HH
2 #define VTESTBED_DB_ENTITY_HH
3 
4 #include <string>
5 
6 #include <sqlitex/forward.hh>
7 #include <sqlitex/blob.hh>
8 
9 namespace vtb {
10 
11  namespace db {
12 
13  class Entity {
14 
15  public:
16  typedef int64_t id_type;
17  typedef std::string string_type;
18  typedef const std::string& string_reference;
19 
20  protected:
21  id_type _id = 0;
22  std::string _name;
23  std::string _description;
24  std::string _filename;
25  sqlite::blob _filecontent;
26 
27  public:
28 
29  inline id_type id() const { return this->_id; }
30  inline void id(id_type rhs) { this->_id = rhs; }
31  inline bool has_id() const { return this->_id != 0; }
32  inline const std::string& name() const { return this->_name; }
33  inline std::string& name() { return this->_name; }
34  inline void name(const std::string& rhs) { this->_name = rhs; }
35 
36  inline string_reference
37  description() const {
38  return this->_description;
39  }
40 
41  inline void
42  description(string_reference& rhs) {
43  this->_description = rhs;
44  }
45 
46  inline string_reference
47  filename() const {
48  return this->_filename;
49  }
50 
51  inline const sqlite::blob&
52  file_content() const {
53  return this->_filecontent;
54  }
55 
56  inline void
57  clear() {
58  this->_id = 0;
59  this->_name.clear();
60  this->_description.clear();
61  this->_filename.clear();
62  this->_filecontent.clear();
63  }
64 
65  void export_original(std::string filename) const;
66 
67  protected:
68 
69  std::string temporary_filename() const;
70 
71  };
72 
73  }
74 
75 }
76 
77 #endif // vim:filetype=cpp
Main namespace.
Definition: convert.hh:9