Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10520 for code/branches


Ignore:
Timestamp:
May 31, 2015, 11:54:06 AM (9 years ago)
Author:
landauf
Message:

StaticallyInitializedInstances are now responsible to delete the wrapped object.

Location:
code/branches/core7/src
Files:
16 edited

Legend:

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

    r10518 r10520  
    241241        safeObjectDelete(&languageInstance_);
    242242        safeObjectDelete(&configFileManager_);
    243         ConsoleCommandManager::getInstance().destroyAll();
    244243        Context::setRootContext(NULL);
    245         IdentifierManager::getInstance().destroyAllIdentifiers();
    246244        safeObjectDelete(&signalHandler_);
    247245//        if (this->rootModule_)
  • code/branches/core7/src/libraries/core/CoreIncludes.h

    r10512 r10520  
    226226        public:
    227227            StaticallyInitializedIdentifier(Identifier* identifier) : identifier_(identifier) {}
     228            ~StaticallyInitializedIdentifier() { delete identifier_; }
    228229
    229230            virtual void load()
  • code/branches/core7/src/libraries/core/class/IdentifierManager.cc

    r10519 r10520  
    277277        this->identifierByNetworkId_.clear();
    278278    }
    279 
    280     /**
    281         @brief Destroys all Identifiers. Called when exiting the program.
    282     */
    283     void IdentifierManager::destroyAllIdentifiers()
    284     {
    285         for (std::set<Identifier*>::iterator it = this->identifiers_.begin(); it != this->identifiers_.end(); ++it)
    286             delete (*it);
    287 
    288         this->identifiers_.clear();
    289         this->identifierByString_.clear();
    290         this->identifierByLowercaseString_.clear();
    291         this->identifierByNetworkId_.clear();
    292     }
    293279}
  • code/branches/core7/src/libraries/core/class/IdentifierManager.h

    r10519 r10520  
    8787                { return this->identifierByNetworkId_; }
    8888
    89             void destroyAllIdentifiers();
    90 
    9189        private:
    9290            IdentifierManager();
  • code/branches/core7/src/libraries/core/command/ConsoleCommand.cc

    r10484 r10520  
    9292    ConsoleCommand::~ConsoleCommand()
    9393    {
    94         ConsoleCommandManager::getInstance().unregisterCommand(this);
    9594    }
    9695
  • code/branches/core7/src/libraries/core/command/ConsoleCommandIncludes.h

    r10484 r10520  
    311311        public:
    312312            StaticallyInitializedConsoleCommand(ConsoleCommand* command) : command_(command) {}
     313            ~StaticallyInitializedConsoleCommand() { delete command_; }
    313314
    314315            virtual void load();
  • code/branches/core7/src/libraries/core/command/ConsoleCommandManager.cc

    r10484 r10520  
    191191        }
    192192    }
    193 
    194     /**
    195         @brief Deletes all commands
    196     */
    197     void ConsoleCommandManager::destroyAll()
    198     {
    199         // delete entries until the map is empty
    200         while (!this->commandMap_.empty() && !this->commandMap_.begin()->second.empty())
    201             delete this->commandMap_.begin()->second.begin()->second;
    202     }
    203193}
  • code/branches/core7/src/libraries/core/command/ConsoleCommandManager.h

    r10484 r10520  
    6868            ConsoleCommand* getCommandLC(const std::string& group, const std::string& name, bool bPrintError = false);
    6969
    70             void destroyAll();
    71 
    7270        private:
    7371            std::map<std::string, std::map<std::string, ConsoleCommand*> > commandMap_;
  • code/branches/core7/src/libraries/core/commandline/CommandLineIncludes.h

    r10404 r10520  
    5959        public:
    6060            StaticallyInitializedCommandLineArgument(CommandLineArgument* argument) : argument_(argument) {}
     61            ~StaticallyInitializedCommandLineArgument() { delete argument_; }
    6162
    6263            virtual void load()
  • code/branches/core7/src/libraries/core/commandline/CommandLineParser.cc

    r10509 r10520  
    8585    CommandLineParser::~CommandLineParser()
    8686    {
    87         CommandLineParser::destroyAllArguments();
    8887    }
    8988
     
    9695        static CommandLineParser instance;
    9796        return instance;
    98     }
    99 
    100     /**
    101     @brief
    102         Destroys all command line arguments. This should be called at the end
    103         of main. Do not use before that.
    104     */
    105     void CommandLineParser::destroyAllArguments()
    106     {
    107         for (std::map<std::string, CommandLineArgument*>::const_iterator it = _getInstance().cmdLineArgs_.begin();
    108             it != _getInstance().cmdLineArgs_.end(); ++it)
    109             delete it->second;
    110         _getInstance().cmdLineArgs_.clear();
    11197    }
    11298
  • code/branches/core7/src/libraries/core/commandline/CommandLineParser.h

    r10404 r10520  
    161161        }
    162162
    163         static void destroyAllArguments();
    164 
    165163        static void generateDoc(std::ofstream& file);
    166164
  • code/branches/core7/src/libraries/core/singleton/ScopedSingletonIncludes.h

    r10514 r10520  
    8484                , scope_(scope)
    8585            {}
     86            ~StaticallyInitializedScopedSingletonWrapper() { delete wrapper_; }
    8687
    8788            virtual void load();
  • code/branches/core7/src/libraries/network/NetworkFunctionIncludes.h

    r10478 r10520  
    5252        public:
    5353            StaticallyInitializedNetworkFunction(NetworkFunctionBase* function) : function_(function) {}
     54            ~StaticallyInitializedNetworkFunction() { delete function_; }
    5455
    5556            virtual void load();
  • code/branches/core7/src/libraries/network/NetworkFunctionManager.cc

    r10475 r10520  
    5454    }
    5555
    56     void NetworkFunctionManager::destroyAllNetworkFunctions()
    57     {
    58         std::set<NetworkFunctionBase*>::iterator it;
    59         for (it = this->functions_.begin(); it != this->functions_.end(); ++it)
    60             delete (*it);
    61     }
    62 
    6356    NetworkFunctionBase* NetworkFunctionManager::getFunctionByName(const std::string& name)
    6457    {
  • code/branches/core7/src/libraries/network/NetworkFunctionManager.h

    r10475 r10520  
    4646            void unregisterFunction(NetworkFunctionBase* function);
    4747
    48             void destroyAllNetworkFunctions();
    49 
    5048            inline const std::set<NetworkFunctionBase*>& getAllFunctions()
    5149                { return functions_; }
  • code/branches/core7/src/orxonox/gamestates/GSRoot.cc

    r10474 r10520  
    3535#include "core/command/ConsoleCommandIncludes.h"
    3636#include "network/NetworkFunctionIncludes.h"
    37 #include "network/NetworkFunctionManager.h"
    3837#include "tools/Timer.h"
    3938#include "tools/interfaces/Tickable.h"
     
    6968    GSRoot::~GSRoot()
    7069    {
    71         NetworkFunctionManager::getInstance().destroyAllNetworkFunctions();
    7270    }
    7371
Note: See TracChangeset for help on using the changeset viewer.