Wt examples  3.7.1
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 bv, Herent, 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>
12 #include <Wt/Dbo/Types>
13 #include <Wt/Dbo/WtSqlTraits>
14 #include <Wt/Auth/Dbo/AuthInfo>
15 
16 #include <string>
17 
18 class User;
21 
22 class User
23 {
24 public:
25  User();
26 
27  std::string name; /* a copy of auth info's user name */
29  long long score;
32 
33  template<class Action>
34  void persist(Action& a)
35  {
36  Wt::Dbo::field(a, gamesPlayed, "gamesPlayed");
37  Wt::Dbo::field(a, score, "score");
38  Wt::Dbo::field(a, lastGame, "lastGame");
39 
40  Wt::Dbo::hasMany(a, authInfos, Wt::Dbo::ManyToOne, "user");
41  }
42 };
43 
45 
46 #endif // USER_H_
Wt::WDateTime lastGame
Definition: User.h:30
User()
Definition: User.C:17
DBO_EXTERN_TEMPLATES(User)
Definition: User.h:22
int gamesPlayed
Definition: User.h:28
long long score
Definition: User.h:29
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())
Wt::Auth::Dbo::AuthInfo< User > AuthInfo
Definition: User.h:18
Wt::Dbo::collection< Wt::Dbo::ptr< AuthInfo > > authInfos
Definition: User.h:31
std::string name
Definition: User.h:27
void persist(Action &a)
Definition: User.h:34
Wt::Dbo::collection< Wt::Dbo::ptr< User > > Users
Definition: User.h:20

Generated on Tue Dec 15 2020 for the C++ Web Toolkit (Wt) by doxygen 1.8.13