Changeset 11014 for code/trunk/src/libraries/core/module
- Timestamp:
- Jan 2, 2016, 3:15:04 PM (9 years ago)
- Location:
- code/trunk/src/libraries/core/module
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/libraries/core/module/Plugin.cc
r10553 r11014 44 44 { 45 45 if (this->moduleInstance_ != NULL) 46 {47 this->referenceCounter_ = 1; // force unloading48 46 this->unload(); 49 }50 47 } 51 48 52 void Plugin:: load()49 void Plugin::reference() 53 50 { 54 51 this->referenceCounter_++; 55 52 if (this->referenceCounter_ == 1) // increased from 0 to 1 -> load plugin 56 { 57 orxout(internal_info) << "Loading plugin " << this->name_ << "..." << endl; 58 this->moduleInstance_ = new ModuleInstance(this->libraryName_); 59 Core::getInstance().loadModule(this->moduleInstance_); 60 } 53 this->load(); 61 54 else 62 55 orxout(internal_info) << "Increased reference count for plugin " << this->name_ << " to " << this->referenceCounter_ << endl; 63 56 } 64 57 65 void Plugin:: unload()58 void Plugin::dereference() 66 59 { 67 60 if (this->referenceCounter_ == 0) … … 73 66 this->referenceCounter_--; 74 67 if (this->referenceCounter_ == 0) // reduced from 1 to 0 -> load plugin 75 { 76 orxout(internal_info) << "Unloading plugin " << this->name_ << "..." << endl; 77 Core::getInstance().unloadModule(this->moduleInstance_); 78 delete this->moduleInstance_; 79 this->moduleInstance_ = NULL; 80 } 68 this->unload(); 81 69 else 82 70 orxout(internal_info) << "Reduced reference count for plugin " << this->name_ << " to " << this->referenceCounter_ << endl; 83 71 } 72 73 void Plugin::load() 74 { 75 orxout(internal_info) << "Loading plugin " << this->name_ << "..." << endl; 76 this->moduleInstance_ = new ModuleInstance(this->libraryName_); 77 Core::getInstance().loadModule(this->moduleInstance_); 78 } 79 80 void Plugin::unload() 81 { 82 orxout(internal_info) << "Unloading plugin " << this->name_ << "..." << endl; 83 Core::getInstance().unloadModule(this->moduleInstance_); 84 delete this->moduleInstance_; 85 this->moduleInstance_ = NULL; 86 } 84 87 } -
code/trunk/src/libraries/core/module/Plugin.h
r10552 r11014 40 40 ~Plugin(); 41 41 42 void reference(); 43 void dereference(); 44 45 private: 42 46 void load(); 43 47 void unload(); 44 48 45 private:46 49 std::string name_; 47 50 std::string libraryName_; -
code/trunk/src/libraries/core/module/PluginManager.cc
r10580 r11014 90 90 Plugin* plugin = this->plugins_[name]; 91 91 if (plugin != NULL) 92 plugin-> load();92 plugin->reference(); 93 93 else 94 94 orxout(internal_warning) << "Cannot find plugin with name " << name << endl; … … 99 99 Plugin* plugin = this->plugins_[name]; 100 100 if (plugin != NULL) 101 plugin-> unload();101 plugin->dereference(); 102 102 else 103 103 orxout(internal_warning) << "Cannot find plugin with name " << name << endl;
Note: See TracChangeset
for help on using the changeset viewer.