00001 /*************************************************************************** 00002 * Copyright (C) 2007 by Pierre Schmitt, Ludovic Giacomello, Nhi Ly * 00003 * * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License as published by * 00007 * the Free Software Foundation; either version 2 of the License, or * 00008 * (at your option) any later version. * 00009 * * 00010 * This program is distributed in the hope that it will be useful, * 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00013 * GNU General Public License for more details. * 00014 * * 00015 * You should have received a copy of the GNU General Public License * 00016 * along with this program; if not, write to the * 00017 * Free Software Foundation, Inc., * 00018 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00019 ***************************************************************************/ 00020 00021 00022 00023 #ifndef BDD_H 00024 #define BDD_H 00025 00026 #include <iostream> 00027 #include <cstdlib> 00028 #include <fstream> 00029 #include <sstream> 00030 00031 #include <pthread.h> 00032 00033 #include "TableauDyn.h" 00034 #include "Mutex.h" 00035 #include "Singleton.h" 00036 00040 struct UserInfo{ 00041 string login; 00042 string mdp; 00043 unsigned int score; 00044 }; 00045 00054 class BdD : public Singleton<BdD>{ 00055 friend class Singleton<BdD>; 00056 private: 00063 BdD(); 00064 00069 ~BdD(); 00070 00076 int Rechercher(string login); 00077 00081 void Charger(); 00082 public: 00089 int AjouterUtilisateur(string login, string mdp); 00090 00096 int SupprimerUtilisateur(string login); 00097 00104 bool EstUtilisateur(string login, string mdp); 00105 00111 int GetScore(string login); 00112 00119 int SetScore(string login, unsigned int score); 00120 00121 00126 string ListeScore(); 00127 00131 void Afficher(); 00132 00136 void Sauvegarder(); 00137 private: 00141 TableauDyn<UserInfo> mBdD; 00142 00146 Mutex mVerrou; 00147 }; 00148 00149 #endif