Wt examples  4.0.0
User.h
Go to the documentation of this file.
1 // This may look like C code, but it's really -*- C++ -*-
2 /*
3  * Copyright (C) 2011 Emweb bvba, Heverlee, Belgium
4  *
5  * See the LICENSE file for terms of use.
6  */
7 
8 #ifndef USER_H_
9 #define USER_H_
10 
11 #include <Wt/WDateTime.h>
12 #include <Wt/Dbo/Types.h>
13 #include <Wt/Dbo/WtSqlTraits.h>
14 #include <Wt/Auth/Dbo/AuthInfo.h>
15 
16 #include <string>
17 
18 using namespace Wt;
19 
20 namespace dbo = Wt::Dbo;
21 
22 class User;
25 
26 class User
27 {
28 public:
29  User();
30 
31  std::string name; /* a copy of auth info's user name */
33  long long score;
36 
37  template<class Action>
38  void persist(Action& a)
39  {
40  dbo::field(a, gamesPlayed, "gamesPlayed");
41  dbo::field(a, score, "score");
42  dbo::field(a, lastGame, "lastGame");
43 
44  dbo::hasMany(a, authInfos, dbo::ManyToOne, "user");
45  }
46 };
47 
49 
50 #endif // USER_H_
Auth::Dbo::AuthInfo< User > AuthInfo
Definition: User.h:22
dbo::collection< dbo::ptr< User > > Users
Definition: User.h:24
DBO_EXTERN_TEMPLATES(User)
Definition: User.h:26
int gamesPlayed
Definition: User.h:32
dbo::collection< dbo::ptr< AuthInfo > > authInfos
Definition: User.h:35
long long score
Definition: User.h:33
WDateTime lastGame
Definition: User.h:34
void field(Action &action, V &value, const std::string &name, int size=-1)
void hasMany(Action &action, collection< ptr< C > > &value, RelationType type, const std::string &name=std::string())
std::string name
Definition: User.h:31
ManyToOne
void persist(Action &a)
Definition: User.h:38

Generated on Mon Sep 4 2017 for the C++ Web Toolkit (Wt) by doxygen 1.8.11