eliot-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Eliot-dev] Changes to eliot/game/game_factory.h [antoine-1]


From: eliot-dev
Subject: [Eliot-dev] Changes to eliot/game/game_factory.h [antoine-1]
Date: Sun, 23 Oct 2005 13:16:33 -0400

Index: eliot/game/game_factory.h
diff -u /dev/null eliot/game/game_factory.h:1.5.2.1
--- /dev/null   Sun Oct 23 17:16:33 2005
+++ eliot/game/game_factory.h   Sun Oct 23 17:16:24 2005
@@ -0,0 +1,96 @@
+/*****************************************************************************
+ * Copyright (C) 2005 Eliot
+ * Authors: Olivier Teuliere  <address@hidden>
+ *
+ * $Id: game_factory.h,v 1.5.2.1 2005/10/23 17:16:24 afrab Exp $
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *****************************************************************************/
+
+#ifndef _GAME_FACTORY_H_
+#define _GAME_FACTORY_H_
+
+#include "game.h"
+#include "training.h"
+#include "freegame.h"
+#include "duplicate.h"
+
+
+/**
+ * This class is the entry point to create Game objects, either directly or
+ * using command-line parameters. It also offers a method to destroy Game
+ * objects.
+ * This class implements the Singleton pattern.
+ */
+class GameFactory
+{
+public:
+    static GameFactory *Instance();
+    static void Destroy();
+
+    /*************************
+     * Functions to create and destroy a game
+     * The dictionary does not belong to the
+     * game (ie: it won't be destroyed by ~Game)
+     *************************/
+    Training  *createTraining (const Dictionary  iDic);
+    FreeGame  *createFreeGame (const Dictionary  iDic);
+    Duplicate *createDuplicate(const Dictionary iDic);
+
+    Game *createFromCmdLine(int argc, char **argv);
+
+    /// Destroy a Game object, created by any of the createXXX methods above
+    void releaseGame(Game &iGame);
+
+private:
+
+    GameFactory();
+    virtual ~GameFactory();
+
+    /// The unique instance of the class
+    static GameFactory *m_factory;
+
+    /// Initial dictionary (it could be changed later)
+    Dictionary m_dic;
+
+    /** Parameters specified on the command-line */
+    //@{
+
+    /// Dictionary
+    std::string m_dicStr;
+
+    /// Game mode
+    std::string m_modeStr;
+
+    /// Number of human players
+    int m_human;
+
+    /// Number of AI players
+    int m_ai;
+
+    /// Variant of the game
+    bool m_joker;
+
+    //@}
+
+    /// Print command-line usage
+    void printUsage(const std::string &iBinaryName) const;
+
+    /// Print version
+    void printVersion() const;
+
+};
+
+#endif // _GAME_FACTORY_H_




reply via email to

[Prev in Thread] Current Thread [Next in Thread]