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 SESSION_H_ 00009 #define SESSION_H_ 00010 00011 #include <vector> 00012 00013 #include <Wt/Dbo/Dbo> 00014 #include <Wt/Dbo/backend/Sqlite3> 00015 00016 #include "User.h" 00017 #include "Dictionary.h" 00018 00019 class Session 00020 { 00021 public: 00022 Session(); 00023 00024 const User* user() { 00025 if (user_) 00026 return &(*user_); 00027 else 00028 return 0; 00029 } 00030 00031 Dictionary& dictionary() { return dictionary_; } 00032 void setDictionary(const Dictionary& d) { dictionary_ = d;} 00033 00034 bool login(std::string name, std::string password); 00035 std::vector<User> topUsers(int limit); 00036 int findRanking(const User* user); 00037 void addToScore(int s); 00038 00039 private: 00040 Wt::Dbo::backend::Sqlite3 sqlite3_; 00041 00042 Wt::Dbo::Session session_; 00043 Wt::Dbo::ptr<User> user_; 00044 Dictionary dictionary_; 00045 }; 00046 00047 #endif //SESSION_H_
1.7.2