Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 7, 2015, 2:16:55 PM (9 years ago)
Author:
landauf
Message:

clean and explicit setup/shutdown of singletons that are used by statically initialized instances

Location:
code/branches/core7/src/libraries/network
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core7/src/libraries/network/NetworkFunctionManager.cc

    r10520 r10542  
    3232namespace orxonox
    3333{
    34     /* static */NetworkFunctionManager& NetworkFunctionManager::getInstance()
    35     {
    36         static NetworkFunctionManager instance;
    37         return instance;
    38     }
     34    NetworkFunctionManager* NetworkFunctionManager::singletonPtr_s = 0;
    3935
    4036    void NetworkFunctionManager::registerFunction(NetworkFunctionBase* function)
  • code/branches/core7/src/libraries/network/NetworkFunctionManager.h

    r10520 r10542  
    3636#include <set>
    3737
     38#include "util/Singleton.h"
     39#include "NetworkFunction.h"
     40
    3841namespace orxonox
    3942{
    40     class _NetworkExport NetworkFunctionManager
     43    class _NetworkExport NetworkFunctionManager : public Singleton<NetworkFunctionManager>
    4144    {
     45        friend class Singleton<NetworkFunctionManager>;
     46
    4247        public:
    43             static NetworkFunctionManager& getInstance();
    44 
    4548            void registerFunction(NetworkFunctionBase* function);
    4649            void unregisterFunction(NetworkFunctionBase* function);
     
    5861            std::map<NetworkFunctionPointer, NetworkFunctionBase*> functorMap_;
    5962            std::map<uint32_t, NetworkFunctionBase*> idMap_;
     63
     64            static NetworkFunctionManager* singletonPtr_s;
    6065    };
    6166}
  • code/branches/core7/src/libraries/network/NetworkStaticInitializationHandler.cc

    r10535 r10542  
    3030
    3131#include "core/module/ModuleInstance.h"
     32#include "NetworkFunctionManager.h"
    3233
    3334namespace orxonox
     
    3536    void NetworkStaticInitializationHandler::setupHandler()
    3637    {
    37         // TODO
     38        // initialize singleton
     39        new NetworkFunctionManager();
    3840    }
    3941
    4042    void NetworkStaticInitializationHandler::shutdownHandler()
    4143    {
    42         // TODO
     44        delete &NetworkFunctionManager::getInstance();
    4345    }
    4446
Note: See TracChangeset for help on using the changeset viewer.