Changeset 10518 for code/branches/core7/src/libraries/core/module
- Timestamp:
- May 31, 2015, 10:56:32 AM (9 years ago)
- Location:
- code/branches/core7/src/libraries/core/module
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core7/src/libraries/core/module/ModuleInstance.cc
r10404 r10518 35 35 ModuleInstance* ModuleInstance::currentModuleInstance_s = NULL; 36 36 37 ModuleInstance::ModuleInstance(const std::string& name) 38 : name_(name) 39 , dynLib_(NULL) 40 { 41 } 42 37 43 ModuleInstance::~ModuleInstance() 38 44 { 39 std::list<StaticallyInitializedInstance*> copy(this->staticallyInitializedInstances_); 40 for (std::list<StaticallyInitializedInstance*>::iterator it = this->staticallyInitializedInstances_.begin(); it != this->staticallyInitializedInstances_.end(); ++it) 41 delete (*it); 45 this->deleteAllStaticallyInitializedInstances(); 42 46 } 43 47 44 48 void ModuleInstance::addStaticallyInitializedInstance(StaticallyInitializedInstance* instance) 45 49 { 46 this->staticallyInitializedInstances_. push_back(instance);50 this->staticallyInitializedInstances_.insert(instance); 47 51 } 48 52 49 53 void ModuleInstance::loadAllStaticallyInitializedInstances() 50 54 { 51 for (std:: list<StaticallyInitializedInstance*>::iterator it = this->staticallyInitializedInstances_.begin(); it != this->staticallyInitializedInstances_.end(); ++it)55 for (std::set<StaticallyInitializedInstance*>::iterator it = this->staticallyInitializedInstances_.begin(); it != this->staticallyInitializedInstances_.end(); ++it) 52 56 (*it)->load(); 53 57 } … … 55 59 void ModuleInstance::unloadAllStaticallyInitializedInstances() 56 60 { 57 for (std:: list<StaticallyInitializedInstance*>::iterator it = this->staticallyInitializedInstances_.begin(); it != this->staticallyInitializedInstances_.end(); ++it)61 for (std::set<StaticallyInitializedInstance*>::iterator it = this->staticallyInitializedInstances_.begin(); it != this->staticallyInitializedInstances_.end(); ++it) 58 62 (*it)->unload(); 59 63 } … … 61 65 void ModuleInstance::removeStaticallyInitializedInstance(StaticallyInitializedInstance* instance) 62 66 { 63 this->staticallyInitializedInstances_. remove(instance);67 this->staticallyInitializedInstances_.erase(instance); 64 68 } 69 70 void ModuleInstance::deleteAllStaticallyInitializedInstances() 71 { 72 std::set<StaticallyInitializedInstance*> copy(this->staticallyInitializedInstances_); 73 this->staticallyInitializedInstances_.clear(); 74 for (std::set<StaticallyInitializedInstance*>::iterator it = this->staticallyInitializedInstances_.begin(); it != this->staticallyInitializedInstances_.end(); ++it) 75 delete (*it); 76 } 77 65 78 66 79 /*static*/ void ModuleInstance::setCurrentModuleInstance(ModuleInstance* instance) … … 72 85 { 73 86 if (!ModuleInstance::currentModuleInstance_s) 74 ModuleInstance::currentModuleInstance_s = new ModuleInstance( );87 ModuleInstance::currentModuleInstance_s = new ModuleInstance(""); 75 88 return ModuleInstance::currentModuleInstance_s; 76 89 } -
code/branches/core7/src/libraries/core/module/ModuleInstance.h
r10404 r10518 32 32 #include "core/CorePrereqs.h" 33 33 34 #include <list> 34 #include <set> 35 #include <string> 35 36 36 37 namespace orxonox … … 39 40 { 40 41 public: 42 ModuleInstance(const std::string& name); 41 43 ~ModuleInstance(); 42 44 … … 45 47 void unloadAllStaticallyInitializedInstances(); 46 48 void removeStaticallyInitializedInstance(StaticallyInitializedInstance* instance); 49 void deleteAllStaticallyInitializedInstances(); 50 51 inline const std::string& getName() const 52 { return this->name_; } 53 54 inline void setDynLib(DynLib* dynLib) 55 { this->dynLib_ = dynLib; } 56 inline DynLib* getDynLib() const 57 { return this->dynLib_; } 47 58 48 59 static void setCurrentModuleInstance(ModuleInstance* instance); … … 50 61 51 62 private: 52 std::list<StaticallyInitializedInstance*> staticallyInitializedInstances_; 63 std::set<StaticallyInitializedInstance*> staticallyInitializedInstances_; 64 std::string name_; 65 DynLib* dynLib_; 53 66 54 67 static ModuleInstance* currentModuleInstance_s;
Note: See TracChangeset
for help on using the changeset viewer.