Changeset 10530 for code/branches/core7/src/libraries/core
- Timestamp:
- Jun 6, 2015, 2:45:20 PM (10 years ago)
- Location:
- code/branches/core7/src/libraries/core
- Files:
-
- 9 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 {}
Note: See TracChangeset
for help on using the changeset viewer.