Changeset 10530
- Timestamp:
- Jun 6, 2015, 2:45:20 PM (9 years ago)
- Location:
- code/branches/core7
- Files:
-
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core7/src/libraries/core/Core.cc
r10527 r10530 130 130 // TODO: initialize NetworkFunctionManager here 131 131 this->rootModule_ = ModuleInstance::getCurrentModuleInstance(); 132 this->rootModule_->loadAllStaticallyInitializedInstances( );132 this->rootModule_->loadAllStaticallyInitializedInstances(0); 133 133 134 134 // Parse command line arguments AFTER the modules have been loaded (static code!) … … 246 246 if (this->rootModule_) 247 247 { 248 this->rootModule_->unloadAllStaticallyInitializedInstances( );248 this->rootModule_->unloadAllStaticallyInitializedInstances(0); 249 249 this->rootModule_->deleteAllStaticallyInitializedInstances(); 250 250 } … … 287 287 DynLib* dynLib = this->dynLibManager_->load(module->getName()); 288 288 module->setDynLib(dynLib); 289 module->loadAllStaticallyInitializedInstances( );289 module->loadAllStaticallyInitializedInstances(0); 290 290 IdentifierManager::getInstance().createClassHierarchy(); 291 291 ScopeManager::getInstance().updateListeners(); … … 307 307 orxout(internal_info) << "Unloading module " << module->getName() << "..." << endl; 308 308 309 module->unloadAllStaticallyInitializedInstances( );309 module->unloadAllStaticallyInitializedInstances(0); 310 310 module->deleteAllStaticallyInitializedInstances(); 311 311 this->dynLibManager_->unload(module->getDynLib()); -
code/branches/core7/src/libraries/core/CoreIncludes.h
r10520 r10530 225 225 226 226 public: 227 StaticallyInitializedIdentifier(Identifier* identifier) : identifier_(identifier) {} 227 StaticallyInitializedIdentifier(Identifier* identifier) 228 : StaticallyInitializedInstance(0) 229 , identifier_(identifier) 230 {} 228 231 ~StaticallyInitializedIdentifier() { delete identifier_; } 229 232 -
code/branches/core7/src/libraries/core/command/ConsoleCommandIncludes.h
r10520 r10530 310 310 { 311 311 public: 312 StaticallyInitializedConsoleCommand(ConsoleCommand* command) : command_(command) {} 312 StaticallyInitializedConsoleCommand(ConsoleCommand* command) 313 : StaticallyInitializedInstance(0) 314 , command_(command) 315 {} 313 316 ~StaticallyInitializedConsoleCommand() { delete command_; } 314 317 -
code/branches/core7/src/libraries/core/commandline/CommandLineIncludes.h
r10520 r10530 58 58 { 59 59 public: 60 StaticallyInitializedCommandLineArgument(CommandLineArgument* argument) : argument_(argument) {} 60 StaticallyInitializedCommandLineArgument(CommandLineArgument* argument) 61 : StaticallyInitializedInstance(0) 62 , argument_(argument) 63 {} 61 64 ~StaticallyInitializedCommandLineArgument() { delete argument_; } 62 65 -
code/branches/core7/src/libraries/core/module/ModuleInstance.cc
r10521 r10530 48 48 void ModuleInstance::addStaticallyInitializedInstance(StaticallyInitializedInstance* instance) 49 49 { 50 this->staticallyInitializedInstances_.insert(instance); 51 } 52 53 void ModuleInstance::loadAllStaticallyInitializedInstances() 54 { 55 for (std::set<StaticallyInitializedInstance*>::iterator it = this->staticallyInitializedInstances_.begin(); it != this->staticallyInitializedInstances_.end(); ++it) 56 (*it)->load(); 57 } 58 59 void ModuleInstance::unloadAllStaticallyInitializedInstances() 60 { 61 for (std::set<StaticallyInitializedInstance*>::iterator it = this->staticallyInitializedInstances_.begin(); it != this->staticallyInitializedInstances_.end(); ++it) 62 (*it)->unload(); 50 this->staticallyInitializedInstancesByType_[instance->getType()].insert(instance); 63 51 } 64 52 65 53 void ModuleInstance::removeStaticallyInitializedInstance(StaticallyInitializedInstance* instance) 66 54 { 67 this->staticallyInitializedInstances_.erase(instance); 55 this->staticallyInitializedInstancesByType_[instance->getType()].erase(instance); 56 } 57 58 void ModuleInstance::loadAllStaticallyInitializedInstances(StaticallyInitializedInstance::Type type) 59 { 60 const std::set<StaticallyInitializedInstance*>& instances = this->staticallyInitializedInstancesByType_[type]; 61 for (std::set<StaticallyInitializedInstance*>::iterator it = instances.begin(); it != instances.end(); ++it) 62 (*it)->load(); 63 } 64 65 void ModuleInstance::unloadAllStaticallyInitializedInstances(StaticallyInitializedInstance::Type type) 66 { 67 const std::set<StaticallyInitializedInstance*>& instances = this->staticallyInitializedInstancesByType_[type]; 68 for (std::set<StaticallyInitializedInstance*>::iterator it = instances.begin(); it != instances.end(); ++it) 69 (*it)->unload(); 68 70 } 69 71 70 72 void ModuleInstance::deleteAllStaticallyInitializedInstances() 71 73 { 72 std::set<StaticallyInitializedInstance*> copy(this->staticallyInitializedInstances_); 73 this->staticallyInitializedInstances_.clear(); 74 for (std::set<StaticallyInitializedInstance*>::iterator it = copy.begin(); it != copy.end(); ++it) 75 delete (*it); 74 std::map<StaticallyInitializedInstance::Type, std::set<StaticallyInitializedInstance*> > copy(this->staticallyInitializedInstancesByType_); 75 this->staticallyInitializedInstancesByType_.clear(); 76 for (std::map<StaticallyInitializedInstance::Type, std::set<StaticallyInitializedInstance*> >::iterator it1 = copy.begin(); it1 != copy.end(); ++it1) 77 for (std::set<StaticallyInitializedInstance*>::iterator it2 = it1->second.begin(); it2 != it1->second.end(); ++it2) 78 delete (*it2); 76 79 } 77 80 -
code/branches/core7/src/libraries/core/module/ModuleInstance.h
r10518 r10530 33 33 34 34 #include <set> 35 #include <map> 35 36 #include <string> 37 38 #include "StaticallyInitializedInstance.h" 36 39 37 40 namespace orxonox … … 44 47 45 48 void addStaticallyInitializedInstance(StaticallyInitializedInstance* instance); 46 void loadAllStaticallyInitializedInstances();47 void unloadAllStaticallyInitializedInstances();48 49 void removeStaticallyInitializedInstance(StaticallyInitializedInstance* instance); 50 51 void loadAllStaticallyInitializedInstances(StaticallyInitializedInstance::Type type); 52 void unloadAllStaticallyInitializedInstances(StaticallyInitializedInstance::Type type); 53 49 54 void deleteAllStaticallyInitializedInstances(); 50 55 … … 61 66 62 67 private: 63 std:: set<StaticallyInitializedInstance*> staticallyInitializedInstances_;68 std::map<StaticallyInitializedInstance::Type, std::set<StaticallyInitializedInstance*> > staticallyInitializedInstancesByType_; 64 69 std::string name_; 65 70 DynLib* dynLib_; -
code/branches/core7/src/libraries/core/module/StaticallyInitializedInstance.cc
r10522 r10530 33 33 namespace orxonox 34 34 { 35 StaticallyInitializedInstance::StaticallyInitializedInstance( )35 StaticallyInitializedInstance::StaticallyInitializedInstance(Type type) 36 36 { 37 this->type_ = type; 37 38 this->module_ = ModuleInstance::getCurrentModuleInstance(); 38 39 this->module_->addStaticallyInitializedInstance(this); -
code/branches/core7/src/libraries/core/module/StaticallyInitializedInstance.h
r10522 r10530 37 37 { 38 38 public: 39 StaticallyInitializedInstance(); 39 typedef int Type; 40 41 StaticallyInitializedInstance(Type type); 40 42 virtual ~StaticallyInitializedInstance(); 41 43 … … 43 45 virtual void unload() = 0; 44 46 47 inline Type getType() const 48 { return this->type_; } 49 45 50 private: 46 51 ModuleInstance* module_; 52 Type type_; 47 53 }; 48 54 } -
code/branches/core7/src/libraries/core/singleton/ScopedSingletonIncludes.h
r10520 r10530 81 81 public: 82 82 StaticallyInitializedScopedSingletonWrapper(ScopedSingletonWrapper* wrapper, ScopeID::Value scope) 83 : wrapper_(wrapper) 83 : StaticallyInitializedInstance(0) 84 , wrapper_(wrapper) 84 85 , scope_(scope) 85 86 {} -
code/branches/core7/src/libraries/network/NetworkFunctionIncludes.h
r10520 r10530 51 51 { 52 52 public: 53 StaticallyInitializedNetworkFunction(NetworkFunctionBase* function) : function_(function) {} 53 StaticallyInitializedNetworkFunction(NetworkFunctionBase* function) 54 : StaticallyInitializedInstance(0) 55 , function_(function) 56 {} 54 57 ~StaticallyInitializedNetworkFunction() { delete function_; } 55 58 -
code/branches/core7/test/core/class/IdentifierClassHierarchyTest.cc
r10405 r10530 142 142 virtual void SetUp() 143 143 { 144 ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances( );144 ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(0); 145 145 Identifier::initConfigValues_s = false; // TODO: hack! 146 146 IdentifierManager::getInstance().createClassHierarchy(); … … 150 150 { 151 151 IdentifierManager::getInstance().destroyClassHierarchy(); 152 ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances( );152 ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(0); 153 153 } 154 154 }; -
code/branches/core7/test/core/class/IdentifierExternalClassHierarchyTest.cc
r10405 r10530 49 49 virtual void SetUp() 50 50 { 51 ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances( );51 ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(0); 52 52 Identifier::initConfigValues_s = false; // TODO: hack! 53 53 IdentifierManager::getInstance().createClassHierarchy(); … … 57 57 { 58 58 IdentifierManager::getInstance().destroyClassHierarchy(); 59 ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances( );59 ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(0); 60 60 } 61 61 }; -
code/branches/core7/test/core/class/IdentifierNestedClassHierarchyTest.cc
r10405 r10530 109 109 virtual void SetUp() 110 110 { 111 ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances( );111 ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(0); 112 112 Identifier::initConfigValues_s = false; // TODO: hack! 113 113 IdentifierManager::getInstance().createClassHierarchy(); … … 117 117 { 118 118 IdentifierManager::getInstance().destroyClassHierarchy(); 119 ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances( );119 ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(0); 120 120 } 121 121 }; -
code/branches/core7/test/core/class/IdentifierSimpleClassHierarchyTest.cc
r10405 r10530 51 51 virtual void SetUp() 52 52 { 53 ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances( );53 ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(0); 54 54 Identifier::initConfigValues_s = false; // TODO: hack! 55 55 IdentifierManager::getInstance().createClassHierarchy(); … … 59 59 { 60 60 IdentifierManager::getInstance().destroyClassHierarchy(); 61 ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances( );61 ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(0); 62 62 } 63 63 }; -
code/branches/core7/test/core/class/SubclassIdentifierTest.cc
r10405 r10530 31 31 virtual void SetUp() 32 32 { 33 ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances( );33 ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(0); 34 34 Identifier::initConfigValues_s = false; // TODO: hack! 35 35 IdentifierManager::getInstance().createClassHierarchy(); … … 43 43 44 44 IdentifierManager::getInstance().destroyClassHierarchy(); 45 ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances( );45 ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(0); 46 46 } 47 47 }; -
code/branches/core7/test/core/class/SuperTest.cc
r10405 r10530 72 72 virtual void SetUp() 73 73 { 74 ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances( );74 ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(0); 75 75 Identifier::initConfigValues_s = false; // TODO: hack! 76 76 IdentifierManager::getInstance().createClassHierarchy(); … … 84 84 85 85 IdentifierManager::getInstance().destroyClassHierarchy(); 86 ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances( );86 ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(0); 87 87 } 88 88 }; -
code/branches/core7/test/core/command/CommandTest.cc
r10405 r10530 140 140 virtual void SetUp() 141 141 { 142 ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances( );142 ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(0); 143 143 Identifier::initConfigValues_s = false; // TODO: hack! 144 144 IdentifierManager::getInstance().createClassHierarchy(); … … 148 148 { 149 149 IdentifierManager::getInstance().destroyClassHierarchy(); 150 ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances( );150 ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(0); 151 151 } 152 152 }; -
code/branches/core7/test/core/object/ClassFactoryTest.cc
r10481 r10530 16 16 { 17 17 Context::setRootContext(new Context(NULL)); 18 ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances( );18 ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(0); 19 19 } 20 20 21 21 virtual void TearDown() 22 22 { 23 ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances( );23 ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(0); 24 24 Context::setRootContext(NULL); 25 25 } -
code/branches/core7/test/core/object/ContextTest.cc
r10481 r10530 24 24 { 25 25 Context::setRootContext(new Context(NULL)); 26 ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances( );26 ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(0); 27 27 } 28 28 29 29 virtual void TearDown() 30 30 { 31 ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances( );31 ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(0); 32 32 Context::setRootContext(NULL); 33 33 } -
code/branches/core7/test/core/object/IteratorTest.cc
r10481 r10530 35 35 { 36 36 Context::setRootContext(new Context(NULL)); 37 ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances( );37 ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(0); 38 38 } 39 39 40 40 virtual void TearDown() 41 41 { 42 ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances( );42 ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(0); 43 43 Context::setRootContext(NULL); 44 44 } -
code/branches/core7/test/core/object/ListableTest.cc
r10481 r10530 40 40 { 41 41 Context::setRootContext(new Context(NULL)); 42 ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances( );42 ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(0); 43 43 } 44 44 45 45 virtual void TearDown() 46 46 { 47 ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances( );47 ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(0); 48 48 Context::setRootContext(NULL); 49 49 } -
code/branches/core7/test/core/object/ObjectListIteratorTest.cc
r10481 r10530 27 27 { 28 28 Context::setRootContext(new Context(NULL)); 29 ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances( );29 ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(0); 30 30 } 31 31 32 32 virtual void TearDown() 33 33 { 34 ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances( );34 ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(0); 35 35 Context::setRootContext(NULL); 36 36 } -
code/branches/core7/test/core/singleton/ScopeTest.cc
r10464 r10530 27 27 virtual void SetUp() 28 28 { 29 ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances( );29 ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(0); 30 30 } 31 31 32 32 virtual void TearDown() 33 33 { 34 ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances( );34 ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(0); 35 35 } 36 36 };
Note: See TracChangeset
for help on using the changeset viewer.