GnuCashew ~ GnuCash Enabled Web
GCW
Item.h
Go to the documentation of this file.
1 #line 2 "src/Dbo/Versions/Item.h"
2 
3 #ifndef __DBO_VERSIONS_ITEM_H___
4 #define __DBO_VERSIONS_ITEM_H___
5 
6 #include "../BaseItem.h"
7 #include "Definition.h"
8 
9 /*
10 ** Predefine the class that fixin to come up.
11 **
12 */
13 namespace GCW {
14  namespace Dbo {
15  namespace Versions {
16  class Item;
17  }
18  }
19 }
20 
21 /*
22 ** Define these dbo_traits to prevent the system from
23 ** automatically generating an ID field or a VERSION
24 ** field, and instead substitute the guid field
25 ** as the primary key.
26 **
27 */
28 template<> struct Wt::Dbo::dbo_traits< GCW::Dbo::Versions::Item >
29 : public Wt::Dbo::dbo_default_traits
30 {
31  using IdType = std::string;
32  static auto invalidId()-> IdType { return std::string(); }
33  static auto surrogateIdField()-> const char * { return nullptr; }
34  static auto versionField()-> const char * { return nullptr; }
35 };
36 
37 template<> struct Wt::Dbo::dbo_traits< const GCW::Dbo::Versions::Item > : Wt::Dbo::dbo_traits< GCW::Dbo::Versions::Item > {};
38 
39 /*
40 ** Now we can start building our class!
41 **
42 */
43 namespace GCW {
44  namespace Dbo {
45  namespace Versions {
46 
47 /*!
48 ** \brief Versions Class
49 **
50 **
51 ** \dot
52 ** digraph VersionsMap
53 ** {
54 ** VersionsItem;
55 ** }
56 ** \enddot
57 **
58 ** \par Native GnuCash Invoice Sqlite Schema
59 ** \code
60 ** CREATE TABLE versions
61 ** (
62 ** table_name text(50) PRIMARY KEY NOT NULL,
63 ** table_version integer NOT NULL
64 ** );
65 ** \endcode
66 **
67 */
68 class Item
69 : public GCW::Dbo::BaseItem< Item >
70 {
71  public:
72 
73  /*!
74  ** \brief ctor
75  */
76  Item(){}
77 
78  /*!
79  ** \brief ctor with guid
80  */
81  Item( const std::string & _table_name ): m_table_name( _table_name ){}
82 
83  template< class Action > auto
84  persist( Action & action )-> void
85  {
88 
89  } // endpersist( Action & action )-> void
90 
91  private:
92 
93  std::string m_table_name ; // text(50) PRIMARY KEY NOT NULL,
94  int m_table_version ; // integer NOT NULL
95 
96 }; // endclass Item
97 
98  } // endnamespace Versions {
99  } // endnamespace Dbo {
100 } // endnamespace GCW {
101 
102 #endif // __DBO_VERSIONS_ITEM_H___
103 
Versions Class.
Definition: Item.h:70
auto persist(Action &action) -> void
Definition: Item.h:84
std::string m_table_name
Definition: Item.h:93
Item(const std::string &_table_name)
ctor with guid
Definition: Item.h:81
const Wt::WFormModel::Field action
Definition: Entries.cpp:14
const Wt::WFormModel::Field id
Definition: Definition.h:17
const Wt::WFormModel::Field table_name
Definition: Versions.cpp:10
const Wt::WFormModel::Field table_version
Definition: Versions.cpp:11
Definition: App.h:17
static auto versionField() -> const char *
Definition: Item.h:34
static auto invalidId() -> IdType
Definition: Item.h:32
static auto surrogateIdField() -> const char *
Definition: Item.h:33