Wt examples  4.12.2
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;
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;
32
33 template<class Action>
34 void persist(Action& a)
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
43DBO_EXTERN_TEMPLATES(User)
44
45#endif // USER_H_
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
void hasOne(Action &action, weak_ptr< C > &value, const std::string &name=std::string())
void field(Action &action, V &value, const std::string &name, int size=-1)