Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 4, 2009, 12:02:28 AM (15 years ago)
Author:
rgrieder
Message:

Modified Scoped Singleton concept: Derive from Singleton normally, but place an important pre-main() instruction in the source file: ManageScopedSingleton(className, scope) (it's a macro).
This causes the Singleton to be created and destroyed with the Scope. Thus if a Singleton c'tor throws, it is much easier to react accordingly.

Location:
code/branches/core5/src/modules/questsystem
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core5/src/modules/questsystem/QuestManager.cc

    r5800 r5867  
    4141#include "core/ConsoleCommand.h"
    4242#include "core/LuaState.h"
     43#include "core/ScopedSingletonManager.h"
    4344#include "infos/PlayerInfo.h"
    4445#include "overlays/GUIOverlay.h"
     
    5657    //! Pointer to the current (and single) instance of this class.
    5758    /*static*/ QuestManager* QuestManager::singletonPtr_s = NULL;
     59    ManageScopedSingleton(QuestManager, ScopeID::Root);
    5860
    5961    /**
  • code/branches/core5/src/modules/questsystem/QuestManager.h

    r5850 r5867  
    4242#include <string>
    4343
    44 #include "util/ScopedSingleton.h"
     44#include "util/Singleton.h"
    4545#include "core/OrxonoxClass.h"
    4646
     
    5959    class _QuestsystemExport QuestManager
    6060// tolua_end
    61         : public ScopedSingleton<QuestManager, ScopeID::Root>, public orxonox::OrxonoxClass
     61        : public Singleton<QuestManager>, public orxonox::OrxonoxClass
    6262    { // tolua_export
    6363
    64             friend class ScopedSingleton<QuestManager, ScopeID::Root>;
     64            friend class Singleton<QuestManager>;
    6565            friend class QuestGUI;
    6666
     
    7070
    7171            //! Returns a reference to the single instance of the Quest Manager.
    72             static QuestManager& getInstance() { return ScopedSingleton<QuestManager, ScopeID::Root>::getInstance(); } // tolua_export
     72            static QuestManager& getInstance() { return Singleton<QuestManager>::getInstance(); } // tolua_export
    7373
    7474            //! Retreive the main window for the GUI.
  • code/branches/core5/src/modules/questsystem/QuestsystemPrecompiledHeaders.h

    r5749 r5867  
    5151#include <OgreColourValue.h> // 16
    5252
    53 #include <tinyxml/ticpp.h>        // 14
    54 #include "util/ScopedSingleton.h" // 13
     53#include <tinyxml/ticpp.h>   // 14
     54#include "util/Singleton.h" // 13
    5555
    5656///////////////////////////////////////////
  • code/branches/core5/src/modules/questsystem/notifications/NotificationManager.cc

    r5760 r5867  
    3737
    3838#include "core/CoreIncludes.h"
     39#include "core/ScopedSingletonManager.h"
    3940#include "Notification.h"
    4041#include "interfaces/NotificationListener.h"
     
    4748
    4849    NotificationManager* NotificationManager::singletonPtr_s = NULL;
     50    ManageScopedSingleton(NotificationManager, ScopeID::Root);
    4951
    5052    /**
  • code/branches/core5/src/modules/questsystem/notifications/NotificationManager.h

    r5850 r5867  
    4141#include <string>
    4242
    43 #include "util/ScopedSingleton.h"
     43#include "util/Singleton.h"
    4444#include "core/OrxonoxClass.h"
    4545
     
    5353        Damian 'Mozork' Frick
    5454    */
    55     class _QuestsystemExport NotificationManager : public ScopedSingleton<NotificationManager, ScopeID::Root>, public OrxonoxClass
     55    class _QuestsystemExport NotificationManager : public Singleton<NotificationManager>, public OrxonoxClass
    5656    {
    57             friend class ScopedSingleton<NotificationManager, ScopeID::Root>;
     57            friend class Singleton<NotificationManager>;
    5858        public:
    5959            NotificationManager();
Note: See TracChangeset for help on using the changeset viewer.