[Orxonox-commit 2500] r7207 - in code/branches/consolecommands3/src: libraries/core libraries/core/input libraries/network libraries/util modules/designtools modules/notifications modules/pickup modules/questsystem orxonox orxonox/overlays orxonox/sound
landauf at orxonox.net
landauf at orxonox.net
Mon Aug 23 18:50:22 CEST 2010
Author: landauf
Date: 2010-08-23 18:50:22 +0200 (Mon, 23 Aug 2010)
New Revision: 7207
Added:
code/branches/consolecommands3/src/libraries/util/ScopedSingletonManager.cc
code/branches/consolecommands3/src/libraries/util/ScopedSingletonManager.h
Removed:
code/branches/consolecommands3/src/libraries/core/ScopedSingletonManager.cc
code/branches/consolecommands3/src/libraries/core/ScopedSingletonManager.h
Modified:
code/branches/consolecommands3/src/libraries/core/CMakeLists.txt
code/branches/consolecommands3/src/libraries/core/Core.cc
code/branches/consolecommands3/src/libraries/core/input/KeyBinderManager.cc
code/branches/consolecommands3/src/libraries/core/input/KeyDetector.cc
code/branches/consolecommands3/src/libraries/network/Client.cc
code/branches/consolecommands3/src/libraries/network/LANDiscovery.cc
code/branches/consolecommands3/src/libraries/util/CMakeLists.txt
code/branches/consolecommands3/src/modules/designtools/ScreenshotManager.cc
code/branches/consolecommands3/src/modules/designtools/SkyboxGenerator.cc
code/branches/consolecommands3/src/modules/notifications/NotificationManager.cc
code/branches/consolecommands3/src/modules/pickup/PickupManager.cc
code/branches/consolecommands3/src/modules/questsystem/QuestManager.cc
code/branches/consolecommands3/src/orxonox/CameraManager.cc
code/branches/consolecommands3/src/orxonox/ChatHistory.cc
code/branches/consolecommands3/src/orxonox/ChatInputHandler.cc
code/branches/consolecommands3/src/orxonox/LevelManager.cc
code/branches/consolecommands3/src/orxonox/MoodManager.cc
code/branches/consolecommands3/src/orxonox/PlayerManager.cc
code/branches/consolecommands3/src/orxonox/overlays/InGameConsole.cc
code/branches/consolecommands3/src/orxonox/sound/SoundManager.cc
Log:
moved ScopedSingletonManager to util
Modified: code/branches/consolecommands3/src/libraries/core/CMakeLists.txt
===================================================================
--- code/branches/consolecommands3/src/libraries/core/CMakeLists.txt 2010-08-23 09:43:10 UTC (rev 7206)
+++ code/branches/consolecommands3/src/libraries/core/CMakeLists.txt 2010-08-23 16:50:22 UTC (rev 7207)
@@ -34,7 +34,6 @@
ObjectListBase.cc
OrxonoxClass.cc
Resource.cc
- ScopedSingletonManager.cc
WindowEventListener.cc
# hierarchy
Modified: code/branches/consolecommands3/src/libraries/core/Core.cc
===================================================================
--- code/branches/consolecommands3/src/libraries/core/Core.cc 2010-08-23 09:43:10 UTC (rev 7206)
+++ code/branches/consolecommands3/src/libraries/core/Core.cc 2010-08-23 16:50:22 UTC (rev 7207)
@@ -51,6 +51,7 @@
#include "util/Debug.h"
#include "util/Exception.h"
#include "util/Scope.h"
+#include "util/ScopedSingletonManager.h"
#include "util/SignalHandler.h"
#include "PathConfig.h"
#include "CommandLineParser.h"
@@ -64,7 +65,6 @@
#include "Identifier.h"
#include "Language.h"
#include "LuaState.h"
-#include "ScopedSingletonManager.h"
#include "command/CommandExecutor.h"
#include "command/IOConsole.h"
#include "command/TclBind.h"
Deleted: code/branches/consolecommands3/src/libraries/core/ScopedSingletonManager.cc
===================================================================
--- code/branches/consolecommands3/src/libraries/core/ScopedSingletonManager.cc 2010-08-23 09:43:10 UTC (rev 7206)
+++ code/branches/consolecommands3/src/libraries/core/ScopedSingletonManager.cc 2010-08-23 16:50:22 UTC (rev 7207)
@@ -1,49 +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:
- * 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));
- }
-}
Deleted: code/branches/consolecommands3/src/libraries/core/ScopedSingletonManager.h
===================================================================
--- code/branches/consolecommands3/src/libraries/core/ScopedSingletonManager.h 2010-08-23 09:43:10 UTC (rev 7206)
+++ code/branches/consolecommands3/src/libraries/core/ScopedSingletonManager.h 2010-08-23 16:50:22 UTC (rev 7207)
@@ -1,212 +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:
- * Reto Grieder
- * Co-authors:
- * ...
- *
- */
-
-#ifndef __ScopedSingletonManager_H__
-#define __ScopedSingletonManager_H__
-
-#include "CorePrereqs.h"
-
-#include <cassert>
-#include <map>
-#include "util/Exception.h"
-#include "util/Scope.h"
-#include "util/Singleton.h"
-
-#define ManageScopedSingleton(className, scope, allowedToFail) \
- className* className::singletonPtr_s = NULL; \
- static ClassScopedSingletonManager<className, scope, allowedToFail> 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);
-
- template<ScopeID::Value scope>
- static void preUpdate(const Clock& time)
- {
- assert(Scope<scope>::isActive());
- for (ManagerMultiMap::iterator it = getManagersByScope().lower_bound(scope); it != getManagersByScope().upper_bound(scope); ++it)
- it->second->preUpdate(time);
- }
- virtual void preUpdate(const Clock& time) = 0;
- template<ScopeID::Value scope>
- static void postUpdate(const Clock& time)
- {
- assert(Scope<scope>::isActive());
- for (ManagerMultiMap::iterator it = getManagersByScope().lower_bound(scope); it != getManagersByScope().upper_bound(scope); ++it)
- it->second->postUpdate(time);
- }
- virtual void postUpdate(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, bool allowedToFail>
- class ClassScopedSingletonManager : public ScopedSingletonManager, public ScopeListener
- {
- public:
- ClassScopedSingletonManager(const std::string& className)
- : ScopedSingletonManager(className, scope)
- , ScopeListener(scope)
- , singletonPtr_(NULL)
- {
- ScopedSingletonManager::addManager(this);
- }
-
- ~ClassScopedSingletonManager()
- {
- }
-
- //! 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*)
- {
- singletonPtr_->destroy();
- }
- void destroy(void*)
- {
- delete singletonPtr_;
- }
-
- //! Called every frame by the ScopedSingletonManager
- void preUpdate(const Clock& time)
- {
- assert(Scope<scope>::isActive());
- // assuming T inherits Singleton<T>
- singletonPtr_->preUpdateSingleton(time);
- }
-
- //! Called every frame by the ScopedSingletonManager
- void postUpdate(const Clock& time)
- {
- assert(Scope<scope>::isActive());
- // assuming T inherits Singleton<T>
- singletonPtr_->postUpdateSingleton(time);
- }
-
- private:
- T* singletonPtr_;
- };
-
- template <class T, ScopeID::Value scope>
- class ClassScopedSingletonManager<T, scope, true> : public ScopedSingletonManager, public ScopeListener
- {
- public:
- ClassScopedSingletonManager(const std::string& className)
- : ScopedSingletonManager(className, scope)
- , ScopeListener(scope)
- , singletonPtr_(NULL)
- {
- ScopedSingletonManager::addManager(this);
- }
-
- ~ClassScopedSingletonManager()
- {
- }
-
- //! Called if the Scope of the Singleton gets active (creates the instance)
- void activated()
- {
- assert(singletonPtr_ == NULL);
- try
- { singletonPtr_ = new T(); }
- catch (const InitialisationAbortedException& ex)
- { COUT(3) << ex.getDescription() << std::endl; }
- catch (...)
- { COUT(1) << "Singleton creation failed: " << Exception::handleMessage() << std::endl; }
- }
-
- //! Called if the Scope of this Singleton gets deactivated (destroys the instance)
- void deactivated()
- {
- if (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 preUpdate(const Clock& time)
- {
- assert(Scope<scope>::isActive());
- // assuming T inherits Singleton<T>
- if (singletonPtr_ != NULL)
- singletonPtr_->preUpdateSingleton(time);
- }
-
- //! Called every frame by the ScopedSingletonManager
- void postUpdate(const Clock& time)
- {
- assert(Scope<scope>::isActive());
- // assuming T inherits Singleton<T>
- if (singletonPtr_ != NULL)
- singletonPtr_->postUpdateSingleton(time);
- }
-
- private:
- T* singletonPtr_;
- };
-}
-
-#endif /* __ScopedSingletonManager_H__ */
Modified: code/branches/consolecommands3/src/libraries/core/input/KeyBinderManager.cc
===================================================================
--- code/branches/consolecommands3/src/libraries/core/input/KeyBinderManager.cc 2010-08-23 09:43:10 UTC (rev 7206)
+++ code/branches/consolecommands3/src/libraries/core/input/KeyBinderManager.cc 2010-08-23 16:50:22 UTC (rev 7207)
@@ -30,10 +30,10 @@
#include "util/Debug.h"
#include "util/Exception.h"
+#include "util/ScopedSingletonManager.h"
#include "core/ConfigValueIncludes.h"
#include "core/CoreIncludes.h"
#include "core/LuaState.h"
-#include "core/ScopedSingletonManager.h"
#include "core/command/ConsoleCommand.h"
#include "InputManager.h"
#include "KeyDetector.h"
Modified: code/branches/consolecommands3/src/libraries/core/input/KeyDetector.cc
===================================================================
--- code/branches/consolecommands3/src/libraries/core/input/KeyDetector.cc 2010-08-23 09:43:10 UTC (rev 7206)
+++ code/branches/consolecommands3/src/libraries/core/input/KeyDetector.cc 2010-08-23 16:50:22 UTC (rev 7207)
@@ -28,8 +28,8 @@
#include "KeyDetector.h"
+#include "util/ScopedSingletonManager.h"
#include "core/CoreIncludes.h"
-#include "core/ScopedSingletonManager.h"
#include "core/command/ConsoleCommand.h"
#include "Button.h"
#include "InputManager.h"
Modified: code/branches/consolecommands3/src/libraries/network/Client.cc
===================================================================
--- code/branches/consolecommands3/src/libraries/network/Client.cc 2010-08-23 09:43:10 UTC (rev 7206)
+++ code/branches/consolecommands3/src/libraries/network/Client.cc 2010-08-23 16:50:22 UTC (rev 7207)
@@ -44,6 +44,7 @@
#include "util/Clock.h"
#include "util/Debug.h"
+#include "util/ScopedSingletonManager.h"
#include "synchronisable/Synchronisable.h"
#include "packet/Chat.h"
#include "packet/Gamestate.h"
@@ -51,7 +52,6 @@
#include "core/CoreIncludes.h"
#include "core/CommandLineParser.h"
#include "core/Game.h"
-#include "core/ScopedSingletonManager.h"
namespace orxonox
{
@@ -106,7 +106,7 @@
Host::setActive(false);
return ClientConnection::closeConnection();
}
-
+
void Client::setDestination(const std::string& serverAddress, unsigned int port)
{
ClientConnection::setServerAddress(serverAddress);
Modified: code/branches/consolecommands3/src/libraries/network/LANDiscovery.cc
===================================================================
--- code/branches/consolecommands3/src/libraries/network/LANDiscovery.cc 2010-08-23 09:43:10 UTC (rev 7206)
+++ code/branches/consolecommands3/src/libraries/network/LANDiscovery.cc 2010-08-23 16:50:22 UTC (rev 7207)
@@ -31,14 +31,14 @@
#include <enet/enet.h>
#include <cstring>
+#include "util/ScopedSingletonManager.h"
#include "core/CoreIncludes.h"
-#include "core/ScopedSingletonManager.h"
namespace orxonox
-{
+{
ManageScopedSingleton(LANDiscovery, ScopeID::Root, true);
-
+
LANDiscovery::LANDiscovery()
{
this->host_ = enet_host_create(NULL, 10, 0, 0 );
@@ -48,17 +48,17 @@
{
enet_host_destroy(this->host_);
}
-
+
void LANDiscovery::discover()
{
this->servers_.clear();
ENetAddress address;
enet_address_set_host(&address, "255.255.255.255");
address.port = LAN_DISCOVERY_PORT;
-
+
ENetPeer* peer;
peer = enet_host_connect(this->host_, &address, 0);
-
+
ENetEvent event;
while( enet_host_service(this->host_, &event, 1000 ) )
{
@@ -92,7 +92,7 @@
}
}
}
-
+
std::string LANDiscovery::getServerListItemName(unsigned int index)
{
if( index >= this->servers_.size() )
@@ -100,7 +100,7 @@
else
return this->servers_[index].getServerName();
}
-
+
std::string LANDiscovery::getServerListItemIP(unsigned int index)
{
if( index >= this->servers_.size() )
@@ -108,6 +108,6 @@
else
return this->servers_[index].getServerIP();
}
-
-
+
+
} // namespace orxonox
Modified: code/branches/consolecommands3/src/libraries/util/CMakeLists.txt
===================================================================
--- code/branches/consolecommands3/src/libraries/util/CMakeLists.txt 2010-08-23 09:43:10 UTC (rev 7206)
+++ code/branches/consolecommands3/src/libraries/util/CMakeLists.txt 2010-08-23 16:50:22 UTC (rev 7207)
@@ -30,6 +30,7 @@
CRC32.cc
ExprParser.cc
OutputHandler.cc
+ ScopedSingletonManager.cc
SignalHandler.cc
Sleep.cc
SubString.cc
Copied: code/branches/consolecommands3/src/libraries/util/ScopedSingletonManager.cc (from rev 7203, code/branches/consolecommands3/src/libraries/core/ScopedSingletonManager.cc)
===================================================================
--- code/branches/consolecommands3/src/libraries/util/ScopedSingletonManager.cc (rev 0)
+++ code/branches/consolecommands3/src/libraries/util/ScopedSingletonManager.cc 2010-08-23 16:50:22 UTC (rev 7207)
@@ -0,0 +1,49 @@
+/*
+ * 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));
+ }
+}
Copied: code/branches/consolecommands3/src/libraries/util/ScopedSingletonManager.h (from rev 7203, code/branches/consolecommands3/src/libraries/core/ScopedSingletonManager.h)
===================================================================
--- code/branches/consolecommands3/src/libraries/util/ScopedSingletonManager.h (rev 0)
+++ code/branches/consolecommands3/src/libraries/util/ScopedSingletonManager.h 2010-08-23 16:50:22 UTC (rev 7207)
@@ -0,0 +1,214 @@
+/*
+ * 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 "UtilPrereqs.h"
+
+#include <cassert>
+#include <map>
+#include "util/Exception.h"
+#include "util/Scope.h"
+#include "util/Singleton.h"
+
+#define ManageScopedSingleton(className, scope, allowedToFail) \
+ className* className::singletonPtr_s = NULL; \
+ static ClassScopedSingletonManager<className, scope, allowedToFail> className##ScopedSingletonManager(#className)
+
+namespace orxonox
+{
+ class OrxonoxClass;
+
+ class _UtilExport ScopedSingletonManager
+ {
+ public:
+ ScopedSingletonManager(const std::string& className, ScopeID::Value scope)
+ : className_(className)
+ , scope_(scope)
+ { }
+ virtual ~ScopedSingletonManager() { }
+ static void addManager(ScopedSingletonManager* manager);
+
+ template<ScopeID::Value scope>
+ static void preUpdate(const Clock& time)
+ {
+ assert(Scope<scope>::isActive());
+ for (ManagerMultiMap::iterator it = getManagersByScope().lower_bound(scope); it != getManagersByScope().upper_bound(scope); ++it)
+ it->second->preUpdate(time);
+ }
+ virtual void preUpdate(const Clock& time) = 0;
+ template<ScopeID::Value scope>
+ static void postUpdate(const Clock& time)
+ {
+ assert(Scope<scope>::isActive());
+ for (ManagerMultiMap::iterator it = getManagersByScope().lower_bound(scope); it != getManagersByScope().upper_bound(scope); ++it)
+ it->second->postUpdate(time);
+ }
+ virtual void postUpdate(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, bool allowedToFail>
+ class ClassScopedSingletonManager : public ScopedSingletonManager, public ScopeListener
+ {
+ public:
+ ClassScopedSingletonManager(const std::string& className)
+ : ScopedSingletonManager(className, scope)
+ , ScopeListener(scope)
+ , singletonPtr_(NULL)
+ {
+ ScopedSingletonManager::addManager(this);
+ }
+
+ ~ClassScopedSingletonManager()
+ {
+ }
+
+ //! 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*)
+ {
+ singletonPtr_->destroy();
+ }
+ void destroy(void*)
+ {
+ delete singletonPtr_;
+ }
+
+ //! Called every frame by the ScopedSingletonManager
+ void preUpdate(const Clock& time)
+ {
+ assert(Scope<scope>::isActive());
+ // assuming T inherits Singleton<T>
+ singletonPtr_->preUpdateSingleton(time);
+ }
+
+ //! Called every frame by the ScopedSingletonManager
+ void postUpdate(const Clock& time)
+ {
+ assert(Scope<scope>::isActive());
+ // assuming T inherits Singleton<T>
+ singletonPtr_->postUpdateSingleton(time);
+ }
+
+ private:
+ T* singletonPtr_;
+ };
+
+ template <class T, ScopeID::Value scope>
+ class ClassScopedSingletonManager<T, scope, true> : public ScopedSingletonManager, public ScopeListener
+ {
+ public:
+ ClassScopedSingletonManager(const std::string& className)
+ : ScopedSingletonManager(className, scope)
+ , ScopeListener(scope)
+ , singletonPtr_(NULL)
+ {
+ ScopedSingletonManager::addManager(this);
+ }
+
+ ~ClassScopedSingletonManager()
+ {
+ }
+
+ //! Called if the Scope of the Singleton gets active (creates the instance)
+ void activated()
+ {
+ assert(singletonPtr_ == NULL);
+ try
+ { singletonPtr_ = new T(); }
+ catch (const InitialisationAbortedException& ex)
+ { COUT(3) << ex.getDescription() << std::endl; }
+ catch (...)
+ { COUT(1) << "Singleton creation failed: " << Exception::handleMessage() << std::endl; }
+ }
+
+ //! Called if the Scope of this Singleton gets deactivated (destroys the instance)
+ void deactivated()
+ {
+ if (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 preUpdate(const Clock& time)
+ {
+ assert(Scope<scope>::isActive());
+ // assuming T inherits Singleton<T>
+ if (singletonPtr_ != NULL)
+ singletonPtr_->preUpdateSingleton(time);
+ }
+
+ //! Called every frame by the ScopedSingletonManager
+ void postUpdate(const Clock& time)
+ {
+ assert(Scope<scope>::isActive());
+ // assuming T inherits Singleton<T>
+ if (singletonPtr_ != NULL)
+ singletonPtr_->postUpdateSingleton(time);
+ }
+
+ private:
+ T* singletonPtr_;
+ };
+}
+
+#endif /* __ScopedSingletonManager_H__ */
Modified: code/branches/consolecommands3/src/modules/designtools/ScreenshotManager.cc
===================================================================
--- code/branches/consolecommands3/src/modules/designtools/ScreenshotManager.cc 2010-08-23 09:43:10 UTC (rev 7206)
+++ code/branches/consolecommands3/src/modules/designtools/ScreenshotManager.cc 2010-08-23 16:50:22 UTC (rev 7207)
@@ -8,9 +8,9 @@
#include <OgreCamera.h>
#include <OgreRoot.h>
+#include "util/ScopedSingletonManager.h"
#include "core/GraphicsManager.h"
#include "core/PathConfig.h"
-#include "core/ScopedSingletonManager.h"
#include "core/command/ConsoleCommand.h"
#include "CameraManager.h"
Modified: code/branches/consolecommands3/src/modules/designtools/SkyboxGenerator.cc
===================================================================
--- code/branches/consolecommands3/src/modules/designtools/SkyboxGenerator.cc 2010-08-23 09:43:10 UTC (rev 7206)
+++ code/branches/consolecommands3/src/modules/designtools/SkyboxGenerator.cc 2010-08-23 16:50:22 UTC (rev 7207)
@@ -33,10 +33,10 @@
#include <OgreRenderWindow.h>
#include <OgreCamera.h>
+#include "util/ScopedSingletonManager.h"
#include "core/CoreIncludes.h"
#include "core/ConfigValueIncludes.h"
#include "core/GraphicsManager.h"
-#include "core/ScopedSingletonManager.h"
#include "core/command/ConsoleCommand.h"
#include "core/command/CommandExecutor.h"
#include "controllers/HumanController.h"
Modified: code/branches/consolecommands3/src/modules/notifications/NotificationManager.cc
===================================================================
--- code/branches/consolecommands3/src/modules/notifications/NotificationManager.cc 2010-08-23 09:43:10 UTC (rev 7206)
+++ code/branches/consolecommands3/src/modules/notifications/NotificationManager.cc 2010-08-23 16:50:22 UTC (rev 7207)
@@ -35,8 +35,8 @@
#include <set>
+#include "util/ScopedSingletonManager.h"
#include "core/CoreIncludes.h"
-#include "core/ScopedSingletonManager.h"
#include "Notification.h"
#include "interfaces/NotificationListener.h"
Modified: code/branches/consolecommands3/src/modules/pickup/PickupManager.cc
===================================================================
--- code/branches/consolecommands3/src/modules/pickup/PickupManager.cc 2010-08-23 09:43:10 UTC (rev 7206)
+++ code/branches/consolecommands3/src/modules/pickup/PickupManager.cc 2010-08-23 16:50:22 UTC (rev 7207)
@@ -33,12 +33,12 @@
#include "PickupManager.h"
+#include "util/Convert.h"
+#include "util/ScopedSingletonManager.h"
#include "core/CoreIncludes.h"
#include "core/LuaState.h"
#include "core/GUIManager.h"
-#include "core/ScopedSingletonManager.h"
#include "core/Identifier.h"
-#include "util/Convert.h"
#include "interfaces/PickupCarrier.h"
#include "infos/PlayerInfo.h"
#include "worldentities/pawns/Pawn.h"
Modified: code/branches/consolecommands3/src/modules/questsystem/QuestManager.cc
===================================================================
--- code/branches/consolecommands3/src/modules/questsystem/QuestManager.cc 2010-08-23 09:43:10 UTC (rev 7206)
+++ code/branches/consolecommands3/src/modules/questsystem/QuestManager.cc 2010-08-23 16:50:22 UTC (rev 7207)
@@ -36,10 +36,10 @@
#include <CEGUIWindow.h>
#include "util/Exception.h"
+#include "util/ScopedSingletonManager.h"
#include "core/CoreIncludes.h"
#include "core/GUIManager.h"
#include "core/LuaState.h"
-#include "core/ScopedSingletonManager.h"
#include "core/command/ConsoleCommand.h"
#include "infos/PlayerInfo.h"
#include "overlays/GUIOverlay.h"
Modified: code/branches/consolecommands3/src/orxonox/CameraManager.cc
===================================================================
--- code/branches/consolecommands3/src/orxonox/CameraManager.cc 2010-08-23 09:43:10 UTC (rev 7206)
+++ code/branches/consolecommands3/src/orxonox/CameraManager.cc 2010-08-23 16:50:22 UTC (rev 7207)
@@ -33,11 +33,11 @@
#include <OgreCompositorManager.h>
#include "util/StringUtils.h"
+#include "util/ScopedSingletonManager.h"
#include "core/GameMode.h"
#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"
Modified: code/branches/consolecommands3/src/orxonox/ChatHistory.cc
===================================================================
--- code/branches/consolecommands3/src/orxonox/ChatHistory.cc 2010-08-23 09:43:10 UTC (rev 7206)
+++ code/branches/consolecommands3/src/orxonox/ChatHistory.cc 2010-08-23 16:50:22 UTC (rev 7207)
@@ -27,7 +27,7 @@
*/
#include "ChatHistory.h"
-#include <core/ScopedSingletonManager.h>
+#include "util/ScopedSingletonManager.h"
#ifndef CHATTEST
namespace orxonox
Modified: code/branches/consolecommands3/src/orxonox/ChatInputHandler.cc
===================================================================
--- code/branches/consolecommands3/src/orxonox/ChatInputHandler.cc 2010-08-23 09:43:10 UTC (rev 7206)
+++ code/branches/consolecommands3/src/orxonox/ChatInputHandler.cc 2010-08-23 16:50:22 UTC (rev 7207)
@@ -27,7 +27,7 @@
*/
#include "ChatInputHandler.h"
-#include <core/ScopedSingletonManager.h>
+#include "util/ScopedSingletonManager.h"
#include "core/CoreIncludes.h"
#include "core/GUIManager.h"
#include "core/CorePrereqs.h"
Modified: code/branches/consolecommands3/src/orxonox/LevelManager.cc
===================================================================
--- code/branches/consolecommands3/src/orxonox/LevelManager.cc 2010-08-23 09:43:10 UTC (rev 7206)
+++ code/branches/consolecommands3/src/orxonox/LevelManager.cc 2010-08-23 16:50:22 UTC (rev 7207)
@@ -30,12 +30,12 @@
#include <map>
+#include "util/ScopedSingletonManager.h"
#include "core/CommandLineParser.h"
#include "core/ConfigValueIncludes.h"
#include "core/CoreIncludes.h"
#include "core/Loader.h"
#include "core/Resource.h"
-#include "core/ScopedSingletonManager.h"
#include "PlayerManager.h"
#include "Level.h"
Modified: code/branches/consolecommands3/src/orxonox/MoodManager.cc
===================================================================
--- code/branches/consolecommands3/src/orxonox/MoodManager.cc 2010-08-23 09:43:10 UTC (rev 7206)
+++ code/branches/consolecommands3/src/orxonox/MoodManager.cc 2010-08-23 16:50:22 UTC (rev 7207)
@@ -28,9 +28,9 @@
#include "MoodManager.h"
+#include "util/ScopedSingletonManager.h"
#include "core/ConfigValueIncludes.h"
#include "core/CoreIncludes.h"
-#include "core/ScopedSingletonManager.h"
#include "core/Resource.h"
namespace orxonox
@@ -47,7 +47,7 @@
// Need to use a variable to store old data because ResetConfigValues() doesn't seem to work.
oldMood_ = MoodManager::defaultMood_;
-
+
// Checking for the existence of the folder for the default mood
const std::string& path = "ambient/" + MoodManager::defaultMood_ + "/.";
if (!Resource::exists(path))
Modified: code/branches/consolecommands3/src/orxonox/PlayerManager.cc
===================================================================
--- code/branches/consolecommands3/src/orxonox/PlayerManager.cc 2010-08-23 09:43:10 UTC (rev 7206)
+++ code/branches/consolecommands3/src/orxonox/PlayerManager.cc 2010-08-23 16:50:22 UTC (rev 7207)
@@ -28,9 +28,9 @@
#include "PlayerManager.h"
+#include "util/ScopedSingletonManager.h"
#include "core/CoreIncludes.h"
#include "core/GameMode.h"
-#include "core/ScopedSingletonManager.h"
#include "Level.h"
#include "infos/HumanPlayer.h"
#include "LevelManager.h"
Modified: code/branches/consolecommands3/src/orxonox/overlays/InGameConsole.cc
===================================================================
--- code/branches/consolecommands3/src/orxonox/overlays/InGameConsole.cc 2010-08-23 09:43:10 UTC (rev 7206)
+++ code/branches/consolecommands3/src/orxonox/overlays/InGameConsole.cc 2010-08-23 16:50:22 UTC (rev 7207)
@@ -44,9 +44,9 @@
#include "util/Convert.h"
#include "util/Math.h"
#include "util/DisplayStringConversions.h"
+#include "util/ScopedSingletonManager.h"
#include "core/CoreIncludes.h"
#include "core/ConfigValueIncludes.h"
-#include "core/ScopedSingletonManager.h"
#include "core/command/ConsoleCommand.h"
#include "core/input/InputManager.h"
#include "core/input/InputState.h"
Modified: code/branches/consolecommands3/src/orxonox/sound/SoundManager.cc
===================================================================
--- code/branches/consolecommands3/src/orxonox/sound/SoundManager.cc 2010-08-23 09:43:10 UTC (rev 7206)
+++ code/branches/consolecommands3/src/orxonox/sound/SoundManager.cc 2010-08-23 16:50:22 UTC (rev 7207)
@@ -37,10 +37,10 @@
#include "util/Math.h"
#include "util/ScopeGuard.h"
#include "util/Clock.h"
+#include "util/ScopedSingletonManager.h"
#include "core/ConfigValueIncludes.h"
#include "core/CoreIncludes.h"
#include "core/GameMode.h"
-#include "core/ScopedSingletonManager.h"
#include "core/Resource.h"
#include "SoundBuffer.h"
#include "BaseSound.h"
More information about the Orxonox-commit
mailing list