Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 4, 2015, 9:12:21 PM (9 years ago)
Author:
landauf
Message:

merged branch core7 back to trunk

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/libraries/network/NetworkFunction.cc

    r9667 r10624  
    2828
    2929#include "NetworkFunction.h"
    30 #include "core/CoreIncludes.h"
     30#include "NetworkFunctionManager.h"
    3131
    3232namespace orxonox
    3333{
    34   std::map<uint32_t, bool> NetworkFunctionBase::isStaticMap_;
     34    NetworkFunctionBase::NetworkFunctionBase(const std::string& name, const NetworkFunctionPointer& pointer)
     35    {
     36        static uint32_t networkID = 0;
     37        this->networkID_ = networkID++;
     38        this->name_ = name;
     39        this->pointer_ = pointer;
     40    }
    3541
    36   std::map<NetworkFunctionPointer, NetworkMemberFunctionBase*> NetworkMemberFunctionBase::functorMap_;
    37   std::map<uint32_t, NetworkMemberFunctionBase*> NetworkMemberFunctionBase::idMap_;
    38 
    39   // no suitable factory for NetworkFunctionBase (and children), so we declare it abstract
    40   RegisterAbstractClass(NetworkFunctionBase).inheritsFrom(Class(Listable));
    41   RegisterAbstractClass(NetworkFunctionStatic).inheritsFrom(Class(NetworkFunctionBase));
    42   RegisterAbstractClass(NetworkMemberFunctionBase).inheritsFrom(Class(NetworkFunctionBase));
    43 
    44   NetworkFunctionBase::NetworkFunctionBase(const std::string& name)
    45   {
    46       RegisterObject(NetworkFunctionBase);
    47 
    48     static uint32_t networkID = 0;
    49     this->networkID_ = networkID++;
    50 
    51     this->name_ = name;
    52     NetworkFunctionBase::getNameMap()[name] = this;
    53   }
    54   NetworkFunctionBase::~NetworkFunctionBase()
    55   {
    56   }
    57 
    58 
    59   void NetworkFunctionBase::destroyAllNetworkFunctions()
    60   {
    61     std::map<std::string, NetworkFunctionBase*>& map = NetworkFunctionBase::getNameMap();
    62     std::map<std::string, NetworkFunctionBase*>::iterator it;
    63     for( it=map.begin(); it!=map.end(); ++it )
    64       delete it->second;
    65   }
    66 
    67 
    68   /*static*/ std::map<std::string, NetworkFunctionBase*>& NetworkFunctionBase::getNameMap()
    69   {
    70     static std::map<std::string, NetworkFunctionBase*> nameMap_;
    71     return nameMap_;
    72   }
    73 
    74 
    75   NetworkFunctionStatic::NetworkFunctionStatic(const FunctorStaticPtr& functor, const std::string& name, const NetworkFunctionPointer& p):
    76     NetworkFunctionBase(name)
    77   {
    78     RegisterObject(NetworkFunctionStatic);
    79 
    80     this->functor_ = functor;
    81     NetworkFunctionStatic::getFunctorMap()[p] = this;
    82     NetworkFunctionStatic::getIdMap()[ this->getNetworkID() ] = this;
    83   }
    84 
    85   /*static*/ std::map<NetworkFunctionPointer, NetworkFunctionStatic*>& NetworkFunctionStatic::getFunctorMap()
    86   {
    87     static std::map<NetworkFunctionPointer, NetworkFunctionStatic*> functorMap_;
    88     return functorMap_;
    89   }
    90 
    91   /*static*/ std::map<uint32_t, NetworkFunctionStatic*>& NetworkFunctionStatic::getIdMap()
    92   {
    93     static std::map<uint32_t, NetworkFunctionStatic*> idMap_;
    94     return idMap_;
    95   }
    96 
    97 
    98   NetworkMemberFunctionBase::NetworkMemberFunctionBase(const std::string& name, const NetworkFunctionPointer& p):
    99     NetworkFunctionBase(name)
    100   {
    101     RegisterObject(NetworkMemberFunctionBase);
    102 
    103     this->functorMap_[p] = this;
    104     this->idMap_[ this->getNetworkID() ] = this;
    105   }
    106 
    107   NetworkMemberFunctionBase::~NetworkMemberFunctionBase()
    108   {
    109   }
    110 
    111 
     42    void NetworkFunctionBase::setNetworkID(uint32_t id)
     43    {
     44        this->networkID_ = id;
     45        NetworkFunctionManager::getInstance().registerFunction(this);   // register with new id
     46    }
    11247}
Note: See TracChangeset for help on using the changeset viewer.