Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 6, 2015, 2:45:20 PM (10 years ago)
Author:
landauf
Message:

statically initialized instances may contain a type. currently not used.

Location:
code/branches/core7/src/libraries/core
Files:
9 edited

Legend:

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

    r10527 r10530  
    130130        // TODO: initialize NetworkFunctionManager here
    131131        this->rootModule_ = ModuleInstance::getCurrentModuleInstance();
    132         this->rootModule_->loadAllStaticallyInitializedInstances();
     132        this->rootModule_->loadAllStaticallyInitializedInstances(0);
    133133
    134134        // Parse command line arguments AFTER the modules have been loaded (static code!)
     
    246246        if (this->rootModule_)
    247247        {
    248             this->rootModule_->unloadAllStaticallyInitializedInstances();
     248            this->rootModule_->unloadAllStaticallyInitializedInstances(0);
    249249            this->rootModule_->deleteAllStaticallyInitializedInstances();
    250250        }
     
    287287        DynLib* dynLib = this->dynLibManager_->load(module->getName());
    288288        module->setDynLib(dynLib);
    289         module->loadAllStaticallyInitializedInstances();
     289        module->loadAllStaticallyInitializedInstances(0);
    290290        IdentifierManager::getInstance().createClassHierarchy();
    291291        ScopeManager::getInstance().updateListeners();
     
    307307        orxout(internal_info) << "Unloading module " << module->getName() << "..." << endl;
    308308
    309         module->unloadAllStaticallyInitializedInstances();
     309        module->unloadAllStaticallyInitializedInstances(0);
    310310        module->deleteAllStaticallyInitializedInstances();
    311311        this->dynLibManager_->unload(module->getDynLib());
  • code/branches/core7/src/libraries/core/CoreIncludes.h

    r10520 r10530  
    225225
    226226        public:
    227             StaticallyInitializedIdentifier(Identifier* identifier) : identifier_(identifier) {}
     227            StaticallyInitializedIdentifier(Identifier* identifier)
     228                : StaticallyInitializedInstance(0)
     229                , identifier_(identifier)
     230            {}
    228231            ~StaticallyInitializedIdentifier() { delete identifier_; }
    229232
  • code/branches/core7/src/libraries/core/command/ConsoleCommandIncludes.h

    r10520 r10530  
    310310    {
    311311        public:
    312             StaticallyInitializedConsoleCommand(ConsoleCommand* command) : command_(command) {}
     312            StaticallyInitializedConsoleCommand(ConsoleCommand* command)
     313                : StaticallyInitializedInstance(0)
     314                , command_(command)
     315            {}
    313316            ~StaticallyInitializedConsoleCommand() { delete command_; }
    314317
  • code/branches/core7/src/libraries/core/commandline/CommandLineIncludes.h

    r10520 r10530  
    5858    {
    5959        public:
    60             StaticallyInitializedCommandLineArgument(CommandLineArgument* argument) : argument_(argument) {}
     60            StaticallyInitializedCommandLineArgument(CommandLineArgument* argument)
     61                : StaticallyInitializedInstance(0)
     62                , argument_(argument)
     63            {}
    6164            ~StaticallyInitializedCommandLineArgument() { delete argument_; }
    6265
  • code/branches/core7/src/libraries/core/module/ModuleInstance.cc

    r10521 r10530  
    4848    void ModuleInstance::addStaticallyInitializedInstance(StaticallyInitializedInstance* instance)
    4949    {
    50         this->staticallyInitializedInstances_.insert(instance);
    51     }
    52 
    53     void ModuleInstance::loadAllStaticallyInitializedInstances()
    54     {
    55         for (std::set<StaticallyInitializedInstance*>::iterator it = this->staticallyInitializedInstances_.begin(); it != this->staticallyInitializedInstances_.end(); ++it)
    56             (*it)->load();
    57     }
    58 
    59     void ModuleInstance::unloadAllStaticallyInitializedInstances()
    60     {
    61         for (std::set<StaticallyInitializedInstance*>::iterator it = this->staticallyInitializedInstances_.begin(); it != this->staticallyInitializedInstances_.end(); ++it)
    62             (*it)->unload();
     50        this->staticallyInitializedInstancesByType_[instance->getType()].insert(instance);
    6351    }
    6452
    6553    void ModuleInstance::removeStaticallyInitializedInstance(StaticallyInitializedInstance* instance)
    6654    {
    67         this->staticallyInitializedInstances_.erase(instance);
     55        this->staticallyInitializedInstancesByType_[instance->getType()].erase(instance);
     56    }
     57
     58    void ModuleInstance::loadAllStaticallyInitializedInstances(StaticallyInitializedInstance::Type type)
     59    {
     60        const std::set<StaticallyInitializedInstance*>& instances = this->staticallyInitializedInstancesByType_[type];
     61        for (std::set<StaticallyInitializedInstance*>::iterator it = instances.begin(); it != instances.end(); ++it)
     62            (*it)->load();
     63    }
     64
     65    void ModuleInstance::unloadAllStaticallyInitializedInstances(StaticallyInitializedInstance::Type type)
     66    {
     67        const std::set<StaticallyInitializedInstance*>& instances = this->staticallyInitializedInstancesByType_[type];
     68        for (std::set<StaticallyInitializedInstance*>::iterator it = instances.begin(); it != instances.end(); ++it)
     69            (*it)->unload();
    6870    }
    6971
    7072    void ModuleInstance::deleteAllStaticallyInitializedInstances()
    7173    {
    72         std::set<StaticallyInitializedInstance*> copy(this->staticallyInitializedInstances_);
    73         this->staticallyInitializedInstances_.clear();
    74         for (std::set<StaticallyInitializedInstance*>::iterator it = copy.begin(); it != copy.end(); ++it)
    75             delete (*it);
     74        std::map<StaticallyInitializedInstance::Type, std::set<StaticallyInitializedInstance*> > copy(this->staticallyInitializedInstancesByType_);
     75        this->staticallyInitializedInstancesByType_.clear();
     76        for (std::map<StaticallyInitializedInstance::Type, std::set<StaticallyInitializedInstance*> >::iterator it1 = copy.begin(); it1 != copy.end(); ++it1)
     77            for (std::set<StaticallyInitializedInstance*>::iterator it2 = it1->second.begin(); it2 != it1->second.end(); ++it2)
     78                delete (*it2);
    7679    }
    7780
  • code/branches/core7/src/libraries/core/module/ModuleInstance.h

    r10518 r10530  
    3333
    3434#include <set>
     35#include <map>
    3536#include <string>
     37
     38#include "StaticallyInitializedInstance.h"
    3639
    3740namespace orxonox
     
    4447
    4548            void addStaticallyInitializedInstance(StaticallyInitializedInstance* instance);
    46             void loadAllStaticallyInitializedInstances();
    47             void unloadAllStaticallyInitializedInstances();
    4849            void removeStaticallyInitializedInstance(StaticallyInitializedInstance* instance);
     50
     51            void loadAllStaticallyInitializedInstances(StaticallyInitializedInstance::Type type);
     52            void unloadAllStaticallyInitializedInstances(StaticallyInitializedInstance::Type type);
     53
    4954            void deleteAllStaticallyInitializedInstances();
    5055
     
    6166
    6267        private:
    63             std::set<StaticallyInitializedInstance*> staticallyInitializedInstances_;
     68            std::map<StaticallyInitializedInstance::Type, std::set<StaticallyInitializedInstance*> > staticallyInitializedInstancesByType_;
    6469            std::string name_;
    6570            DynLib* dynLib_;
  • code/branches/core7/src/libraries/core/module/StaticallyInitializedInstance.cc

    r10522 r10530  
    3333namespace orxonox
    3434{
    35     StaticallyInitializedInstance::StaticallyInitializedInstance()
     35    StaticallyInitializedInstance::StaticallyInitializedInstance(Type type)
    3636    {
     37        this->type_ = type;
    3738        this->module_ = ModuleInstance::getCurrentModuleInstance();
    3839        this->module_->addStaticallyInitializedInstance(this);
  • code/branches/core7/src/libraries/core/module/StaticallyInitializedInstance.h

    r10522 r10530  
    3737    {
    3838        public:
    39             StaticallyInitializedInstance();
     39            typedef int Type;
     40
     41            StaticallyInitializedInstance(Type type);
    4042            virtual ~StaticallyInitializedInstance();
    4143
     
    4345            virtual void unload() = 0;
    4446
     47            inline Type getType() const
     48                { return this->type_; }
     49
    4550        private:
    4651            ModuleInstance* module_;
     52            Type type_;
    4753    };
    4854}
  • code/branches/core7/src/libraries/core/singleton/ScopedSingletonIncludes.h

    r10520 r10530  
    8181        public:
    8282            StaticallyInitializedScopedSingletonWrapper(ScopedSingletonWrapper* wrapper, ScopeID::Value scope)
    83                 : wrapper_(wrapper)
     83                : StaticallyInitializedInstance(0)
     84                , wrapper_(wrapper)
    8485                , scope_(scope)
    8586            {}
Note: See TracChangeset for help on using the changeset viewer.