Wt examples  4.10.4
Loading...
Searching...
No Matches
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
18namespace dbo = Wt::Dbo;
19
20class User;
21using AuthInfo = Wt::Auth::Dbo::AuthInfo<User>;
22using Users = dbo::collection<dbo::ptr<User>>;
23
24class User
25{
26public:
27 std::string name; /* a copy of auth info's user name */
28 int gamesPlayed = 0;
29 long long score = 0;
30 Wt::WDateTime lastGame;
31 dbo::weak_ptr<AuthInfo> authInfo;
32
33 template<class Action>
35 {
36 dbo::field(a, gamesPlayed, "gamesPlayed");
37 dbo::field(a, score, "score");
38 dbo::field(a, lastGame, "lastGame");
39 dbo::hasOne(a, authInfo, "user");
40 }
41};
42
44
45#endif // USER_H_
Wt::Auth::Dbo::UserDatabase< AuthInfo > UserDatabase
Definition Session.h:22
dbo::collection< dbo::ptr< User > > Users
Definition User.h:22
Wt::Auth::Dbo::AuthInfo< User > AuthInfo
Definition User.h:21
Definition User.h:25
std::string name
Definition User.h:27
dbo::weak_ptr< AuthInfo > authInfo
Definition User.h:31
long long score
Definition User.h:29
void persist(Action &a)
Definition User.h:34
Wt::WDateTime lastGame
Definition User.h:30
int gamesPlayed
Definition User.h:28