Wt examples 4.5.2
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.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
18using namespace Wt;
19
20namespace dbo = Wt::Dbo;
21
22class User;
23typedef Auth::Dbo::AuthInfo<User> AuthInfo;
24typedef dbo::collection< dbo::ptr<User> > Users;
25
26class User
27{
28public:
29 User();
30
31 std::string name; /* a copy of auth info's user name */
33 long long score;
34 WDateTime lastGame;
35 dbo::collection<dbo::ptr<AuthInfo>> authInfos;
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_
dbo::collection< dbo::ptr< User > > Users
Definition: User.h:24
Auth::Dbo::AuthInfo< User > AuthInfo
Definition: User.h:22
DBO_EXTERN_TEMPLATES(User)
Definition: User.h:27
std::string name
Definition: User.h:31
long long score
Definition: User.h:33
User()
Definition: User.C:16
WDateTime lastGame
Definition: User.h:34
void persist(Action &a)
Definition: User.h:38
int gamesPlayed
Definition: User.h:32
dbo::collection< dbo::ptr< AuthInfo > > authInfos
Definition: User.h:35

Generated on Wed Jan 12 2022 for the C++ Web Toolkit (Wt) by doxygen 1.9.3