Changeset 5850 for code/branches/core5/src
- Timestamp:
- Oct 1, 2009, 11:44:53 AM (15 years ago)
- Location:
- code/branches/core5/src
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core5/src/libraries/core/Core.cc
r5838 r5850 264 264 // create a shell 265 265 this->shell_.reset(new Shell()); 266 267 // Create singletons that always exist (in other libraries) 268 this->rootScope_.reset(new Scope<ScopeID::Root>()); 266 269 } 267 270 … … 289 292 inputManager_->getMousePosition(), graphicsManager_->isFullScreen())); 290 293 294 // Create singletons associated with graphics (in other libraries) 295 graphicsScope_.reset(new Scope<ScopeID::Graphics>()); 296 291 297 unloader.Dismiss(); 292 298 … … 296 302 void Core::unloadGraphics() 297 303 { 298 this->guiManager_.reset();; 299 this->inputManager_.reset();; 304 this->graphicsScope_.reset(); 305 this->guiManager_.reset(); 306 this->inputManager_.reset(); 300 307 this->graphicsManager_.reset(); 301 308 … … 420 427 void Core::preUpdate(const Clock& time) 421 428 { 429 // singletons from other libraries 430 Scope<ScopeID::Root>::update(time); 422 431 if (this->bGraphicsLoaded_) 423 432 { … … 426 435 // process gui events 427 436 this->guiManager_->update(time); 437 // graphics singletons from other libraries 438 Scope<ScopeID::Graphics>::update(time); 428 439 } 429 440 // process thread commands -
code/branches/core5/src/libraries/core/Core.h
r5836 r5850 36 36 #include <boost/scoped_ptr.hpp> 37 37 #include "util/OutputHandler.h" 38 #include "util/Scope.h" 38 39 #include "util/ScopeGuard.h" 39 40 #include "util/Singleton.h" … … 100 101 scoped_ptr<InputManager> inputManager_; //!< Interface to OIS 101 102 scoped_ptr<GUIManager> guiManager_; //!< Interface to GUI 103 scoped_ptr<Scope<ScopeID::Root> > rootScope_; 104 scoped_ptr<Scope<ScopeID::Graphics> > graphicsScope_; 102 105 103 106 bool bGraphicsLoaded_; -
code/branches/core5/src/libraries/util/Scope.h
r5738 r5850 31 31 32 32 #include "UtilPrereqs.h" 33 33 34 #include <cassert> 35 #include <map> 34 36 #include <set> 35 #include <map>36 37 #include "Debug.h" 37 38 … … 45 46 enum Value 46 47 { 47 GSRoot, 48 GSGraphics, 49 GSLevel 48 Root, 49 Graphics 50 50 }; 51 51 } 52 52 53 class ScopeListener; // Forward declaration 53 // Forward declarations 54 class ScopeListener; 55 class Clock; 54 56 55 57 /** … … 87 89 //! Gets called if the scope is deactivated 88 90 virtual void deactivated() = 0; 91 //! Gets called if the scope is updated 92 virtual void updated(const Clock& time) = 0; 89 93 90 94 private: … … 136 140 return (ScopeManager::instanceCounts_s[scope] > 0); 137 141 } 142 143 //! Update method for the ScopeListeners (to implement singleton updates) 144 static void update(const Clock& time) 145 { 146 if (isActive()) 147 { 148 for (typename std::set<ScopeListener*>::iterator it = ScopeManager::listeners_s[scope].begin(); it != ScopeManager::listeners_s[scope].end(); ) 149 (*(it++))->updated(time); 150 } 151 } 138 152 }; 139 153 } -
code/branches/core5/src/libraries/util/ScopedSingleton.h
r5802 r5850 37 37 namespace orxonox 38 38 { 39 class Clock; 39 40 /** 40 41 @brief … … 59 60 assert(Scope<scope>::isActive()); 60 61 61 if (!T::singletonPtr_s && Scope<scope>::isActive())62 if (!T::singletonPtr_s) 62 63 T::singletonPtr_s = new T(); 63 64 64 65 return *T::singletonPtr_s; 65 66 } 67 68 //! Update method for singletons like the ingame console 69 virtual void updated(const Clock& time) { static_cast<T*>(this)->update(time); } 70 //! Empty update method for the static polymorphism 71 void update(const Clock& time) { } 66 72 67 73 protected: … … 85 91 { 86 92 // The ScopedSingleton shouldn't be active bevor the scope is activated -> always assertion failed 87 assert( T::singletonPtr_s == 0 &&false);93 assert(false); 88 94 } 89 95 -
code/branches/core5/src/modules/questsystem/QuestManager.h
r5760 r5850 50 50 namespace orxonox 51 51 { 52 53 typedef ScopedSingleton<QuestManager, ScopeID::GSLevel> ScopedSingletonQuestManagerGSLevel; // workaround for tolua54 55 52 /** 56 53 @brief … … 60 57 Damian 'Mozork' Frick 61 58 */ 62 class _QuestsystemExport QuestManager : public ScopedSingletonQuestManagerGSLevel, public orxonox::OrxonoxClass 63 { 59 class _QuestsystemExport QuestManager 64 60 // tolua_end 61 : public ScopedSingleton<QuestManager, ScopeID::Root>, public orxonox::OrxonoxClass 62 { // tolua_export 65 63 66 friend class ScopedSingleton<QuestManager, ScopeID:: GSLevel>;64 friend class ScopedSingleton<QuestManager, ScopeID::Root>; 67 65 friend class QuestGUI; 68 66 … … 72 70 73 71 //! Returns a reference to the single instance of the Quest Manager. 74 static QuestManager& getInstance() { return ScopedSingleton<QuestManager, ScopeID:: GSLevel>::getInstance(); } // tolua_export72 static QuestManager& getInstance() { return ScopedSingleton<QuestManager, ScopeID::Root>::getInstance(); } // tolua_export 75 73 76 74 //! Retreive the main window for the GUI. -
code/branches/core5/src/modules/questsystem/notifications/NotificationManager.h
r5738 r5850 46 46 namespace orxonox 47 47 { 48 49 48 /** 50 49 @brief … … 54 53 Damian 'Mozork' Frick 55 54 */ 56 class _QuestsystemExport NotificationManager : public ScopedSingleton<NotificationManager, ScopeID:: GSLevel>, public OrxonoxClass55 class _QuestsystemExport NotificationManager : public ScopedSingleton<NotificationManager, ScopeID::Root>, public OrxonoxClass 57 56 { 58 friend class ScopedSingleton<NotificationManager, ScopeID:: GSLevel>;57 friend class ScopedSingleton<NotificationManager, ScopeID::Root>; 59 58 public: 60 59 NotificationManager(); -
code/branches/core5/src/orxonox/CameraManager.cc
r5805 r5850 34 34 #include "util/StringUtils.h" 35 35 #include "core/GameMode.h" 36 #include "core/GraphicsManager.h" 36 37 #include "core/GUIManager.h" 37 38 #include "core/ObjectList.h" … … 44 45 CameraManager* CameraManager::singletonPtr_s = 0; 45 46 46 CameraManager::CameraManager( Ogre::Viewport* viewport)47 : viewport_( viewport)47 CameraManager::CameraManager() 48 : viewport_(GraphicsManager::getInstance().getViewport()) 48 49 { 49 50 this->fallbackCamera_ = 0; -
code/branches/core5/src/orxonox/CameraManager.h
r5805 r5850 41 41 #include <list> 42 42 #include "util/OgreForwardRefs.h" 43 #include "util/Singleton.h" 43 #include "util/ScopedSingleton.h" 44 #include "core/OrxonoxClass.h" 44 45 #include "core/SmartPtr.h" 45 46 46 47 namespace orxonox 47 48 { 48 class _OrxonoxExport CameraManager : public S ingleton<CameraManager>49 class _OrxonoxExport CameraManager : public ScopedSingleton<CameraManager, ScopeID::Graphics>, public OrxonoxClass 49 50 { 50 friend class S ingleton<CameraManager>;51 friend class ScopedSingleton<CameraManager, ScopeID::Graphics>; 51 52 public: 52 CameraManager( Ogre::Viewport* viewport);53 CameraManager(); 53 54 ~CameraManager(); 54 55 -
code/branches/core5/src/orxonox/LevelManager.h
r3370 r5850 36 36 #include <string> 37 37 38 #include "util/S ingleton.h"38 #include "util/ScopedSingleton.h" 39 39 #include "core/OrxonoxClass.h" 40 40 … … 44 44 class _OrxonoxExport LevelManager 45 45 // tolua_end 46 : public S ingleton<LevelManager>, public OrxonoxClass46 : public ScopedSingleton<LevelManager, ScopeID::Root>, public OrxonoxClass 47 47 { // tolua_export 48 friend class S ingleton<LevelManager>;48 friend class ScopedSingleton<LevelManager, ScopeID::Root>; 49 49 public: 50 50 LevelManager(); … … 63 63 64 64 static LevelManager* getInstancePtr() { return singletonPtr_s; } 65 static LevelManager& getInstance() { return S ingleton<LevelManager>::getInstance(); } // tolua_export65 static LevelManager& getInstance() { return ScopedSingleton<LevelManager, ScopeID::Root>::getInstance(); } // tolua_export 66 66 67 67 private: -
code/branches/core5/src/orxonox/PlayerManager.h
r5820 r5850 34 34 #include <cassert> 35 35 #include <map> 36 #include "util/S ingleton.h"36 #include "util/ScopedSingleton.h" 37 37 #include "network/ClientConnectionListener.h" 38 38 39 39 namespace orxonox 40 40 { 41 class _OrxonoxExport PlayerManager : public S ingleton<PlayerManager>, public ClientConnectionListener41 class _OrxonoxExport PlayerManager : public ScopedSingleton<PlayerManager, ScopeID::Root>, public ClientConnectionListener 42 42 { 43 friend class S ingleton<PlayerManager>;43 friend class ScopedSingleton<PlayerManager, ScopeID::Root>; 44 44 public: 45 45 PlayerManager(); -
code/branches/core5/src/orxonox/gamestates/GSGraphics.cc
r5842 r5850 46 46 #include "core/Loader.h" 47 47 #include "core/XMLFile.h" 48 #include "overlays/InGameConsole.h"49 #include "sound/SoundManager.h"50 48 51 49 // HACK: … … 58 56 GSGraphics::GSGraphics(const GameStateInfo& info) 59 57 : GameState(info) 60 , console_(0)61 , soundManager_(0)62 58 , masterKeyBinder_(0) 63 59 , masterInputState_(0) … … 100 96 masterKeyBinder_->loadBindings("masterKeybindings.ini"); 101 97 102 // Load the SoundManager103 soundManager_ = new SoundManager();104 105 // Load the InGameConsole106 console_ = new InGameConsole();107 console_->initialise();108 109 98 // add console command to toggle GUI 110 99 this->ccToggleGUI_ = createConsoleCommand(createFunctor(&GSGraphics::toggleGUI, this), "toggleGUI"); … … 131 120 */ 132 121 133 this->console_->destroy();134 135 122 Loader::unload(this->debugOverlay_); 136 123 delete this->debugOverlay_; 137 138 this->soundManager_->destroy();139 124 140 125 // HACK: (destroys a resource smart pointer) … … 170 155 Game::getInstance().requestState("mainMenu"); 171 156 } 172 173 this->console_->update(time);174 157 } 175 158 } -
code/branches/core5/src/orxonox/gamestates/GSGraphics.h
r5842 r5850 60 60 61 61 private: 62 // managed singletons63 InGameConsole* console_;64 SoundManager* soundManager_; //!< Keeps track of SoundBase objects65 66 62 KeyBinder* masterKeyBinder_; //!< Key binder for master key bindings 67 63 InputState* masterInputState_; //!< Special input state for master input -
code/branches/core5/src/orxonox/gamestates/GSLevel.cc
r5842 r5850 41 41 #include "core/Game.h" 42 42 #include "core/GameMode.h" 43 #include "core/GraphicsManager.h"44 43 #include "core/GUIManager.h" 45 44 #include "core/Loader.h" 46 45 #include "core/XMLFile.h" 47 46 48 #include "tools/interfaces/Tickable.h"49 #include "CameraManager.h"50 47 #include "LevelManager.h" 51 48 #include "PlayerManager.h" 52 #include "infos/HumanPlayer.h"53 49 54 50 namespace orxonox … … 65 61 , guiMouseOnlyInputState_(0) 66 62 , guiKeysOnlyInputState_(0) 67 , cameraManager_(0)68 63 { 69 64 RegisterObject(GSLevel); … … 98 93 guiKeysOnlyInputState_ = InputManager::getInstance().createInputState("guiKeysOnly"); 99 94 guiKeysOnlyInputState_->setKeyHandler(GUIManager::getInstancePtr()); 100 101 // create the global CameraManager 102 this->cameraManager_ = new CameraManager(GraphicsManager::getInstance().getViewport()); 103 } 104 105 this->playerManager_ = new PlayerManager(); 106 107 this->scope_GSLevel_ = new Scope<ScopeID::GSLevel>(); 95 } 108 96 109 97 if (GameMode::isMaster()) … … 126 114 127 115 // connect the HumanPlayer to the game 128 this->playerManager_->clientConnected(0);116 PlayerManager::getInstance().clientConnected(0); 129 117 } 130 118 } … … 165 153 { 166 154 // disconnect the HumanPlayer 167 this->playerManager_->clientDisconnected(0);155 PlayerManager::getInstance().clientDisconnected(0); 168 156 169 157 // unload all compositors (this is only necessary because we don't yet destroy all resources!) … … 184 172 if (GameMode::isMaster()) 185 173 this->unloadLevel(); 186 187 if (this->cameraManager_)188 {189 delete this->cameraManager_;190 this->cameraManager_ = 0;191 }192 193 if (this->playerManager_)194 {195 this->playerManager_->destroy();196 this->playerManager_ = 0;197 }198 199 if (this->scope_GSLevel_)200 {201 delete this->scope_GSLevel_;202 this->scope_GSLevel_ = NULL;203 }204 174 205 175 if (GameMode::showsGraphics()) -
code/branches/core5/src/orxonox/gamestates/GSLevel.h
r5842 r5850 33 33 34 34 #include <string> 35 #include "util/Scope.h"36 35 #include "core/OrxonoxClass.h" 37 36 #include "core/GameState.h" … … 67 66 InputState* guiMouseOnlyInputState_; //!< input state if we only need the mouse to use the GUI 68 67 InputState* guiKeysOnlyInputState_; //!< input state if we only need the keys to use the GUI 69 CameraManager* cameraManager_; //!< camera manager for this level70 PlayerManager* playerManager_; //!< player manager for this level71 Scope<ScopeID::GSLevel>* scope_GSLevel_;72 68 73 69 //##### ConfigValues ##### -
code/branches/core5/src/orxonox/gamestates/GSRoot.cc
r5831 r5850 37 37 #include "tools/interfaces/TimeFactorListener.h" 38 38 #include "tools/interfaces/Tickable.h" 39 #include "LevelManager.h"40 39 41 40 namespace orxonox … … 70 69 this->ccPause_ = createConsoleCommand(createFunctor(&GSRoot::pause, this), "pause"); 71 70 CommandExecutor::addConsoleCommandShortcut(this->ccPause_).accessLevel(AccessLevel::Offline); 72 73 // create the LevelManager74 this->levelManager_ = new LevelManager();75 71 } 76 72 … … 90 86 } 91 87 */ 92 93 this->levelManager_->destroy();94 88 } 95 89 -
code/branches/core5/src/orxonox/gamestates/GSRoot.h
r5842 r5850 56 56 float timeFactorPauseBackup_; 57 57 58 LevelManager* levelManager_; //!< global level manager59 60 58 // console commands 61 59 ConsoleCommand* ccSetTimeFactor_; -
code/branches/core5/src/orxonox/overlays/InGameConsole.cc
r5738 r5850 85 85 86 86 this->setConfigValues(); 87 this->initialise(); 87 88 } 88 89 -
code/branches/core5/src/orxonox/overlays/InGameConsole.h
r5791 r5850 36 36 37 37 #include "util/OgreForwardRefs.h" 38 #include "util/S ingleton.h"38 #include "util/ScopedSingleton.h" 39 39 #include "core/Shell.h" 40 40 #include "core/WindowEventListener.h" … … 42 42 namespace orxonox 43 43 { 44 class _OrxonoxExport InGameConsole : public S ingleton<InGameConsole>, public ShellListener, public WindowEventListener44 class _OrxonoxExport InGameConsole : public ScopedSingleton<InGameConsole, ScopeID::Graphics>, public ShellListener, public WindowEventListener 45 45 { 46 friend class S ingleton<InGameConsole>;46 friend class ScopedSingleton<InGameConsole, ScopeID::Graphics>; 47 47 public: // functions 48 48 InGameConsole(); -
code/branches/core5/src/orxonox/sound/SoundManager.h
r5693 r5850 32 32 #include <cassert> 33 33 #include <list> 34 #include "util/S ingleton.h"34 #include "util/ScopedSingleton.h" 35 35 #include "tools/interfaces/Tickable.h" 36 36 … … 43 43 * 44 44 */ 45 class _OrxonoxExport SoundManager : public S ingleton<SoundManager>, public Tickable45 class _OrxonoxExport SoundManager : public ScopedSingleton<SoundManager, ScopeID::Graphics>, public Tickable 46 46 { 47 friend class S ingleton<SoundManager>;47 friend class ScopedSingleton<SoundManager, ScopeID::Graphics>; 48 48 public: 49 49 SoundManager();
Note: See TracChangeset
for help on using the changeset viewer.