Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 9, 2011, 5:06:49 AM (13 years ago)
Author:
rgrieder
Message:

Added and incorporated new class DestructionHelper: instead of doing the destruction of certain singletons implicitly via scoped_ptrs and ScopeGuards, use a method named destroy() that essentially achieves the same, but makes the destruction sequence obvious.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/libraries/core/Game.h

    r8418 r8423  
    4545#include <vector>
    4646#include <boost/shared_ptr.hpp>
    47 #include <boost/scoped_ptr.hpp>
    4847#include <boost/preprocessor/cat.hpp>
    49 #include <loki/ScopeGuard.h>
    5048
    5149#include "util/Debug.h"
     50#include "util/DestructionHelper.h"
    5251#include "util/Singleton.h"
    5352#include "OrxonoxClass.h"
     
    5655@brief
    5756    Adds a new GameState to the Game. The second parameter is the name as string
    58     and every following paramter is a constructor argument (which is usually non existent)
     57    and every following parameter is a constructor argument (which is usually non existent)
    5958*/
    6059#define DeclareGameState(className, stateName, bIgnoreTickTime, bGraphicsMode) \
     
    9291    public:
    9392        Game(const std::string& cmdLine);
    94         ~Game();
     93
     94        //! Leave empty and use cleanup() instead
     95        ~Game() {}
     96        /// Destructor that also executes when object fails to construct
     97        void destroy();
    9598
    9699        void setConfigValues();
     
    138141                { return shared_ptr<GameState>(new T(info)); }
    139142        };
    140         // For the factory destruction
    141         typedef Loki::ObjScopeGuardImpl0<std::map<std::string, shared_ptr<GameStateFactory> >, void (std::map<std::string, shared_ptr<GameStateFactory> >::*)()> ObjScopeGuard;
    142143
    143144        struct StatisticsTickInfo
     
    166167        void resetChangingState() { this->bChangingState_ = false; }
    167168
    168         scoped_ptr<Clock>                  gameClock_;
    169         scoped_ptr<Core>                   core_;
    170         ObjScopeGuard                      gsFactoryDestroyer_;
     169        Clock*                             gameClock_;
     170        Core*                              core_;
    171171
    172172        GameStateMap                       constructedStates_;
     
    194194        unsigned int                       fpsLimit_;
    195195
     196        /// Helper object that executes the surrogate destructor destroy()
     197        DestructionHelper<Game>            destructionHelper_;
     198
    196199        static std::map<std::string, GameStateInfo> gameStateDeclarations_s;
    197200        static Game* singletonPtr_s;        //!< Pointer to the Singleton
Note: See TracChangeset for help on using the changeset viewer.