- Timestamp:
- Jan 2, 2016, 3:36:10 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
r11014 r11015 32 32 #include "util/Output.h" 33 33 #include "core/Core.h" 34 #include "StaticInitializationManager.h" 34 35 35 36 namespace orxonox … … 43 44 Plugin::~Plugin() 44 45 { 46 // force unloading of the module when the plugin is destroyed 45 47 if (this->moduleInstance_ != NULL) 46 this->unload ();48 this->unloadModule(); 47 49 } 48 50 … … 56 58 } 57 59 58 void Plugin::dereference( )60 void Plugin::dereference(bool bMerelyDeactivate) 59 61 { 60 62 if (this->referenceCounter_ == 0) … … 66 68 this->referenceCounter_--; 67 69 if (this->referenceCounter_ == 0) // reduced from 1 to 0 -> load plugin 68 this->unload( );70 this->unload(bMerelyDeactivate); 69 71 else 70 72 orxout(internal_info) << "Reduced reference count for plugin " << this->name_ << " to " << this->referenceCounter_ << endl; 71 73 } 72 74 75 ////////////////////////////////////////// 76 // LOAD // 77 ////////////////////////////////////////// 73 78 void Plugin::load() 79 { 80 // only load module if it isn't already loaded. otherwise merely activate it. 81 if (this->moduleInstance_ == NULL) 82 this->loadModule(); 83 else 84 this->activateModule(); 85 } 86 void Plugin::loadModule() 74 87 { 75 88 orxout(internal_info) << "Loading plugin " << this->name_ << "..." << endl; … … 77 90 Core::getInstance().loadModule(this->moduleInstance_); 78 91 } 92 void Plugin::activateModule() 93 { 94 orxout(internal_info) << "Activating plugin " << this->name_ << "..." << endl; 95 StaticInitializationManager::getInstance().loadModule(this->moduleInstance_); 96 } 79 97 80 void Plugin::unload() 98 ////////////////////////////////////////// 99 // UNLOAD // 100 ////////////////////////////////////////// 101 void Plugin::unload(bool bMerelyDeactivate) 102 { 103 // fully unload the module unless otherwise requested. 104 if (bMerelyDeactivate) 105 this->deactivateModule(); 106 else 107 this->unloadModule(); 108 } 109 void Plugin::unloadModule() 81 110 { 82 111 orxout(internal_info) << "Unloading plugin " << this->name_ << "..." << endl; … … 85 114 this->moduleInstance_ = NULL; 86 115 } 116 void Plugin::deactivateModule() 117 { 118 orxout(internal_info) << "Deactivating plugin " << this->name_ << "..." << endl; 119 StaticInitializationManager::getInstance().unloadModule(this->moduleInstance_); 120 } 87 121 } -
code/trunk/src/libraries/core/module/Plugin.h
r11014 r11015 41 41 42 42 void reference(); 43 void dereference( );43 void dereference(bool bMerelyDeactivate); 44 44 45 45 private: 46 46 void load(); 47 void unload(); 47 void unload(bool bMerelyDeactivate); 48 49 void loadModule(); 50 void activateModule(); 51 52 void unloadModule(); 53 void deactivateModule(); 48 54 49 55 std::string name_; -
code/trunk/src/libraries/core/module/PluginManager.cc
r11014 r11015 99 99 Plugin* plugin = this->plugins_[name]; 100 100 if (plugin != NULL) 101 plugin->dereference( );101 plugin->dereference(false); 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.