Wt examples  3.2.1
/home/koen/project/wt/public-git/wt/examples/hangman/User.h
Go to the documentation of this file.
00001 // This may look like C code, but it's really -*- C++ -*-
00002 /* 
00003  * Copyright (C) 2011 Emweb bvba, Heverlee, Belgium
00004  *
00005  * See the LICENSE file for terms of use.
00006  */
00007 
00008 #ifndef USER_H_
00009 #define USER_H_
00010 
00011 #include <Wt/WDateTime>
00012 #include <Wt/Dbo/Types>
00013 #include <Wt/Dbo/WtSqlTraits>
00014 #include <Wt/Auth/Dbo/AuthInfo>
00015 
00016 #include <string>
00017 
00018 class User;
00019 typedef Wt::Auth::Dbo::AuthInfo<User> AuthInfo;
00020 typedef Wt::Dbo::collection< Wt::Dbo::ptr<User> > Users;
00021 
00022 class User : public Wt::Dbo::Dbo<User>
00023 {
00024 public:
00025   User();
00026 
00027   std::string name; /* a copy of auth info's user name */
00028   int gamesPlayed;
00029   long long score;
00030   Wt::WDateTime lastGame;
00031   Wt::Dbo::collection< Wt::Dbo::ptr<AuthInfo> > authInfos;
00032 
00033   template<class Action>
00034   void persist(Action& a)
00035   {
00036     Wt::Dbo::field(a, gamesPlayed, "gamesPlayed");
00037     Wt::Dbo::field(a, score, "score");
00038     Wt::Dbo::field(a, lastGame, "lastGame");
00039 
00040     Wt::Dbo::hasMany(a, authInfos, Wt::Dbo::ManyToOne, "user");
00041   }
00042 };
00043 
00044 DBO_EXTERN_TEMPLATES(User);
00045 
00046 #endif // USER_H_

Generated on Fri Mar 30 2012 for the C++ Web Toolkit (Wt) by doxygen 1.7.5.1