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/Core.h

    r8366 r8423  
    4545
    4646#include <string>
    47 #include <boost/scoped_ptr.hpp>
    4847#include <loki/ScopeGuard.h>
    4948
     49#include "util/DestructionHelper.h"
    5050#include "util/Singleton.h"
    5151#include "OrxonoxClass.h"
     
    6161    class _CoreExport Core : public Singleton<Core>, public OrxonoxClass
    6262    {
    63         typedef Loki::ScopeGuardImpl0<void (*)()> SimpleScopeGuard;
    6463        friend class Singleton<Core>;
    6564        friend class Game;
     
    7473            */
    7574            Core(const std::string& cmdLine);
    76             ~Core();
     75
     76            /// Leave empty and use destroy() instead
     77            ~Core() {}
     78            /// Destructor that also executes when the object fails to construct
     79            void destroy();
    7780
    7881            void setConfigValues();
     
    108111
    109112            void setThreadAffinity(int limitToCPU);
    110             // MANAGED SINGLETONS/OBJECTS
    111             // Mind the order for the destruction!
    112             scoped_ptr<PathConfig>        pathConfig_;
    113             scoped_ptr<DynLibManager>     dynLibManager_;
    114             scoped_ptr<SignalHandler>     signalHandler_;
    115             SimpleScopeGuard              identifierDestroyer_;
    116             SimpleScopeGuard              consoleCommandDestroyer_;
    117             scoped_ptr<ConfigFileManager> configFileManager_;
    118             scoped_ptr<Language>          languageInstance_;
    119             scoped_ptr<IOConsole>         ioConsole_;
    120             scoped_ptr<TclBind>           tclBind_;
    121             scoped_ptr<TclThreadManager>  tclThreadManager_;
    122             scoped_ptr<Scope<ScopeID::Root> > rootScope_;
     113
     114            PathConfig*               pathConfig_;
     115            DynLibManager*            dynLibManager_;
     116            SignalHandler*            signalHandler_;
     117            ConfigFileManager*        configFileManager_;
     118            Language*                 languageInstance_;
     119            IOConsole*                ioConsole_;
     120            TclBind*                  tclBind_;
     121            TclThreadManager*         tclThreadManager_;
     122            Scope<ScopeID::Root>*     rootScope_;
    123123            // graphical
    124             scoped_ptr<GraphicsManager>   graphicsManager_;     //!< Interface to OGRE
    125             scoped_ptr<InputManager>      inputManager_;        //!< Interface to OIS
    126             scoped_ptr<GUIManager>        guiManager_;          //!< Interface to GUI
    127             scoped_ptr<Scope<ScopeID::Graphics> > graphicsScope_;
     124            GraphicsManager*          graphicsManager_;            //!< Interface to OGRE
     125            InputManager*             inputManager_;               //!< Interface to OIS
     126            GUIManager*               guiManager_;                 //!< Interface to GUI
     127            Scope<ScopeID::Graphics>* graphicsScope_;
    128128
    129             bool                          bGraphicsLoaded_;
    130             int                           softDebugLevelLogFile_;      //!< The debug level for the log file (belongs to OutputHandler)
    131             std::string                   language_;                   //!< The language
    132             bool                          bInitRandomNumberGenerator_; //!< If true, srand(time(0)) is called
    133             bool                          bStartIOConsole_;            //!< Set to false if you don't want to use the IOConsole
    134             long long                     lastLevelTimestamp_;         ///< Timestamp when the last level was started
    135             long long                     ogreConfigTimestamp_;        ///< Timestamp wehen the ogre config level was modified
    136             bool                          bDevMode_;                   //!< Developers bit. If set to false, some options are not available as to not confuse the normal user.
     129            bool                      bGraphicsLoaded_;
     130            int                       softDebugLevelLogFile_;      //!< The debug level for the log file (belongs to OutputHandler)
     131            std::string               language_;                   //!< The language
     132            bool                      bInitRandomNumberGenerator_; //!< If true, srand(time(0)) is called
     133            bool                      bStartIOConsole_;            //!< Set to false if you don't want to use the IOConsole
     134            long long                 lastLevelTimestamp_;         ///< Timestamp when the last level was started
     135            long long                 ogreConfigTimestamp_;        ///< Timestamp wehen the ogre config level was modified
     136            bool                      bDevMode_;                   //!< Developers bit. If set to false, some options are not available as to not confuse the normal user.
    137137
    138             static Core*                  singletonPtr_s;
     138            /// Helper object that executes the surrogate destructor destroy()
     139            DestructionHelper<Core>   destructionHelper_;
     140
     141            static Core*              singletonPtr_s;
    139142    };
    140143}
Note: See TracChangeset for help on using the changeset viewer.