Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 31, 2015, 10:56:32 AM (9 years ago)
Author:
landauf
Message:

load modules AFTER core was initialized. load each module with a separate ModuleInstance. unloading is not yet implemented…

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core7/src/libraries/core/Core.cc

    r10509 r10518  
    111111        , graphicsScope_(NULL)
    112112        , bGraphicsLoaded_(false)
     113        , rootModule_(NULL)
    113114        , config_(NULL)
    114115        , destructionHelper_(this)
     
    121122        // Create a new dynamic library manager
    122123        this->dynLibManager_ = new DynLibManager();
    123 
    124         // Load modules
    125         orxout(internal_info) << "Loading modules:" << endl;
    126         const std::vector<std::string>& modulePaths = ApplicationPaths::getInstance().getModulePaths();
    127         for (std::vector<std::string>::const_iterator it = modulePaths.begin(); it != modulePaths.end(); ++it)
    128         {
    129             try
    130             {
    131                 this->dynLibManager_->load(*it);
    132             }
    133             catch (...)
    134             {
    135                 orxout(user_error) << "Couldn't load module \"" << *it << "\": " << Exception::handleMessage() << endl;
    136             }
    137         }
    138124
    139125        // TODO: initialize Root-Context
     
    142128        // TODO: initialize CommandLineParser here
    143129        // TODO: initialize ConsoleCommandManager here
    144         ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances();
     130        this->rootModule_ = ModuleInstance::getCurrentModuleInstance();
     131        this->rootModule_->loadAllStaticallyInitializedInstances();
    145132
    146133        // Parse command line arguments AFTER the modules have been loaded (static code!)
     
    258245        IdentifierManager::getInstance().destroyAllIdentifiers();
    259246        safeObjectDelete(&signalHandler_);
     247//        if (this->rootModule_)
     248//            this->rootModule_->unloadAllStaticallyInitializedInstances();
     249//        safeObjectDelete(&rootModule_);
    260250        safeObjectDelete(&dynLibManager_);
    261251        safeObjectDelete(&configurablePaths_);
     
    263253
    264254        orxout(internal_status) << "finished destroying Core object" << endl;
     255    }
     256
     257    void Core::loadModules()
     258    {
     259        orxout(internal_info) << "Loading modules:" << endl;
     260
     261        const std::vector<std::string>& modulePaths = ApplicationPaths::getInstance().getModulePaths();
     262        for (std::vector<std::string>::const_iterator it = modulePaths.begin(); it != modulePaths.end(); ++it)
     263        {
     264            try
     265            {
     266                ModuleInstance* module = new ModuleInstance(*it);
     267                this->loadModule(module);
     268                this->modules_.push_back(module);
     269            }
     270            catch (...)
     271            {
     272                orxout(user_error) << "Couldn't load module \"" << *it << "\": " << Exception::handleMessage() << endl;
     273            }
     274        }
     275
     276        orxout(internal_info) << "finished loading modules" << endl;
     277    }
     278
     279    void Core::loadModule(ModuleInstance* module)
     280    {
     281        ModuleInstance::setCurrentModuleInstance(module);
     282        DynLib* dynLib = this->dynLibManager_->load(module->getName());
     283        module->setDynLib(dynLib);
     284        module->loadAllStaticallyInitializedInstances();
     285        IdentifierManager::getInstance().createClassHierarchy();
     286        ScopeManager::getInstance().updateListeners();
     287    }
     288
     289    void Core::unloadModules()
     290    {
     291        for (std::list<ModuleInstance*>::iterator it = this->modules_.begin(); it != this->modules_.end(); ++it)
     292        {
     293            ModuleInstance* module = (*it);
     294            this->unloadModule(module);
     295            delete module;
     296        }
     297        this->modules_.clear();
     298    }
     299
     300    void Core::unloadModule(ModuleInstance* module)
     301    {
     302        module->unloadAllStaticallyInitializedInstances();
     303        module->deleteAllStaticallyInitializedInstances();
     304        this->dynLibManager_->unload(module->getDynLib());
     305        module->setDynLib(NULL);
    265306    }
    266307
Note: See TracChangeset for help on using the changeset viewer.