Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

moved code for loading/unloading a plugin into separate functions

File:
1 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}
Note: See TracChangeset for help on using the changeset viewer.