/home/koen/project/wt/cvs/wt/examples/hangman/HangmanDb.h

Go to the documentation of this file.
00001 #ifndef DB_H_
00002 #define DB_H_
00003 
00004 #include <string>
00005 #include <vector>
00006 
00007 class HangmanDb
00008 {
00009 public:
00010   // this function returns false if user existed, true if user inserted
00011   // It guarantees atomic userExists() checking and adding it if the user
00012   // did not yet exits.
00013   static bool addUser(const std::wstring &user, const std::wstring &password);
00014 
00015   // This function returns true when the credentials are found in the
00016   // database, otherwise false
00017   static bool validLogin(const std::wstring &user, const std::wstring &pass);
00018 
00019   // Increments the number of games played, and adds delta to the score
00020   static void addToScore(const std::wstring &user, int delta);
00021 
00022   struct Score {
00023     int number; // position of the user
00024     std::wstring user;
00025     int numgames;
00026     int score;
00027     std::wstring lastseen; // Last seen, in GMT
00028   };
00029 
00030   // Returns the top n highest scoring users
00031   static std::vector<Score> getHighScores(int top);
00032 
00033   // Returns the score structure for the given user
00034   static Score getUserPosition(const std::wstring &user);
00035 
00036 private:
00037   static std::string DbUser();
00038   static std::string DbPass();
00039 };
00040 
00041 #endif

Generated on Fri Jul 25 17:05:59 2008 for Wt by doxygen 1.5.3