|
From: <sik...@us...> - 2006-05-25 23:29:19
|
Revision: 72 Author: sik0fewl Date: 2006-05-25 16:29:12 -0700 (Thu, 25 May 2006) ViewCVS: http://svn.sourceforge.net/perceptioncrash/?rev=72&view=rev Log Message: ----------- Some docs Modified Paths: -------------- trunk/perceptioncrash/src/Factory.hpp trunk/perceptioncrash/src/GameManager.hpp trunk/perceptioncrash/src/KeyboardMouseInputController.hpp Modified: trunk/perceptioncrash/src/Factory.hpp =================================================================== --- trunk/perceptioncrash/src/Factory.hpp 2006-05-25 23:13:54 UTC (rev 71) +++ trunk/perceptioncrash/src/Factory.hpp 2006-05-25 23:29:12 UTC (rev 72) @@ -7,6 +7,11 @@ #include "tinyxml/tinyxml.h" +/** + * Factory class + * + * Use Factory<T>::factory() to get an instance of Factory for type T + */ template <typename T> class Factory { @@ -22,18 +27,37 @@ CreatorXmlMap creatorsXml; public: + /** + * Return instance of Factory + */ static Factory<T>& factory() { static Factory<T> factory_; return factory_; } + /** + * Register a new object factory type. + * + * The RegisterFatory class provides a simple interface to this function + * + * @param id type name + * @param creator function to create object of type 'id' + * @param creatorXml function to create object of tyoe 'id' from an XML DOM node + * + * @see RegisterFactory + */ void register_(std::string const &id, CreatorFuncPtr creator, CreatorFuncXmlPtr creatorXml) { creators.insert(std::make_pair(id, creator)); creatorsXml.insert(std::make_pair(id, creatorXml)); } - + + /** + * Create new object + * + * @param id object type + */ T* create(std::string const &id) { typename CreatorMap::iterator i = creators.find(id); @@ -44,6 +68,11 @@ throw std::runtime_error("Factory for '" + id + "' does not exist"); } + /** + * Create new object from XML DOM node + * + * @param node XML DOM node. The type is specified in the 'type' XML attribute + */ T* create(TiXmlElement* node) { typename CreatorXmlMap::iterator i = creatorsXml.find(node->Attribute("type")); @@ -59,21 +88,38 @@ } }; +/** + * Convenience class for registering new factories + * + * Example usage: + * RegisterFactory<Base, Implementation> ImplementationFactory("Implementation"); + */ template <typename T, typename U> struct RegisterFactory { typedef Factory<T> FactoryType; + /** + * Create a new object + */ static T* newCreator() { return new U; } + /** + * Create a new object + */ static T* newCreator(TiXmlElement* node) { return new U(node); } + /** + * Constructor + * + * @param id object factory type + */ RegisterFactory(std::string const &id) { FactoryType::factory().register_(id, Modified: trunk/perceptioncrash/src/GameManager.hpp =================================================================== --- trunk/perceptioncrash/src/GameManager.hpp 2006-05-25 23:13:54 UTC (rev 71) +++ trunk/perceptioncrash/src/GameManager.hpp 2006-05-25 23:29:12 UTC (rev 72) @@ -18,21 +18,25 @@ public Ogre::Singleton<GameManager> { public: - /** Default constructor + /** + * Default constructor */ GameManager(); - /** Default destructor + /** + * Default destructor */ ~GameManager(); - /** Start game from specified game state + /** + * Start game from specified game state * * @param state game state to start from */ void start(GameState* state); - /** Change state to the specified state. + /** + * Change state to the specified state. * * This exits the current state, pops it, pushes the new state and enters * it @@ -41,7 +45,8 @@ */ void changeState(GameState* state); - /** Push new state onto state stack + /** + * Push new state onto state stack * * This pauses the current state, pushes the new state onto the game state * stack and enters it @@ -50,7 +55,8 @@ */ void pushState(GameState* state); - /** Pop current state off of state stack + /** + * Pop current state off of state stack * * This exits the current state, pops it off the state stack and resumes * the previous state (if any) @@ -58,7 +64,8 @@ void popState(); - /** Override standard Ogre::Singleton retrieval. + /** + * Override standard Ogre::Singleton retrieval. * * @remarks * @@ -75,7 +82,8 @@ */ static GameManager& getSingleton(void); - /** Override standard Ogre::Singleton retrieval. + /** + * Override standard Ogre::Singleton retrieval. * * @remarks * @@ -130,7 +138,8 @@ /** Update debug panel overlay with current FPS, etc */ void updateDebugPanelOverlay(); - /** Debug panel overlay. + /** + * Debug panel overlay. * Shows current FPS another stats on-screen */ Ogre::Overlay* mDebugPanelOverlay; Modified: trunk/perceptioncrash/src/KeyboardMouseInputController.hpp =================================================================== --- trunk/perceptioncrash/src/KeyboardMouseInputController.hpp 2006-05-25 23:13:54 UTC (rev 71) +++ trunk/perceptioncrash/src/KeyboardMouseInputController.hpp 2006-05-25 23:29:12 UTC (rev 72) @@ -17,7 +17,15 @@ public Ogre::MouseMotionListener { public: + /** + * Default constructor + */ KeyboardMouseInputController(); + /** + * Constructor + * + * Creates controller based on XML DOM node + */ KeyboardMouseInputController(TiXmlElement* node); ~KeyboardMouseInputController(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |