game_factory.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * Copyright (C) 2005 Eliot
00003  * Authors: Olivier Teuliere  <ipkiss@via.ecp.fr>
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 Free Software
00017  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018  *****************************************************************************/
00019 
00020 #ifndef _GAME_FACTORY_H_
00021 #define _GAME_FACTORY_H_
00022 
00023 #include "game.h"
00024 #include "training.h"
00025 #include "freegame.h"
00026 #include "duplicate.h"
00027 
00028 
00029 /**
00030  * This class is the entry point to create Game objects, either directly or
00031  * using command-line parameters. It also offers a method to destroy Game
00032  * objects.
00033  * This class implements the Singleton pattern.
00034  */
00035 class GameFactory
00036 {
00037 public:
00038     static GameFactory *Instance();
00039     static void Destroy();
00040 
00041     /*************************
00042      * Functions to create and destroy a game
00043      * The dictionary does not belong to the
00044      * game (ie: it won't be destroyed by ~Game)
00045      *************************/
00046     Training *createTraining(const Dictionary &iDic);
00047     FreeGame *createFreeGame(const Dictionary &iDic);
00048     Duplicate *createDuplicate(const Dictionary &iDic);
00049     //Game *loadGame(FILE *fin, const Dictionary &iDic);
00050 
00051     Game *createFromCmdLine(int argc, char **argv);
00052 
00053     /// Destroy a Game object, created by any of the createXXX methods above
00054     void releaseGame(Game &iGame);
00055 
00056 private:
00057 
00058     GameFactory();
00059     virtual ~GameFactory();
00060 
00061     /// The unique instance of the class
00062     static GameFactory *m_factory;
00063 
00064     /// Initial dictionary (it could be changed later)
00065     Dictionary m_dic;
00066 
00067     /** Parameters specified on the command-line */
00068     //@{
00069 
00070     /// Dictionary
00071     string m_dicStr;
00072 
00073     /// Game mode
00074     string m_modeStr;
00075 
00076     /// Number of human players
00077     int m_human;
00078 
00079     /// Number of AI players
00080     int m_ai;
00081 
00082     /// Variant of the game
00083     bool m_joker;
00084 
00085     //@}
00086 
00087     /// Print command-line usage
00088     void printUsage(const string &iBinaryName) const;
00089 
00090     /// Print version
00091     void printVersion() const;
00092 
00093 };
00094 
00095 #endif // _GAME_FACTORY_H_
00096 
00097 /// Local Variables:
00098 /// mode: c++
00099 /// mode: hs-minor
00100 /// c-basic-offset: 4
00101 /// indent-tabs-mode: nil
00102 /// End:

Generated on Thu Dec 29 02:01:14 2005 for Eliot by  doxygen 1.4.5