[Orxonox-commit 1146] r5867 - in code/branches/core5/src: libraries/core libraries/util modules/questsystem modules/questsystem/notifications orxonox orxonox/overlays orxonox/sound
rgrieder at orxonox.net
rgrieder at orxonox.net
Sun Oct 4 00:02:28 CEST 2009
Author: rgrieder
Date: 2009-10-04 00:02:28 +0200 (Sun, 04 Oct 2009)
New Revision: 5867
Added:
code/branches/core5/src/libraries/core/ScopedSingletonManager.cc
code/branches/core5/src/libraries/core/ScopedSingletonManager.h
Removed:
code/branches/core5/src/libraries/util/ScopedSingleton.h
Modified:
code/branches/core5/src/libraries/core/CMakeLists.txt
code/branches/core5/src/libraries/core/Core.cc
code/branches/core5/src/libraries/util/Scope.h
code/branches/core5/src/libraries/util/Singleton.h
code/branches/core5/src/modules/questsystem/QuestManager.cc
code/branches/core5/src/modules/questsystem/QuestManager.h
code/branches/core5/src/modules/questsystem/QuestsystemPrecompiledHeaders.h
code/branches/core5/src/modules/questsystem/notifications/NotificationManager.cc
code/branches/core5/src/modules/questsystem/notifications/NotificationManager.h
code/branches/core5/src/orxonox/CameraManager.cc
code/branches/core5/src/orxonox/CameraManager.h
code/branches/core5/src/orxonox/LevelManager.cc
code/branches/core5/src/orxonox/LevelManager.h
code/branches/core5/src/orxonox/PlayerManager.cc
code/branches/core5/src/orxonox/PlayerManager.h
code/branches/core5/src/orxonox/overlays/InGameConsole.cc
code/branches/core5/src/orxonox/overlays/InGameConsole.h
code/branches/core5/src/orxonox/sound/SoundManager.cc
code/branches/core5/src/orxonox/sound/SoundManager.h
Log:
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.
Modified: code/branches/core5/src/libraries/core/CMakeLists.txt
===================================================================
--- code/branches/core5/src/libraries/core/CMakeLists.txt 2009-10-03 16:32:05 UTC (rev 5866)
+++ code/branches/core5/src/libraries/core/CMakeLists.txt 2009-10-03 22:02:28 UTC (rev 5867)
@@ -36,6 +36,7 @@
OrxonoxClass.cc
PathConfig.cc
Resource.cc
+ ScopedSingletonManager.cc
WindowEventListener.cc
# command
Modified: code/branches/core5/src/libraries/core/Core.cc
===================================================================
--- code/branches/core5/src/libraries/core/Core.cc 2009-10-03 16:32:05 UTC (rev 5866)
+++ code/branches/core5/src/libraries/core/Core.cc 2009-10-03 22:02:28 UTC (rev 5867)
@@ -64,6 +64,7 @@
#include "Identifier.h"
#include "Language.h"
#include "LuaState.h"
+#include "ScopedSingletonManager.h"
#include "Shell.h"
#include "TclBind.h"
#include "TclThreadManager.h"
@@ -432,7 +433,7 @@
void Core::preUpdate(const Clock& time)
{
// singletons from other libraries
- Scope<ScopeID::Root>::update(time);
+ ScopedSingletonManager::update(time, ScopeID::Root);
if (this->bGraphicsLoaded_)
{
// process input events
@@ -440,7 +441,7 @@
// process gui events
this->guiManager_->update(time);
// graphics singletons from other libraries
- Scope<ScopeID::Graphics>::update(time);
+ ScopedSingletonManager::update(time, ScopeID::Graphics);
}
// process thread commands
this->tclThreadManager_->update(time);
Added: code/branches/core5/src/libraries/core/ScopedSingletonManager.cc
===================================================================
--- code/branches/core5/src/libraries/core/ScopedSingletonManager.cc (rev 0)
+++ code/branches/core5/src/libraries/core/ScopedSingletonManager.cc 2009-10-03 22:02:28 UTC (rev 5867)
@@ -0,0 +1,59 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Reto Grieder
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "ScopedSingletonManager.h"
+
+namespace orxonox
+{
+ /*static*/ std::map<std::string, ScopedSingletonManager*>& ScopedSingletonManager::getManagers()
+ {
+ static std::map<std::string, ScopedSingletonManager*> managers;
+ return managers;
+ }
+ /*static*/ ScopedSingletonManager::ManagerMultiMap& ScopedSingletonManager::getManagersByScope()
+ {
+ static ManagerMultiMap managers;
+ return managers;
+ }
+
+ /*static*/ void ScopedSingletonManager::addManager(ScopedSingletonManager* manager)
+ {
+ getManagers()[manager->className_] = manager;
+ getManagersByScope().insert(std::make_pair(manager->scope_, manager));
+ }
+
+ /*static*/ void ScopedSingletonManager::removeManager(ScopedSingletonManager* manager)
+ {
+ getManagers().erase(getManagers().find(manager->className_));
+ for (ManagerMultiMap::iterator it = getManagersByScope().lower_bound(manager->scope_); it != getManagersByScope().upper_bound(manager->scope_);)
+ if (it->second == manager)
+ getManagersByScope().erase(it++);
+ else
+ ++it;
+ }
+}
Property changes on: code/branches/core5/src/libraries/core/ScopedSingletonManager.cc
___________________________________________________________________
Added: svn:eol-style
+ native
Added: code/branches/core5/src/libraries/core/ScopedSingletonManager.h
===================================================================
--- code/branches/core5/src/libraries/core/ScopedSingletonManager.h (rev 0)
+++ code/branches/core5/src/libraries/core/ScopedSingletonManager.h 2009-10-03 22:02:28 UTC (rev 5867)
@@ -0,0 +1,124 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Reto Grieder
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef __ScopedSingletonManager_H__
+#define __ScopedSingletonManager_H__
+
+#include "CorePrereqs.h"
+
+#include <cassert>
+#include <map>
+#include "util/Scope.h"
+#include "util/Singleton.h"
+
+#define ManageScopedSingleton(className, scope) \
+ static ClassScopedSingletonManager<className, scope> className##ScopedSingletonManager(#className)
+
+namespace orxonox
+{
+ class _CoreExport ScopedSingletonManager
+ {
+ public:
+ ScopedSingletonManager(const std::string& className, ScopeID::Value scope)
+ : className_(className)
+ , scope_(scope)
+ { }
+ virtual ~ScopedSingletonManager() { }
+ static void addManager(ScopedSingletonManager* manager);
+ static void removeManager(ScopedSingletonManager* manager);
+
+ static void update(const Clock& time, ScopeID::Value scope)
+ {
+ for (ManagerMultiMap::iterator it = getManagersByScope().lower_bound(scope); it != getManagersByScope().upper_bound(scope); ++it)
+ it->second->update(time);
+ }
+ virtual void update(const Clock& time) = 0;
+
+ static std::map<std::string, ScopedSingletonManager*>& getManagers();
+ typedef std::multimap<ScopeID::Value, ScopedSingletonManager*> ManagerMultiMap;
+ static ManagerMultiMap& getManagersByScope();
+
+ protected:
+ const std::string className_;
+ const ScopeID::Value scope_;
+ };
+
+ template <class T, ScopeID::Value scope>
+ class ClassScopedSingletonManager : public ScopedSingletonManager, public ScopeListener
+ {
+ public:
+ ClassScopedSingletonManager(const std::string& className)
+ : ScopedSingletonManager(className, scope)
+ , ScopeListener(scope)
+ , singletonPtr_(NULL)
+ {
+ ScopedSingletonManager::addManager(this);
+ }
+
+ ~ClassScopedSingletonManager()
+ {
+ ScopedSingletonManager::removeManager(this);
+ }
+
+ //! Called if the Scope of the Singleton gets active (creates the instance)
+ void activated()
+ {
+ assert(singletonPtr_ == NULL);
+ singletonPtr_ = new T();
+ }
+
+ //! Called if the Scope of this Singleton gets deactivated (destroys the instance)
+ void deactivated()
+ {
+ assert(singletonPtr_ != NULL);
+ this->destroy(singletonPtr_);
+ singletonPtr_ = NULL;
+ }
+
+ void destroy(OrxonoxClass* ptr)
+ {
+ singletonPtr_->destroy();
+ }
+ void destroy(void* ptr)
+ {
+ delete singletonPtr_;
+ }
+
+ //! Called every frame by the ScopedSingletonManager
+ void update(const Clock& time)
+ {
+ // assuming T inherits Singleton<T>
+ singletonPtr_->updateSingleton(time);
+ }
+
+ private:
+ T* singletonPtr_;
+ };
+}
+
+#endif /* __ScopedSingletonManager_H__ */
Property changes on: code/branches/core5/src/libraries/core/ScopedSingletonManager.h
___________________________________________________________________
Added: svn:eol-style
+ native
Modified: code/branches/core5/src/libraries/util/Scope.h
===================================================================
--- code/branches/core5/src/libraries/util/Scope.h 2009-10-03 16:32:05 UTC (rev 5866)
+++ code/branches/core5/src/libraries/util/Scope.h 2009-10-03 22:02:28 UTC (rev 5867)
@@ -72,8 +72,6 @@
virtual void activated() = 0;
//! Gets called if the scope is deactivated
virtual void deactivated() = 0;
- //! Gets called if the scope is updated
- virtual void updated(const Clock& time) = 0;
private:
ScopeID::Value scope_; //!< Store the scope to unregister on destruction
@@ -123,16 +121,6 @@
{
return (ScopeManager::instanceCounts_s[scope] > 0);
}
-
- //! Update method for the ScopeListeners (to implement singleton updates)
- static void update(const Clock& time)
- {
- if (isActive())
- {
- for (typename std::set<ScopeListener*>::iterator it = ScopeManager::listeners_s[scope].begin(); it != ScopeManager::listeners_s[scope].end(); )
- (*(it++))->updated(time);
- }
- }
};
}
Deleted: code/branches/core5/src/libraries/util/ScopedSingleton.h
===================================================================
--- code/branches/core5/src/libraries/util/ScopedSingleton.h 2009-10-03 16:32:05 UTC (rev 5866)
+++ code/branches/core5/src/libraries/util/ScopedSingleton.h 2009-10-03 22:02:28 UTC (rev 5867)
@@ -1,108 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Fabian 'x3n' Landau
- * Co-authors:
- * ...
- *
- */
-
-#ifndef __Util_ScopedSingleton_H__
-#define __Util_ScopedSingleton_H__
-
-#include "UtilPrereqs.h"
-#include <cassert>
-
-#include "Scope.h"
-
-namespace orxonox
-{
- class Clock;
- /**
- @brief
- Base for scoped singleton classes.
- A Scoped singleton creates itself if the scope is active and getInstance() is called.
- Destroys itself if the scope is deactivated.
-
- Usage:
- Inherit publicly from ScopedSingleton<MyClass, scope> and provide access to
- MyClass::singletonPtr_s.
- This can easily be done with a friend declaration.
-
- See @ref UtilPrereqs.h for a list of scopes (ScopeID::Value).
- */
- template <class T, ScopeID::Value scope>
- class ScopedSingleton : public ScopeListener
- {
- public:
- //! Returns a reference to the singleton instance
- static T& getInstance()
- {
- assert(Scope<scope>::isActive());
-
- if (!T::singletonPtr_s)
- T::singletonPtr_s = new T();
-
- return *T::singletonPtr_s;
- }
-
- //! Update method for singletons like the ingame console
- virtual void updated(const Clock& time) { static_cast<T*>(this)->update(time); }
- //! Empty update method for the static polymorphism
- void update(const Clock& time) { }
-
- protected:
- //! Constructor sets the singleton instance pointer
- ScopedSingleton() : ScopeListener(scope)
- {
- assert(T::singletonPtr_s == 0);
- T::singletonPtr_s = static_cast<T*>(this);
- }
-
- //! Constructor resets the singleton instance pointer
- ~ScopedSingleton()
- {
- assert(T::singletonPtr_s != 0);
- T::singletonPtr_s = 0;
- }
-
- private:
- //! Called if the Scope of this Singleton gets active (no instance should be active then)
- void activated()
- {
- // The ScopedSingleton shouldn't be active bevor the scope is activated -> always assertion failed
- assert(false);
- }
-
- //! Called if the Scope of this Singleton gets deactivated (destroys the instance)
- void deactivated()
- {
- if (T::singletonPtr_s)
- {
- T::singletonPtr_s->destroy();
- T::singletonPtr_s = 0;
- }
- }
- };
-}
-
-#endif /* __Util_ScopedSingleton_H__ */
Modified: code/branches/core5/src/libraries/util/Singleton.h
===================================================================
--- code/branches/core5/src/libraries/util/Singleton.h 2009-10-03 16:32:05 UTC (rev 5866)
+++ code/branches/core5/src/libraries/util/Singleton.h 2009-10-03 22:02:28 UTC (rev 5867)
@@ -54,6 +54,11 @@
return *T::singletonPtr_s;
}
+ //! Update method called by ClassSingletonManager (if used)
+ void updateSingleton(const Clock& time) { static_cast<T*>(T::singletonPtr_s)->update(time); }
+ //! Empty update method for the static polymorphism
+ void update(const Clock& time) { }
+
protected:
//! Constructor sets the singleton instance pointer
Singleton()
Modified: code/branches/core5/src/modules/questsystem/QuestManager.cc
===================================================================
--- code/branches/core5/src/modules/questsystem/QuestManager.cc 2009-10-03 16:32:05 UTC (rev 5866)
+++ code/branches/core5/src/modules/questsystem/QuestManager.cc 2009-10-03 22:02:28 UTC (rev 5867)
@@ -40,6 +40,7 @@
#include "core/GUIManager.h"
#include "core/ConsoleCommand.h"
#include "core/LuaState.h"
+#include "core/ScopedSingletonManager.h"
#include "infos/PlayerInfo.h"
#include "overlays/GUIOverlay.h"
@@ -55,6 +56,7 @@
//! Pointer to the current (and single) instance of this class.
/*static*/ QuestManager* QuestManager::singletonPtr_s = NULL;
+ ManageScopedSingleton(QuestManager, ScopeID::Root);
/**
@brief
Modified: code/branches/core5/src/modules/questsystem/QuestManager.h
===================================================================
--- code/branches/core5/src/modules/questsystem/QuestManager.h 2009-10-03 16:32:05 UTC (rev 5866)
+++ code/branches/core5/src/modules/questsystem/QuestManager.h 2009-10-03 22:02:28 UTC (rev 5867)
@@ -41,7 +41,7 @@
#include <map>
#include <string>
-#include "util/ScopedSingleton.h"
+#include "util/Singleton.h"
#include "core/OrxonoxClass.h"
#include "QuestGUI.h"
@@ -58,10 +58,10 @@
*/
class _QuestsystemExport QuestManager
// tolua_end
- : public ScopedSingleton<QuestManager, ScopeID::Root>, public orxonox::OrxonoxClass
+ : public Singleton<QuestManager>, public orxonox::OrxonoxClass
{ // tolua_export
- friend class ScopedSingleton<QuestManager, ScopeID::Root>;
+ friend class Singleton<QuestManager>;
friend class QuestGUI;
public:
@@ -69,7 +69,7 @@
virtual ~QuestManager();
//! Returns a reference to the single instance of the Quest Manager.
- static QuestManager& getInstance() { return ScopedSingleton<QuestManager, ScopeID::Root>::getInstance(); } // tolua_export
+ static QuestManager& getInstance() { return Singleton<QuestManager>::getInstance(); } // tolua_export
//! Retreive the main window for the GUI.
CEGUI::Window* getQuestGUI(const std::string & guiName); // tolua_export
Modified: code/branches/core5/src/modules/questsystem/QuestsystemPrecompiledHeaders.h
===================================================================
--- code/branches/core5/src/modules/questsystem/QuestsystemPrecompiledHeaders.h 2009-10-03 16:32:05 UTC (rev 5866)
+++ code/branches/core5/src/modules/questsystem/QuestsystemPrecompiledHeaders.h 2009-10-03 22:02:28 UTC (rev 5867)
@@ -50,8 +50,8 @@
#include <OgreQuaternion.h> // 16
#include <OgreColourValue.h> // 16
-#include <tinyxml/ticpp.h> // 14
-#include "util/ScopedSingleton.h" // 13
+#include <tinyxml/ticpp.h> // 14
+#include "util/Singleton.h" // 13
///////////////////////////////////////////
///// All Rebuild Headers /////
Modified: code/branches/core5/src/modules/questsystem/notifications/NotificationManager.cc
===================================================================
--- code/branches/core5/src/modules/questsystem/notifications/NotificationManager.cc 2009-10-03 16:32:05 UTC (rev 5866)
+++ code/branches/core5/src/modules/questsystem/notifications/NotificationManager.cc 2009-10-03 22:02:28 UTC (rev 5867)
@@ -36,6 +36,7 @@
#include <set>
#include "core/CoreIncludes.h"
+#include "core/ScopedSingletonManager.h"
#include "Notification.h"
#include "interfaces/NotificationListener.h"
@@ -46,6 +47,7 @@
const std::string NotificationManager::NONE = "none";
NotificationManager* NotificationManager::singletonPtr_s = NULL;
+ ManageScopedSingleton(NotificationManager, ScopeID::Root);
/**
@brief
Modified: code/branches/core5/src/modules/questsystem/notifications/NotificationManager.h
===================================================================
--- code/branches/core5/src/modules/questsystem/notifications/NotificationManager.h 2009-10-03 16:32:05 UTC (rev 5866)
+++ code/branches/core5/src/modules/questsystem/notifications/NotificationManager.h 2009-10-03 22:02:28 UTC (rev 5867)
@@ -40,7 +40,7 @@
#include <map>
#include <string>
-#include "util/ScopedSingleton.h"
+#include "util/Singleton.h"
#include "core/OrxonoxClass.h"
namespace orxonox
@@ -52,9 +52,9 @@
@author
Damian 'Mozork' Frick
*/
- class _QuestsystemExport NotificationManager : public ScopedSingleton<NotificationManager, ScopeID::Root>, public OrxonoxClass
+ class _QuestsystemExport NotificationManager : public Singleton<NotificationManager>, public OrxonoxClass
{
- friend class ScopedSingleton<NotificationManager, ScopeID::Root>;
+ friend class Singleton<NotificationManager>;
public:
NotificationManager();
virtual ~NotificationManager();
Modified: code/branches/core5/src/orxonox/CameraManager.cc
===================================================================
--- code/branches/core5/src/orxonox/CameraManager.cc 2009-10-03 16:32:05 UTC (rev 5866)
+++ code/branches/core5/src/orxonox/CameraManager.cc 2009-10-03 22:02:28 UTC (rev 5867)
@@ -25,6 +25,7 @@
* Fabian 'x3n' Landau
*
*/
+
#include "CameraManager.h"
#include <OgreSceneManager.h>
@@ -36,12 +37,14 @@
#include "core/GraphicsManager.h"
#include "core/GUIManager.h"
#include "core/ObjectList.h"
+#include "core/ScopedSingletonManager.h"
#include "tools/Shader.h"
#include "graphics/Camera.h"
#include "Scene.h"
namespace orxonox
{
+ ManageScopedSingleton(CameraManager, ScopeID::Graphics);
CameraManager* CameraManager::singletonPtr_s = 0;
CameraManager::CameraManager()
Modified: code/branches/core5/src/orxonox/CameraManager.h
===================================================================
--- code/branches/core5/src/orxonox/CameraManager.h 2009-10-03 16:32:05 UTC (rev 5866)
+++ code/branches/core5/src/orxonox/CameraManager.h 2009-10-03 22:02:28 UTC (rev 5867)
@@ -40,15 +40,15 @@
#include <cassert>
#include <list>
#include "util/OgreForwardRefs.h"
-#include "util/ScopedSingleton.h"
+#include "util/Singleton.h"
#include "core/OrxonoxClass.h"
#include "core/SmartPtr.h"
namespace orxonox
{
- class _OrxonoxExport CameraManager : public ScopedSingleton<CameraManager, ScopeID::Graphics>, public OrxonoxClass
+ class _OrxonoxExport CameraManager : public Singleton<CameraManager>, public OrxonoxClass
{
- friend class ScopedSingleton<CameraManager, ScopeID::Graphics>;
+ friend class Singleton<CameraManager>;
public:
CameraManager();
~CameraManager();
Modified: code/branches/core5/src/orxonox/LevelManager.cc
===================================================================
--- code/branches/core5/src/orxonox/LevelManager.cc 2009-10-03 16:32:05 UTC (rev 5866)
+++ code/branches/core5/src/orxonox/LevelManager.cc 2009-10-03 22:02:28 UTC (rev 5867)
@@ -35,6 +35,7 @@
#include "core/ConfigValueIncludes.h"
#include "core/CoreIncludes.h"
#include "core/Loader.h"
+#include "core/ScopedSingletonManager.h"
#include "PlayerManager.h"
#include "Level.h"
@@ -42,6 +43,7 @@
{
SetCommandLineArgument(level, "").shortcut("l").information("Default level file (overrides LevelManager::defaultLevelName_ configValue)");
+ ManageScopedSingleton(LevelManager, ScopeID::Root);
LevelManager* LevelManager::singletonPtr_s = 0;
LevelManager::LevelManager()
Modified: code/branches/core5/src/orxonox/LevelManager.h
===================================================================
--- code/branches/core5/src/orxonox/LevelManager.h 2009-10-03 16:32:05 UTC (rev 5866)
+++ code/branches/core5/src/orxonox/LevelManager.h 2009-10-03 22:02:28 UTC (rev 5867)
@@ -35,7 +35,7 @@
#include <list>
#include <string>
-#include "util/ScopedSingleton.h"
+#include "util/Singleton.h"
#include "core/OrxonoxClass.h"
// tolua_begin
@@ -43,9 +43,9 @@
{
class _OrxonoxExport LevelManager
// tolua_end
- : public ScopedSingleton<LevelManager, ScopeID::Root>, public OrxonoxClass
+ : public Singleton<LevelManager>, public OrxonoxClass
{ // tolua_export
- friend class ScopedSingleton<LevelManager, ScopeID::Root>;
+ friend class Singleton<LevelManager>;
public:
LevelManager();
virtual ~LevelManager();
@@ -62,7 +62,7 @@
std::string getAvailableLevelListItem(unsigned int index) const; //tolua_export
static LevelManager* getInstancePtr() { return singletonPtr_s; }
- static LevelManager& getInstance() { return ScopedSingleton<LevelManager, ScopeID::Root>::getInstance(); } // tolua_export
+ static LevelManager& getInstance() { return Singleton<LevelManager>::getInstance(); } // tolua_export
private:
LevelManager(const LevelManager&);
Modified: code/branches/core5/src/orxonox/PlayerManager.cc
===================================================================
--- code/branches/core5/src/orxonox/PlayerManager.cc 2009-10-03 16:32:05 UTC (rev 5866)
+++ code/branches/core5/src/orxonox/PlayerManager.cc 2009-10-03 22:02:28 UTC (rev 5867)
@@ -30,6 +30,7 @@
#include "core/CoreIncludes.h"
#include "core/GameMode.h"
+#include "core/ScopedSingletonManager.h"
#include "Level.h"
#include "infos/HumanPlayer.h"
#include "LevelManager.h"
@@ -37,6 +38,7 @@
namespace orxonox
{
PlayerManager* PlayerManager::singletonPtr_s = 0;
+ ManageScopedSingleton(PlayerManager, ScopeID::Root);
PlayerManager::PlayerManager()
{
Modified: code/branches/core5/src/orxonox/PlayerManager.h
===================================================================
--- code/branches/core5/src/orxonox/PlayerManager.h 2009-10-03 16:32:05 UTC (rev 5866)
+++ code/branches/core5/src/orxonox/PlayerManager.h 2009-10-03 22:02:28 UTC (rev 5867)
@@ -33,14 +33,14 @@
#include <cassert>
#include <map>
-#include "util/ScopedSingleton.h"
+#include "util/Singleton.h"
#include "network/ClientConnectionListener.h"
namespace orxonox
{
- class _OrxonoxExport PlayerManager : public ScopedSingleton<PlayerManager, ScopeID::Root>, public ClientConnectionListener
+ class _OrxonoxExport PlayerManager : public Singleton<PlayerManager>, public ClientConnectionListener
{
- friend class ScopedSingleton<PlayerManager, ScopeID::Root>;
+ friend class Singleton<PlayerManager>;
public:
PlayerManager();
virtual ~PlayerManager();
Modified: code/branches/core5/src/orxonox/overlays/InGameConsole.cc
===================================================================
--- code/branches/core5/src/orxonox/overlays/InGameConsole.cc 2009-10-03 16:32:05 UTC (rev 5866)
+++ code/branches/core5/src/orxonox/overlays/InGameConsole.cc 2009-10-03 22:02:28 UTC (rev 5867)
@@ -47,6 +47,7 @@
#include "core/CoreIncludes.h"
#include "core/ConfigValueIncludes.h"
#include "core/ConsoleCommand.h"
+#include "core/ScopedSingletonManager.h"
#include "core/input/InputManager.h"
#include "core/input/InputState.h"
#include "core/input/InputBuffer.h"
@@ -60,6 +61,7 @@
SetConsoleCommand(InGameConsole, closeConsole, true);
InGameConsole* InGameConsole::singletonPtr_s = 0;
+ ManageScopedSingleton(InGameConsole, ScopeID::Graphics);
/**
@brief Constructor: Creates and initializes the InGameConsole.
Modified: code/branches/core5/src/orxonox/overlays/InGameConsole.h
===================================================================
--- code/branches/core5/src/orxonox/overlays/InGameConsole.h 2009-10-03 16:32:05 UTC (rev 5866)
+++ code/branches/core5/src/orxonox/overlays/InGameConsole.h 2009-10-03 22:02:28 UTC (rev 5867)
@@ -35,15 +35,15 @@
#include <string>
#include "util/OgreForwardRefs.h"
-#include "util/ScopedSingleton.h"
+#include "util/Singleton.h"
#include "core/Shell.h"
#include "core/WindowEventListener.h"
namespace orxonox
{
- class _OrxonoxExport InGameConsole : public ScopedSingleton<InGameConsole, ScopeID::Graphics>, public ShellListener, public WindowEventListener
+ class _OrxonoxExport InGameConsole : public Singleton<InGameConsole>, public ShellListener, public WindowEventListener
{
- friend class ScopedSingleton<InGameConsole, ScopeID::Graphics>;
+ friend class Singleton<InGameConsole>;
public: // functions
InGameConsole();
~InGameConsole();
Modified: code/branches/core5/src/orxonox/sound/SoundManager.cc
===================================================================
--- code/branches/core5/src/orxonox/sound/SoundManager.cc 2009-10-03 16:32:05 UTC (rev 5866)
+++ code/branches/core5/src/orxonox/sound/SoundManager.cc 2009-10-03 22:02:28 UTC (rev 5867)
@@ -31,6 +31,7 @@
#include <AL/alut.h>
#include "util/Math.h"
+#include "core/ScopedSingletonManager.h"
#include "CameraManager.h"
#include "graphics/Camera.h"
#include "SoundBase.h"
@@ -38,6 +39,7 @@
namespace orxonox
{
SoundManager* SoundManager::singletonPtr_s = NULL;
+ ManageScopedSingleton(SoundManager, ScopeID::Graphics);
/**
* Default constructor
Modified: code/branches/core5/src/orxonox/sound/SoundManager.h
===================================================================
--- code/branches/core5/src/orxonox/sound/SoundManager.h 2009-10-03 16:32:05 UTC (rev 5866)
+++ code/branches/core5/src/orxonox/sound/SoundManager.h 2009-10-03 22:02:28 UTC (rev 5867)
@@ -31,7 +31,7 @@
#include <cassert>
#include <list>
-#include "util/ScopedSingleton.h"
+#include "util/Singleton.h"
#include "tools/interfaces/Tickable.h"
namespace orxonox
@@ -42,9 +42,9 @@
* function every tick. It is a singleton.
*
*/
- class _OrxonoxExport SoundManager : public ScopedSingleton<SoundManager, ScopeID::Graphics>, public Tickable
+ class _OrxonoxExport SoundManager : public Singleton<SoundManager>, public Tickable
{
- friend class ScopedSingleton<SoundManager, ScopeID::Graphics>;
+ friend class Singleton<SoundManager>;
public:
SoundManager();
~SoundManager();
More information about the Orxonox-commit
mailing list