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/orxonox
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core5/src/orxonox/CameraManager.cc

    r5850 r5867  
    2626 *
    2727 */
     28
    2829#include "CameraManager.h"
    2930
     
    3738#include "core/GUIManager.h"
    3839#include "core/ObjectList.h"
     40#include "core/ScopedSingletonManager.h"
    3941#include "tools/Shader.h"
    4042#include "graphics/Camera.h"
     
    4345namespace orxonox
    4446{
     47    ManageScopedSingleton(CameraManager, ScopeID::Graphics);
    4548    CameraManager* CameraManager::singletonPtr_s = 0;
    4649
  • code/branches/core5/src/orxonox/CameraManager.h

    r5850 r5867  
    4141#include <list>
    4242#include "util/OgreForwardRefs.h"
    43 #include "util/ScopedSingleton.h"
     43#include "util/Singleton.h"
    4444#include "core/OrxonoxClass.h"
    4545#include "core/SmartPtr.h"
     
    4747namespace orxonox
    4848{
    49     class _OrxonoxExport CameraManager : public ScopedSingleton<CameraManager, ScopeID::Graphics>, public OrxonoxClass
     49    class _OrxonoxExport CameraManager : public Singleton<CameraManager>, public OrxonoxClass
    5050    {
    51             friend class ScopedSingleton<CameraManager, ScopeID::Graphics>;
     51            friend class Singleton<CameraManager>;
    5252        public:
    5353            CameraManager();
  • code/branches/core5/src/orxonox/LevelManager.cc

    r5836 r5867  
    3636#include "core/CoreIncludes.h"
    3737#include "core/Loader.h"
     38#include "core/ScopedSingletonManager.h"
    3839#include "PlayerManager.h"
    3940#include "Level.h"
     
    4344    SetCommandLineArgument(level, "").shortcut("l").information("Default level file (overrides LevelManager::defaultLevelName_ configValue)");
    4445
     46    ManageScopedSingleton(LevelManager, ScopeID::Root);
    4547    LevelManager* LevelManager::singletonPtr_s = 0;
    4648
  • code/branches/core5/src/orxonox/LevelManager.h

    r5850 r5867  
    3636#include <string>
    3737
    38 #include "util/ScopedSingleton.h"
     38#include "util/Singleton.h"
    3939#include "core/OrxonoxClass.h"
    4040
     
    4444    class _OrxonoxExport LevelManager
    4545    // tolua_end
    46         : public ScopedSingleton<LevelManager, ScopeID::Root>, public OrxonoxClass
     46        : public Singleton<LevelManager>, public OrxonoxClass
    4747    { // tolua_export
    48             friend class ScopedSingleton<LevelManager, ScopeID::Root>;
     48            friend class Singleton<LevelManager>;
    4949        public:
    5050            LevelManager();
     
    6363
    6464            static LevelManager* getInstancePtr() { return singletonPtr_s; }
    65             static LevelManager& getInstance()    { return ScopedSingleton<LevelManager, ScopeID::Root>::getInstance(); } // tolua_export
     65            static LevelManager& getInstance()    { return Singleton<LevelManager>::getInstance(); } // tolua_export
    6666
    6767        private:
  • code/branches/core5/src/orxonox/PlayerManager.cc

    r5820 r5867  
    3131#include "core/CoreIncludes.h"
    3232#include "core/GameMode.h"
     33#include "core/ScopedSingletonManager.h"
    3334#include "Level.h"
    3435#include "infos/HumanPlayer.h"
     
    3839{
    3940    PlayerManager* PlayerManager::singletonPtr_s = 0;
     41    ManageScopedSingleton(PlayerManager, ScopeID::Root);
    4042
    4143    PlayerManager::PlayerManager()
  • code/branches/core5/src/orxonox/PlayerManager.h

    r5850 r5867  
    3434#include <cassert>
    3535#include <map>
    36 #include "util/ScopedSingleton.h"
     36#include "util/Singleton.h"
    3737#include "network/ClientConnectionListener.h"
    3838
    3939namespace orxonox
    4040{
    41     class _OrxonoxExport PlayerManager : public ScopedSingleton<PlayerManager, ScopeID::Root>, public ClientConnectionListener
     41    class _OrxonoxExport PlayerManager : public Singleton<PlayerManager>, public ClientConnectionListener
    4242    {
    43             friend class ScopedSingleton<PlayerManager, ScopeID::Root>;
     43            friend class Singleton<PlayerManager>;
    4444        public:
    4545            PlayerManager();
  • code/branches/core5/src/orxonox/overlays/InGameConsole.cc

    r5855 r5867  
    4848#include "core/ConfigValueIncludes.h"
    4949#include "core/ConsoleCommand.h"
     50#include "core/ScopedSingletonManager.h"
    5051#include "core/input/InputManager.h"
    5152#include "core/input/InputState.h"
     
    6162
    6263    InGameConsole* InGameConsole::singletonPtr_s = 0;
     64    ManageScopedSingleton(InGameConsole, ScopeID::Graphics);
    6365
    6466    /**
  • code/branches/core5/src/orxonox/overlays/InGameConsole.h

    r5850 r5867  
    3636
    3737#include "util/OgreForwardRefs.h"
    38 #include "util/ScopedSingleton.h"
     38#include "util/Singleton.h"
    3939#include "core/Shell.h"
    4040#include "core/WindowEventListener.h"
     
    4242namespace orxonox
    4343{
    44     class _OrxonoxExport InGameConsole : public ScopedSingleton<InGameConsole, ScopeID::Graphics>, public ShellListener, public WindowEventListener
     44    class _OrxonoxExport InGameConsole : public Singleton<InGameConsole>, public ShellListener, public WindowEventListener
    4545    {
    46         friend class ScopedSingleton<InGameConsole, ScopeID::Graphics>;
     46        friend class Singleton<InGameConsole>;
    4747    public: // functions
    4848        InGameConsole();
  • code/branches/core5/src/orxonox/sound/SoundManager.cc

    r5738 r5867  
    3232
    3333#include "util/Math.h"
     34#include "core/ScopedSingletonManager.h"
    3435#include "CameraManager.h"
    3536#include "graphics/Camera.h"
     
    3940{
    4041    SoundManager* SoundManager::singletonPtr_s = NULL;
     42    ManageScopedSingleton(SoundManager, ScopeID::Graphics);
    4143
    4244    /**
  • code/branches/core5/src/orxonox/sound/SoundManager.h

    r5850 r5867  
    3232#include <cassert>
    3333#include <list>
    34 #include "util/ScopedSingleton.h"
     34#include "util/Singleton.h"
    3535#include "tools/interfaces/Tickable.h"
    3636
     
    4343     *
    4444     */
    45     class _OrxonoxExport SoundManager : public ScopedSingleton<SoundManager, ScopeID::Graphics>, public Tickable
     45    class _OrxonoxExport SoundManager : public Singleton<SoundManager>, public Tickable
    4646    {
    47         friend class ScopedSingleton<SoundManager, ScopeID::Graphics>;
     47        friend class Singleton<SoundManager>;
    4848    public:
    4949        SoundManager();
Note: See TracChangeset for help on using the changeset viewer.