Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11014


Ignore:
Timestamp:
Jan 2, 2016, 3:15:04 PM (8 years ago)
Author:
landauf
Message:

moved code for loading/unloading a plugin into separate functions

Location:
code/trunk/src/libraries/core/module
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/libraries/core/module/Plugin.cc

    r10553 r11014  
    4444    {
    4545        if (this->moduleInstance_ != NULL)
    46         {
    47             this->referenceCounter_ = 1; // force unloading
    4846            this->unload();
    49         }
    5047    }
    5148
    52     void Plugin::load()
     49    void Plugin::reference()
    5350    {
    5451        this->referenceCounter_++;
    5552        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();
    6154        else
    6255            orxout(internal_info) << "Increased reference count for plugin " << this->name_ << " to " << this->referenceCounter_ << endl;
    6356    }
    6457
    65     void Plugin::unload()
     58    void Plugin::dereference()
    6659    {
    6760        if (this->referenceCounter_ == 0)
     
    7366        this->referenceCounter_--;
    7467        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();
    8169        else
    8270            orxout(internal_info) << "Reduced reference count for plugin " << this->name_ << " to " << this->referenceCounter_ << endl;
    8371    }
     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    }
    8487}
  • code/trunk/src/libraries/core/module/Plugin.h

    r10552 r11014  
    4040            ~Plugin();
    4141
     42            void reference();
     43            void dereference();
     44
     45        private:
    4246            void load();
    4347            void unload();
    4448
    45         private:
    4649            std::string name_;
    4750            std::string libraryName_;
  • code/trunk/src/libraries/core/module/PluginManager.cc

    r10580 r11014  
    9090        Plugin* plugin = this->plugins_[name];
    9191        if (plugin != NULL)
    92             plugin->load();
     92            plugin->reference();
    9393        else
    9494            orxout(internal_warning) << "Cannot find plugin with name " << name << endl;
     
    9999        Plugin* plugin = this->plugins_[name];
    100100        if (plugin != NULL)
    101             plugin->unload();
     101            plugin->dereference();
    102102        else
    103103            orxout(internal_warning) << "Cannot find plugin with name " << name << endl;
Note: See TracChangeset for help on using the changeset viewer.