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 PARTIE_H 00024 #define PARTIE_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" 00040 struct PartieInfo{ 00041 unsigned int id; //identifiant 00042 string loginP; 00043 string loginF[3]; 00044 int scoreP; 00045 int scoreF[3]; 00046 int nbFantomeAuto; 00047 }; 00048 00054 class Partie : public Singleton<Partie>{ 00055 friend class Singleton<Partie>; 00056 private: 00057 Partie(){} 00058 ~Partie(){} 00059 public: 00065 int Rechercher(unsigned int id); 00066 00072 int AjouterPartie(unsigned int id); 00073 int AjouterPartie(const PartieInfo &p); 00079 int SupprimerPartie(unsigned int id); 00080 void Afficher(); 00081 void Afficher(unsigned int id); 00082 00088 string ToString(); 00089 int GetScorePacman(unsigned int id); 00090 int SetScorePacman(unsigned int id, unsigned int score); 00091 int GetScoreF(unsigned int id, unsigned int idFantome); 00092 int SetScoreF(unsigned int id, unsigned int idFantome, unsigned int score); 00093 string GetLoginPacman(unsigned int id); 00094 int SetLoginPacman(unsigned int id, string login); 00095 string GetLoginF(unsigned int id, unsigned int idFantome); 00096 int SetLoginF(unsigned int id, unsigned int idFantome, string login); 00097 int GetNbFantomeAuto(unsigned int id); 00098 int SetNbFantomeAuto(unsigned int id, unsigned int nbFantomeAuto); 00099 private: 00103 TableauDyn<PartieInfo> mPartie; 00104 00108 Mutex mVerrou; 00109 }; 00110 00111 #endif