Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10530


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

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

Location:
code/branches/core7
Files:
23 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            {}
  • code/branches/core7/src/libraries/network/NetworkFunctionIncludes.h

    r10520 r10530  
    5151    {
    5252        public:
    53             StaticallyInitializedNetworkFunction(NetworkFunctionBase* function) : function_(function) {}
     53            StaticallyInitializedNetworkFunction(NetworkFunctionBase* function)
     54                : StaticallyInitializedInstance(0)
     55                , function_(function)
     56            {}
    5457            ~StaticallyInitializedNetworkFunction() { delete function_; }
    5558
  • code/branches/core7/test/core/class/IdentifierClassHierarchyTest.cc

    r10405 r10530  
    142142                virtual void SetUp()
    143143                {
    144                     ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances();
     144                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(0);
    145145                    Identifier::initConfigValues_s = false; // TODO: hack!
    146146                    IdentifierManager::getInstance().createClassHierarchy();
     
    150150                {
    151151                    IdentifierManager::getInstance().destroyClassHierarchy();
    152                     ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances();
     152                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(0);
    153153                }
    154154        };
  • code/branches/core7/test/core/class/IdentifierExternalClassHierarchyTest.cc

    r10405 r10530  
    4949                virtual void SetUp()
    5050                {
    51                     ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances();
     51                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(0);
    5252                    Identifier::initConfigValues_s = false; // TODO: hack!
    5353                    IdentifierManager::getInstance().createClassHierarchy();
     
    5757                {
    5858                    IdentifierManager::getInstance().destroyClassHierarchy();
    59                     ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances();
     59                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(0);
    6060                }
    6161        };
  • code/branches/core7/test/core/class/IdentifierNestedClassHierarchyTest.cc

    r10405 r10530  
    109109                virtual void SetUp()
    110110                {
    111                     ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances();
     111                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(0);
    112112                    Identifier::initConfigValues_s = false; // TODO: hack!
    113113                    IdentifierManager::getInstance().createClassHierarchy();
     
    117117                {
    118118                    IdentifierManager::getInstance().destroyClassHierarchy();
    119                     ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances();
     119                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(0);
    120120                }
    121121        };
  • code/branches/core7/test/core/class/IdentifierSimpleClassHierarchyTest.cc

    r10405 r10530  
    5151                virtual void SetUp()
    5252                {
    53                     ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances();
     53                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(0);
    5454                    Identifier::initConfigValues_s = false; // TODO: hack!
    5555                    IdentifierManager::getInstance().createClassHierarchy();
     
    5959                {
    6060                    IdentifierManager::getInstance().destroyClassHierarchy();
    61                     ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances();
     61                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(0);
    6262                }
    6363        };
  • code/branches/core7/test/core/class/SubclassIdentifierTest.cc

    r10405 r10530  
    3131                virtual void SetUp()
    3232                {
    33                     ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances();
     33                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(0);
    3434                    Identifier::initConfigValues_s = false; // TODO: hack!
    3535                    IdentifierManager::getInstance().createClassHierarchy();
     
    4343
    4444                    IdentifierManager::getInstance().destroyClassHierarchy();
    45                     ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances();
     45                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(0);
    4646                }
    4747        };
  • code/branches/core7/test/core/class/SuperTest.cc

    r10405 r10530  
    7272                virtual void SetUp()
    7373                {
    74                     ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances();
     74                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(0);
    7575                    Identifier::initConfigValues_s = false; // TODO: hack!
    7676                    IdentifierManager::getInstance().createClassHierarchy();
     
    8484
    8585                    IdentifierManager::getInstance().destroyClassHierarchy();
    86                     ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances();
     86                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(0);
    8787                }
    8888        };
  • code/branches/core7/test/core/command/CommandTest.cc

    r10405 r10530  
    140140                virtual void SetUp()
    141141                {
    142                     ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances();
     142                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(0);
    143143                    Identifier::initConfigValues_s = false; // TODO: hack!
    144144                    IdentifierManager::getInstance().createClassHierarchy();
     
    148148                {
    149149                    IdentifierManager::getInstance().destroyClassHierarchy();
    150                     ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances();
     150                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(0);
    151151                }
    152152        };
  • code/branches/core7/test/core/object/ClassFactoryTest.cc

    r10481 r10530  
    1616                {
    1717                    Context::setRootContext(new Context(NULL));
    18                     ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances();
     18                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(0);
    1919                }
    2020
    2121                virtual void TearDown()
    2222                {
    23                     ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances();
     23                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(0);
    2424                    Context::setRootContext(NULL);
    2525                }
  • code/branches/core7/test/core/object/ContextTest.cc

    r10481 r10530  
    2424                {
    2525                    Context::setRootContext(new Context(NULL));
    26                     ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances();
     26                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(0);
    2727                }
    2828
    2929                virtual void TearDown()
    3030                {
    31                     ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances();
     31                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(0);
    3232                    Context::setRootContext(NULL);
    3333                }
  • code/branches/core7/test/core/object/IteratorTest.cc

    r10481 r10530  
    3535                {
    3636                    Context::setRootContext(new Context(NULL));
    37                     ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances();
     37                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(0);
    3838                }
    3939
    4040                virtual void TearDown()
    4141                {
    42                     ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances();
     42                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(0);
    4343                    Context::setRootContext(NULL);
    4444                }
  • code/branches/core7/test/core/object/ListableTest.cc

    r10481 r10530  
    4040                {
    4141                    Context::setRootContext(new Context(NULL));
    42                     ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances();
     42                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(0);
    4343                }
    4444
    4545                virtual void TearDown()
    4646                {
    47                     ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances();
     47                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(0);
    4848                    Context::setRootContext(NULL);
    4949                }
  • code/branches/core7/test/core/object/ObjectListIteratorTest.cc

    r10481 r10530  
    2727                {
    2828                    Context::setRootContext(new Context(NULL));
    29                     ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances();
     29                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(0);
    3030                }
    3131
    3232                virtual void TearDown()
    3333                {
    34                     ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances();
     34                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(0);
    3535                    Context::setRootContext(NULL);
    3636                }
  • code/branches/core7/test/core/singleton/ScopeTest.cc

    r10464 r10530  
    2727                virtual void SetUp()
    2828                {
    29                     ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances();
     29                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(0);
    3030                }
    3131
    3232                virtual void TearDown()
    3333                {
    34                     ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances();
     34                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(0);
    3535                }
    3636        };
Note: See TracChangeset for help on using the changeset viewer.