Changeset 10542 for code/branches/core7/src/libraries/core
- Timestamp:
- Jun 7, 2015, 2:16:55 PM (10 years ago)
- Location:
- code/branches/core7/src/libraries/core
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core7/src/libraries/core/Core.cc
r10540 r10542 58 58 #include "util/output/OutputManager.h" 59 59 #include "core/singleton/Scope.h" 60 #include "core/singleton/ScopedSingletonIncludes.h"61 60 #include "ApplicationPaths.h" 62 61 #include "ConfigurablePaths.h" … … 66 65 #include "GraphicsManager.h" 67 66 #include "GUIManager.h" 68 #include "class/Identifier.h"69 67 #include "Language.h" 70 68 #include "Loader.h" 71 69 #include "LuaState.h" 72 #include "command/ConsoleCommandManager.h"73 70 #include "command/IOConsole.h" 74 71 #include "command/TclBind.h" … … 127 124 128 125 // TODO: initialize Root-Context 129 // TODO: initialize IdentifierManager here 130 // TODO: initialize ScopeManager here 131 // TODO: initialize CommandLineParser here 132 // TODO: initialize ConsoleCommandManager here 133 // TODO: initialize NetworkFunctionManager here 134 // TODO: initialize StaticInitializationManager 126 new StaticInitializationManager(); // create singleton 135 127 this->staticInitHandler_ = new CoreStaticInitializationHandler(); 136 128 StaticInitializationManager::getInstance().addHandler(this->staticInitHandler_); … … 262 254 safeObjectDelete(&rootModule_); 263 255 safeObjectDelete(&staticInitHandler_); 256 delete &StaticInitializationManager::getInstance(); 264 257 safeObjectDelete(&dynLibManager_); 265 258 safeObjectDelete(&configurablePaths_); -
code/branches/core7/src/libraries/core/CoreStaticInitializationHandler.cc
r10539 r10542 31 31 #include "CoreIncludes.h" 32 32 #include "module/ModuleInstance.h" 33 #include "object/Iterator.h" 33 34 #include "class/IdentifierManager.h" 34 #include "object/Iterator.h" 35 #include "singleton/ScopeManager.h" 36 #include "command/ConsoleCommandManager.h" 37 #include "commandline/CommandLineParser.h" 35 38 36 39 namespace orxonox … … 38 41 void CoreStaticInitializationHandler::setupHandler() 39 42 { 40 // TODO 43 // initialize singletons 44 new IdentifierManager(); 45 new ScopeManager(); 46 new CommandLineParser(); 47 new ConsoleCommandManager(); 41 48 } 42 49 43 50 void CoreStaticInitializationHandler::shutdownHandler() 44 51 { 45 // TODO 52 delete &ConsoleCommandManager::getInstance(); 53 delete &CommandLineParser::getInstance(); 54 delete &ScopeManager::getInstance(); 55 delete &IdentifierManager::getInstance(); 46 56 } 47 57 -
code/branches/core7/src/libraries/core/class/IdentifierManager.cc
r10520 r10542 44 44 namespace orxonox 45 45 { 46 /* static */ IdentifierManager& IdentifierManager::getInstance() 47 { 48 static IdentifierManager instance; 49 return instance; 50 } 46 IdentifierManager* IdentifierManager::singletonPtr_s = 0; 51 47 52 48 IdentifierManager::IdentifierManager() -
code/branches/core7/src/libraries/core/class/IdentifierManager.h
r10520 r10542 42 42 #include <string> 43 43 44 #include "util/Singleton.h" 45 44 46 namespace orxonox 45 47 { 46 class _CoreExport IdentifierManager 48 class _CoreExport IdentifierManager : public Singleton<IdentifierManager> 47 49 { 50 friend class Singleton<IdentifierManager>; 51 48 52 public: 49 static IdentifierManager& getInstance(); 53 IdentifierManager(); 54 ~IdentifierManager() {} 50 55 51 56 void addIdentifier(Identifier* identifier); … … 88 93 89 94 private: 90 IdentifierManager(); 91 IdentifierManager(const IdentifierManager&); 92 ~IdentifierManager() {} 95 IdentifierManager(const IdentifierManager&); // not implemented 93 96 94 97 /// Increases the hierarchyCreatingCounter_s variable, causing all new objects to store their parents. … … 110 113 std::map<Identifiable*, std::list<const Identifier*> > identifierTraceOfNewObject_; 111 114 Identifier* recordTraceForIdentifier_; //!< The identifier for which we want to record the trace of identifiers during object creation. If null, no trace is recorded. 115 116 static IdentifierManager* singletonPtr_s; 112 117 }; 113 118 } -
code/branches/core7/src/libraries/core/command/ConsoleCommandManager.cc
r10520 r10542 39 39 namespace orxonox 40 40 { 41 /* static */ ConsoleCommandManager& ConsoleCommandManager::getInstance() 42 { 43 static ConsoleCommandManager instance; 44 return instance; 45 } 41 ConsoleCommandManager* ConsoleCommandManager::singletonPtr_s = 0; 46 42 47 43 /** -
code/branches/core7/src/libraries/core/command/ConsoleCommandManager.h
r10520 r10542 37 37 #include "core/CorePrereqs.h" 38 38 39 #include "util/Singleton.h" 40 39 41 namespace orxonox 40 42 { … … 42 44 * A singleton that stores all existing ConsoleCommands. 43 45 */ 44 class _CoreExport ConsoleCommandManager 46 class _CoreExport ConsoleCommandManager : public Singleton<ConsoleCommandManager> 45 47 { 48 friend class Singleton<ConsoleCommandManager>; 49 46 50 public: 47 static ConsoleCommandManager& getInstance();48 49 51 void registerCommand(ConsoleCommand* command); 50 52 void registerCommand(const std::string& group, const std::string& name, ConsoleCommand* command); … … 71 73 std::map<std::string, std::map<std::string, ConsoleCommand*> > commandMap_; 72 74 std::map<std::string, std::map<std::string, ConsoleCommand*> > commandMapLC_; 75 76 static ConsoleCommandManager* singletonPtr_s; 73 77 }; 74 78 } -
code/branches/core7/src/libraries/core/commandline/CommandLineParser.cc
r10520 r10542 40 40 namespace orxonox 41 41 { 42 CommandLineParser* CommandLineParser::singletonPtr_s = 0; 43 42 44 /** 43 45 @brief … … 85 87 CommandLineParser::~CommandLineParser() 86 88 { 87 }88 89 /**90 @brief91 Returns a unique instance (Meyers Singleton).92 */93 CommandLineParser& CommandLineParser::_getInstance()94 {95 static CommandLineParser instance;96 return instance;97 89 } 98 90 … … 260 252 std::string CommandLineParser::getUsageInformation() 261 253 { 262 CommandLineParser& inst = _getInstance();254 CommandLineParser& inst = getInstance(); 263 255 std::ostringstream infoStr; 264 256 … … 313 305 const CommandLineArgument* CommandLineParser::getArgument(const std::string& name) 314 306 { 315 std::map<std::string, CommandLineArgument*>::const_iterator it = _getInstance().cmdLineArgs_.find(name);316 if (it == _getInstance().cmdLineArgs_.end())307 std::map<std::string, CommandLineArgument*>::const_iterator it = getInstance().cmdLineArgs_.find(name); 308 if (it == getInstance().cmdLineArgs_.end()) 317 309 { 318 310 ThrowException(Argument, "Could find command line argument '" + name + "'."); … … 331 323 void CommandLineParser::addArgument(CommandLineArgument* argument) 332 324 { 333 OrxAssert(! _getInstance().existsArgument(argument->getName()),325 OrxAssert(!getInstance().existsArgument(argument->getName()), 334 326 "Cannot add a command line argument with name '" + argument->getName() + "' twice."); 335 327 OrxAssert(!argument->getDefaultValue().isType<bool>() || argument->getDefaultValue().get<bool>() != true, … … 337 329 << "Please use SetCommandLineSwitch and adjust your argument: " << argument->getName()); 338 330 339 _getInstance().cmdLineArgs_[argument->getName()] = argument;331 getInstance().cmdLineArgs_[argument->getName()] = argument; 340 332 } 341 333 … … 345 337 void CommandLineParser::removeArgument(CommandLineArgument* argument) 346 338 { 347 _getInstance().cmdLineArgs_.erase(argument->getName());339 getInstance().cmdLineArgs_.erase(argument->getName()); 348 340 } 349 341 } -
code/branches/core7/src/libraries/core/commandline/CommandLineParser.h
r10520 r10542 48 48 #include "util/OrxAssert.h" 49 49 #include "util/MultiType.h" 50 #include "util/Singleton.h" 50 51 51 52 namespace orxonox … … 134 135 CommandLineArgument 135 136 */ 136 class _CoreExport CommandLineParser 137 class _CoreExport CommandLineParser : public Singleton<CommandLineParser> 137 138 { 139 friend class Singleton<CommandLineParser>; 140 138 141 public: 142 //! Constructor initialises bFirstTimeParse_ with true. 143 CommandLineParser() : bFirstTimeParse_(true) { } 144 ~CommandLineParser(); 139 145 140 146 //! Parse redirection to internal member method. 141 147 static void parse(const std::string& cmdLine) 142 { _getInstance()._parse(cmdLine); }148 { getInstance()._parse(cmdLine); } 143 149 144 150 static std::string getUsageInformation(); … … 157 163 static bool existsArgument(const std::string& name) 158 164 { 159 std::map<std::string, CommandLineArgument*>::const_iterator it = _getInstance().cmdLineArgs_.find(name);160 return !(it == _getInstance().cmdLineArgs_.end());165 std::map<std::string, CommandLineArgument*>::const_iterator it = getInstance().cmdLineArgs_.find(name); 166 return !(it == getInstance().cmdLineArgs_.end()); 161 167 } 162 168 … … 164 170 165 171 private: 166 //! Constructor initialises bFirstTimeParse_ with true.167 CommandLineParser() : bFirstTimeParse_(true) { }168 172 //! Undefined copy constructor 169 173 CommandLineParser(const CommandLineParser& instance); 170 ~CommandLineParser();171 172 static CommandLineParser& _getInstance();173 174 174 175 void _parse(const std::string& cmdLine); … … 187 188 //! Search map by shortcut for the arguments. 188 189 std::map<std::string, CommandLineArgument*> cmdLineArgsShortcut_; 190 191 static CommandLineParser* singletonPtr_s; 189 192 }; 190 193 -
code/branches/core7/src/libraries/core/module/StaticInitializationManager.cc
r10536 r10542 33 33 namespace orxonox 34 34 { 35 /* static */ StaticInitializationManager& StaticInitializationManager::getInstance() 36 { 37 static StaticInitializationManager instance; 38 return instance; 39 } 35 StaticInitializationManager* StaticInitializationManager::singletonPtr_s = 0; 40 36 41 37 void StaticInitializationManager::addHandler(StaticInitializationHandler* handler) 42 38 { 39 handler->setupHandler(); 43 40 this->handlers_.push_back(handler); 44 41 } … … 47 44 { 48 45 this->handlers_.remove(handler); 46 handler->shutdownHandler(); 49 47 } 50 48 -
code/branches/core7/src/libraries/core/module/StaticInitializationManager.h
r10535 r10542 34 34 #include <list> 35 35 36 #include "util/Singleton.h" 37 36 38 namespace orxonox 37 39 { 38 class _CoreExport StaticInitializationManager 40 class _CoreExport StaticInitializationManager : public Singleton<StaticInitializationManager> 39 41 { 42 friend class Singleton<StaticInitializationManager>; 43 40 44 public: 41 static StaticInitializationManager& getInstance();42 43 45 StaticInitializationManager() {} 44 46 virtual ~StaticInitializationManager() {} … … 52 54 private: 53 55 std::list<StaticInitializationHandler*> handlers_; 56 57 static StaticInitializationManager* singletonPtr_s; 54 58 }; 55 59 } -
code/branches/core7/src/libraries/core/singleton/ScopeManager.cc
r10538 r10542 38 38 namespace orxonox 39 39 { 40 /* static */ ScopeManager& ScopeManager::getInstance() 41 { 42 static ScopeManager instance; 43 return instance; 44 } 40 ScopeManager* ScopeManager::singletonPtr_s = 0; 45 41 46 42 void ScopeManager::addScope(ScopeID::Value scope) -
code/branches/core7/src/libraries/core/singleton/ScopeManager.h
r10538 r10542 41 41 #include <set> 42 42 43 #include "util/Singleton.h" 44 43 45 namespace orxonox 44 46 { … … 52 54 @see See @ref Scope "this description" for details about the interrelationship of Scope, ScopeListener, and ScopeManager. 53 55 */ 54 class _CoreExport ScopeManager 56 class _CoreExport ScopeManager : public Singleton<ScopeManager> 55 57 { 58 friend class Singleton<ScopeManager>; 59 56 60 public: 57 static ScopeManager& getInstance();58 59 61 /** Adds a scope and activates all listeners which are registered for this scope */ 60 62 void addScope(ScopeID::Value scope); … … 78 80 std::set<ScopeID::Value> activeScopes_; 79 81 std::map<ScopeID::Value, std::set<ScopeListener*> > listeners_; //!< Stores all listeners for a scope 82 83 static ScopeManager* singletonPtr_s; 80 84 }; 81 85 }
Note: See TracChangeset
for help on using the changeset viewer.