Wt examples
4.2.2
builddir
build
BUILD
wt-4.2.2
examples
hangman
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
18
using namespace
Wt
;
19
20
namespace
dbo
=
Wt::Dbo
;
21
22
class
User
;
23
typedef
Auth::Dbo::AuthInfo<User>
AuthInfo
;
24
typedef
dbo::collection< dbo::ptr<User>
>
Users
;
25
26
class
User
27
{
28
public
:
29
User
();
30
31
std::string
name
;
/* a copy of auth info's user name */
32
int
gamesPlayed
;
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
48
DBO_EXTERN_TEMPLATES
(
User
);
49
50
#endif // USER_H_
Wt::Dbo
User::authInfos
dbo::collection< dbo::ptr< AuthInfo > > authInfos
Definition:
User.h:35
Wt::WDateTime
User::lastGame
WDateTime lastGame
Definition:
User.h:34
Users
dbo::collection< dbo::ptr< User > > Users
Definition:
User.h:24
DBO_EXTERN_TEMPLATES
DBO_EXTERN_TEMPLATES(User)
Wt
User::score
long long score
Definition:
User.h:33
User::gamesPlayed
int gamesPlayed
Definition:
User.h:32
Wt::Auth::Dbo::AuthInfo
Wt::Dbo::field
void field(Action &action, V &value, const std::string &name, int size=-1)
Wt::Dbo::collection
User::name
std::string name
Definition:
User.h:31
User::persist
void persist(Action &a)
Definition:
User.h:38
ManyToOne
ManyToOne
AuthInfo
Auth::Dbo::AuthInfo< User > AuthInfo
Definition:
User.h:22
Wt::Dbo::hasMany
void hasMany(Action &action, collection< ptr< C > > &value, RelationType type, const std::string &name=std::string())
User
Definition:
User.h:26
Generated on Fri Mar 20 2020 for
the C++ Web Toolkit (Wt)
by
1.8.17