GnuCashew ~ GnuCash Enabled Web
GCW
Template.h
Go to the documentation of this file.
1 #line 2 "src/Dbo/GncLock/Template.h"
2 
3 #ifndef __DBO_GNCLOCK_TEMPLATE_H___
4 #define __DBO_GNCLOCK_TEMPLATE_H___
5 
6 #include <string>
7 
8 #include <Wt/Dbo/Dbo.h>
9 
10 #include "../BaseItem.h"
11 #include "Definition.h"
12 
13 /*
14 ** Predefine the GncLock class that fixin to come up.
15 **
16 */
17 namespace GCW {
18  namespace Dbo {
19  namespace GncLock {
20  class Item;
21  }
22  }
23 }
24 
25 /*
26 ** Define these dbo_traits to prevent the system from
27 ** automatically generating an ID field or a VERSION
28 ** field, and instead substitute the guid field
29 ** as the primary key.
30 **
31 */
32 template<> struct Wt::Dbo::dbo_traits< GCW::Dbo::GncLock::Item >
33 : public Wt::Dbo::dbo_default_traits
34 {
35  using IdType = std::string;
36  static auto invalidId()-> IdType { return std::string(); }
37  static auto surrogateIdField()-> const char * { return "Hostname"; }
38  static auto versionField()-> const char * { return nullptr; }
39 };
40 
41 template<> struct Wt::Dbo::dbo_traits< const GCW::Dbo::GncLock::Item > : Wt::Dbo::dbo_traits< GCW::Dbo::GncLock::Item > {};
42 
43 /*
44 ** Now we can start building our class!
45 **
46 */
47 namespace GCW {
48  namespace Dbo {
49  namespace GncLock {
50 
51 template <class C>
52 class Template
53 : public GCW::Dbo::BaseItem<C>
54 {
55  public:
56 
58 
59  template<class Action>
60  void persist( Action & a )
61  {
62 // Wt::Dbo::field( a, m_hostname , GCW::Dbo::GncLock::FieldDef::hostname );
63  Wt::Dbo::field( a, m_pid , GCW::Dbo::GncLock::FieldDef::pid );
64 
65  } // endvoid persist( Action & a )
66 
67  std::string m_hostname ;
68  int m_pid = -1 ;
69 
70 }; // endclass Template
71 
72  } // endnamespace GncLock {
73  } // endnamespace Dbo {
74 } // endnamespace Swims {
75 
76 #endif // #ifndef __DBO_GNCLOCK_TEMPLATE_H___
77 
78 
void persist(Action &a)
Definition: Template.h:60
const Wt::WFormModel::Field pid
Definition: GncLock.cpp:8
Definition: App.h:17
static auto surrogateIdField() -> const char *
Definition: Template.h:37
static auto versionField() -> const char *
Definition: Template.h:38