Changeset 10535 for code/branches/core7/src/libraries
- Timestamp:
- Jun 6, 2015, 11:52:25 PM (10 years ago)
- Location:
- code/branches/core7/src/libraries
- Files:
-
- 2 added
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core7/src/libraries/core/Core.cc
r10532 r10535 126 126 this->dynLibManager_ = new DynLibManager(); 127 127 128 // TODO: initialize StaticInitializationManager129 this->staticInitHandler_ = new CoreStaticInitializationHandler();130 StaticInitializationManager::getInstance().addHandler(this->staticInitHandler_);131 132 128 // TODO: initialize Root-Context 133 129 // TODO: initialize IdentifierManager here … … 136 132 // TODO: initialize ConsoleCommandManager here 137 133 // TODO: initialize NetworkFunctionManager here 134 // TODO: initialize StaticInitializationManager 135 this->staticInitHandler_ = new CoreStaticInitializationHandler(); 136 StaticInitializationManager::getInstance().addHandler(this->staticInitHandler_); 137 138 138 this->rootModule_ = ModuleInstance::getCurrentModuleInstance(); 139 this->rootModule_->loadAllStaticallyInitializedInstances(0);139 StaticInitializationManager::getInstance().loadModule(this->rootModule_); 140 140 141 141 // Parse command line arguments AFTER the modules have been loaded (static code!) … … 198 198 // creates the class hierarchy for all classes with factories 199 199 orxout(internal_info) << "creating class hierarchy" << endl; 200 IdentifierManager::getInstance().createClassHierarchy(); 200 this->staticInitHandler_->initInstances(this->rootModule_); 201 this->staticInitHandler_->setInitInstances(true); 201 202 202 203 // Loader … … 253 254 if (this->rootModule_) 254 255 { 255 this->rootModule_->unloadAllStaticallyInitializedInstances(0);256 StaticInitializationManager::getInstance().unloadModule(this->rootModule_); 256 257 this->rootModule_->deleteAllStaticallyInitializedInstances(); 257 258 } -
code/branches/core7/src/libraries/core/CoreIncludes.h
r10530 r10535 226 226 public: 227 227 StaticallyInitializedIdentifier(Identifier* identifier) 228 : StaticallyInitializedInstance( 0)228 : StaticallyInitializedInstance(StaticInitialization::IDENTIFIER) 229 229 , identifier_(identifier) 230 230 {} -
code/branches/core7/src/libraries/core/CorePrereqs.h
r10532 r10535 84 84 static const Value ROOT = 1; 85 85 static const Value GRAPHICS = 2; 86 } 87 88 namespace StaticInitialization 89 { 90 typedef int Type; 91 92 static const Type STATIC_INITIALIZATION_HANDLER = 1; 93 static const Type IDENTIFIER = 2; 94 static const Type SCOPED_SINGLETON_WRAPPER = 3; 95 static const Type COMMAND_LINE_ARGUMENT = 4; 96 static const Type CONSOLE_COMMAND = 5; 86 97 } 87 98 -
code/branches/core7/src/libraries/core/CoreStaticInitializationHandler.cc
r10532 r10535 47 47 void CoreStaticInitializationHandler::loadModule(ModuleInstance* module) 48 48 { 49 module->loadAllStaticallyInitializedInstances(0); 49 this->loadInstances(module); 50 if (this->bInitInstances_) 51 this->initInstances(module); 52 } 53 54 void CoreStaticInitializationHandler::loadInstances(ModuleInstance* module) 55 { 56 // the order of initialization is important 57 module->loadAllStaticallyInitializedInstances(StaticInitialization::STATIC_INITIALIZATION_HANDLER); 58 module->loadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER); 59 module->loadAllStaticallyInitializedInstances(StaticInitialization::SCOPED_SINGLETON_WRAPPER); 60 module->loadAllStaticallyInitializedInstances(StaticInitialization::COMMAND_LINE_ARGUMENT); 61 module->loadAllStaticallyInitializedInstances(StaticInitialization::CONSOLE_COMMAND); 62 } 63 64 void CoreStaticInitializationHandler::initInstances(ModuleInstance* module) 65 { 50 66 IdentifierManager::getInstance().createClassHierarchy(); 51 67 ScopeManager::getInstance().updateListeners(); … … 54 70 void CoreStaticInitializationHandler::unloadModule(ModuleInstance* module) 55 71 { 56 module->unloadAllStaticallyInitializedInstances(0); 72 // inverted order of initialization 73 module->unloadAllStaticallyInitializedInstances(StaticInitialization::CONSOLE_COMMAND); 74 module->unloadAllStaticallyInitializedInstances(StaticInitialization::COMMAND_LINE_ARGUMENT); 75 module->unloadAllStaticallyInitializedInstances(StaticInitialization::SCOPED_SINGLETON_WRAPPER); 76 module->unloadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER); 77 module->unloadAllStaticallyInitializedInstances(StaticInitialization::STATIC_INITIALIZATION_HANDLER); 57 78 } 58 79 } -
code/branches/core7/src/libraries/core/CoreStaticInitializationHandler.h
r10532 r10535 38 38 class _CoreExport CoreStaticInitializationHandler : public StaticInitializationHandler 39 39 { 40 friend class Core; 41 40 42 public: 43 CoreStaticInitializationHandler() : bInitInstances_(false) {} 44 41 45 virtual void setupHandler(); 42 46 virtual void shutdownHandler(); … … 44 48 virtual void loadModule(ModuleInstance* module); 45 49 virtual void unloadModule(ModuleInstance* module); 50 51 inline void setInitInstances(bool bInitInstances) 52 { this->bInitInstances_ = bInitInstances; } 53 54 private: 55 void loadInstances(ModuleInstance* module); 56 void initInstances(ModuleInstance* module); 57 58 bool bInitInstances_; 46 59 }; 47 60 } -
code/branches/core7/src/libraries/core/command/ConsoleCommandIncludes.h
r10530 r10535 311 311 public: 312 312 StaticallyInitializedConsoleCommand(ConsoleCommand* command) 313 : StaticallyInitializedInstance( 0)313 : StaticallyInitializedInstance(StaticInitialization::CONSOLE_COMMAND) 314 314 , command_(command) 315 315 {} -
code/branches/core7/src/libraries/core/commandline/CommandLineIncludes.h
r10530 r10535 59 59 public: 60 60 StaticallyInitializedCommandLineArgument(CommandLineArgument* argument) 61 : StaticallyInitializedInstance( 0)61 : StaticallyInitializedInstance(StaticInitialization::COMMAND_LINE_ARGUMENT) 62 62 , argument_(argument) 63 63 {} -
code/branches/core7/src/libraries/core/module/ModuleInstance.cc
r10530 r10535 56 56 } 57 57 58 void ModuleInstance::loadAllStaticallyInitializedInstances(Static allyInitializedInstance::Type type)58 void ModuleInstance::loadAllStaticallyInitializedInstances(StaticInitialization::Type type) 59 59 { 60 60 const std::set<StaticallyInitializedInstance*>& instances = this->staticallyInitializedInstancesByType_[type]; … … 63 63 } 64 64 65 void ModuleInstance::unloadAllStaticallyInitializedInstances(Static allyInitializedInstance::Type type)65 void ModuleInstance::unloadAllStaticallyInitializedInstances(StaticInitialization::Type type) 66 66 { 67 67 const std::set<StaticallyInitializedInstance*>& instances = this->staticallyInitializedInstancesByType_[type]; … … 72 72 void ModuleInstance::deleteAllStaticallyInitializedInstances() 73 73 { 74 std::map<Static allyInitializedInstance::Type, std::set<StaticallyInitializedInstance*> > copy(this->staticallyInitializedInstancesByType_);74 std::map<StaticInitialization::Type, std::set<StaticallyInitializedInstance*> > copy(this->staticallyInitializedInstancesByType_); 75 75 this->staticallyInitializedInstancesByType_.clear(); 76 for (std::map<Static allyInitializedInstance::Type, std::set<StaticallyInitializedInstance*> >::iterator it1 = copy.begin(); it1 != copy.end(); ++it1)76 for (std::map<StaticInitialization::Type, std::set<StaticallyInitializedInstance*> >::iterator it1 = copy.begin(); it1 != copy.end(); ++it1) 77 77 for (std::set<StaticallyInitializedInstance*>::iterator it2 = it1->second.begin(); it2 != it1->second.end(); ++it2) 78 78 delete (*it2); -
code/branches/core7/src/libraries/core/module/ModuleInstance.h
r10530 r10535 49 49 void removeStaticallyInitializedInstance(StaticallyInitializedInstance* instance); 50 50 51 void loadAllStaticallyInitializedInstances(Static allyInitializedInstance::Type type);52 void unloadAllStaticallyInitializedInstances(Static allyInitializedInstance::Type type);51 void loadAllStaticallyInitializedInstances(StaticInitialization::Type type); 52 void unloadAllStaticallyInitializedInstances(StaticInitialization::Type type); 53 53 54 54 void deleteAllStaticallyInitializedInstances(); … … 66 66 67 67 private: 68 std::map<Static allyInitializedInstance::Type, std::set<StaticallyInitializedInstance*> > staticallyInitializedInstancesByType_;68 std::map<StaticInitialization::Type, std::set<StaticallyInitializedInstance*> > staticallyInitializedInstancesByType_; 69 69 std::string name_; 70 70 DynLib* dynLib_; -
code/branches/core7/src/libraries/core/module/StaticInitializationHandlerIncludes.h
r10531 r10535 48 48 public: 49 49 StaticallyInitializedStaticInitializationHandler(StaticInitializationHandler* handler) 50 : StaticallyInitializedInstance( 0)50 : StaticallyInitializedInstance(StaticInitialization::STATIC_INITIALIZATION_HANDLER) 51 51 , handler_(handler) 52 52 {} -
code/branches/core7/src/libraries/core/module/StaticInitializationManager.h
r10532 r10535 38 38 class _CoreExport StaticInitializationManager 39 39 { 40 friend class Core;41 42 40 public: 43 41 static StaticInitializationManager& getInstance(); -
code/branches/core7/src/libraries/core/module/StaticallyInitializedInstance.cc
r10530 r10535 33 33 namespace orxonox 34 34 { 35 StaticallyInitializedInstance::StaticallyInitializedInstance( Type type)35 StaticallyInitializedInstance::StaticallyInitializedInstance(StaticInitialization::Type type) 36 36 { 37 37 this->type_ = type; -
code/branches/core7/src/libraries/core/module/StaticallyInitializedInstance.h
r10530 r10535 37 37 { 38 38 public: 39 typedef int Type;40 39 41 StaticallyInitializedInstance( Type type);40 StaticallyInitializedInstance(StaticInitialization::Type type); 42 41 virtual ~StaticallyInitializedInstance(); 43 42 … … 45 44 virtual void unload() = 0; 46 45 47 inline Type getType() const46 inline StaticInitialization::Type getType() const 48 47 { return this->type_; } 49 48 50 49 private: 51 50 ModuleInstance* module_; 52 Type type_;51 StaticInitialization::Type type_; 53 52 }; 54 53 } -
code/branches/core7/src/libraries/core/singleton/ScopedSingletonIncludes.h
r10530 r10535 81 81 public: 82 82 StaticallyInitializedScopedSingletonWrapper(ScopedSingletonWrapper* wrapper, ScopeID::Value scope) 83 : StaticallyInitializedInstance( 0)83 : StaticallyInitializedInstance(StaticInitialization::SCOPED_SINGLETON_WRAPPER) 84 84 , wrapper_(wrapper) 85 85 , scope_(scope) -
code/branches/core7/src/libraries/network/CMakeLists.txt
r10478 r10535 36 36 NetworkFunctionIncludes.cc 37 37 NetworkFunctionManager.cc 38 NetworkStaticInitializationHandler.cc 38 39 Host.cc 39 40 Server.cc -
code/branches/core7/src/libraries/network/NetworkFunctionIncludes.cc
r10478 r10535 30 30 #include "NetworkFunctionManager.h" 31 31 32 #include "core/module/StaticInitializationHandlerIncludes.h" 33 #include "NetworkStaticInitializationHandler.h" 34 32 35 namespace orxonox 33 36 { 37 RegisterStaticInitializationHandler(NetworkStaticInitializationHandler); 38 34 39 void StaticallyInitializedNetworkFunction::load() 35 40 { -
code/branches/core7/src/libraries/network/NetworkFunctionIncludes.h
r10530 r10535 52 52 public: 53 53 StaticallyInitializedNetworkFunction(NetworkFunctionBase* function) 54 : StaticallyInitializedInstance( 0)54 : StaticallyInitializedInstance(StaticInitialization::NETWORK_FUNCTION) 55 55 , function_(function) 56 56 {} -
code/branches/core7/src/libraries/network/NetworkPrereqs.h
r8858 r10535 97 97 } 98 98 } 99 100 namespace StaticInitialization 101 { 102 typedef int Type; 103 static const Type NETWORK_FUNCTION = 6; 104 } 99 105 } 100 106
Note: See TracChangeset
for help on using the changeset viewer.