Changeset 10474 for code/branches/core7/src/libraries/network
- Timestamp:
- May 25, 2015, 2:14:16 PM (9 years ago)
- Location:
- code/branches/core7/src/libraries/network
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core7/src/libraries/network/FunctionCall.cc
r10473 r10474 47 47 48 48 bool FunctionCall::execute(){ 49 NetworkFunctionBase* fct = static_cast<NetworkFunctionStatic*>(NetworkFunctionManager::get Function( this->functionID_ ));49 NetworkFunctionBase* fct = static_cast<NetworkFunctionStatic*>(NetworkFunctionManager::getInstance().getFunction( this->functionID_ )); 50 50 assert( this->nrOfArguments_==this->arguments_.size() ); 51 51 switch(this->nrOfArguments_) -
code/branches/core7/src/libraries/network/NetworkFunction.cc
r10471 r10474 38 38 39 39 this->name_ = name; 40 NetworkFunctionManager::get NameMap()[name] = this;41 NetworkFunctionManager::get FunctorMap()[p] = this;42 NetworkFunctionManager::getI dMap()[this->getNetworkID()] = this;40 NetworkFunctionManager::getInstance().getNameMap()[name] = this; 41 NetworkFunctionManager::getInstance().getFunctorMap()[p] = this; 42 NetworkFunctionManager::getInstance().getIdMap()[this->getNetworkID()] = this; 43 43 } 44 44 45 45 void NetworkFunctionBase::setNetworkID(uint32_t id) 46 46 { 47 NetworkFunctionManager::getI dMap().erase(this->networkID_); // remove old id47 NetworkFunctionManager::getInstance().getIdMap().erase(this->networkID_); // remove old id 48 48 this->networkID_ = id; 49 NetworkFunctionManager::getI dMap()[this->networkID_] = this; // add new id49 NetworkFunctionManager::getInstance().getIdMap()[this->networkID_] = this; // add new id 50 50 } 51 51 } -
code/branches/core7/src/libraries/network/NetworkFunctionIncludes.h
r10473 r10474 51 51 NetworkFunctionPointer p1; \ 52 52 copyPtr( functionPointer, p1 ); \ 53 FunctionCallManager::addCall(NetworkFunctionManager::get Function(p1)->getNetworkID(), OBJECTID_UNKNOWN, __VA_ARGS__); \53 FunctionCallManager::addCall(NetworkFunctionManager::getInstance().getFunction(p1)->getNetworkID(), OBJECTID_UNKNOWN, __VA_ARGS__); \ 54 54 } 55 55 … … 59 59 NetworkFunctionPointer p1; \ 60 60 copyPtr( &class::function, p1 ); \ 61 FunctionCallManager::addCall(NetworkFunctionManager::get Function(p1)->getNetworkID(), objectID, __VA_ARGS__); \61 FunctionCallManager::addCall(NetworkFunctionManager::getInstance().getFunction(p1)->getNetworkID(), objectID, __VA_ARGS__); \ 62 62 } 63 63 -
code/branches/core7/src/libraries/network/NetworkFunctionManager.cc
r10471 r10474 32 32 namespace orxonox 33 33 { 34 std::map<NetworkFunctionPointer, NetworkFunctionBase*> NetworkFunctionManager::functorMap_;35 std::map<uint32_t, NetworkFunctionBase*> NetworkFunctionManager::idMap_;36 37 34 /* static */NetworkFunctionManager& NetworkFunctionManager::getInstance() 38 35 { … … 41 38 } 42 39 43 /*static*/void NetworkFunctionManager::setNetworkID(const std::string& name, uint32_t id)40 void NetworkFunctionManager::setNetworkID(const std::string& name, uint32_t id) 44 41 { 45 std::map<std::string, NetworkFunctionBase*>& map = NetworkFunctionManager::getNameMap();42 std::map<std::string, NetworkFunctionBase*>& map = this->nameMap_; 46 43 assert( map.find(name)!=map.end() ); 47 44 map[name]->setNetworkID(id); 48 45 } 49 46 50 /*static*/void NetworkFunctionManager::destroyAllNetworkFunctions()47 void NetworkFunctionManager::destroyAllNetworkFunctions() 51 48 { 52 std::map<std::string, NetworkFunctionBase*>& map = NetworkFunctionManager::getNameMap();49 std::map<std::string, NetworkFunctionBase*>& map = this->nameMap_; 53 50 std::map<std::string, NetworkFunctionBase*>::iterator it; 54 51 for (it = map.begin(); it != map.end(); ++it) … … 56 53 } 57 54 58 /*static*/std::map<std::string, NetworkFunctionBase*>& NetworkFunctionManager::getNameMap() 59 { 60 static std::map<std::string, NetworkFunctionBase*> nameMap_; 61 return nameMap_; 62 } 63 64 /*static*/NetworkFunctionBase* NetworkFunctionManager::getFunction(const NetworkFunctionPointer& p) 55 NetworkFunctionBase* NetworkFunctionManager::getFunction(const NetworkFunctionPointer& p) 65 56 { 66 57 std::map<NetworkFunctionPointer, NetworkFunctionBase*>::iterator it = functorMap_.find(p); … … 69 60 } 70 61 71 /*static*/NetworkFunctionBase* NetworkFunctionManager::getFunction(uint32_t id)62 NetworkFunctionBase* NetworkFunctionManager::getFunction(uint32_t id) 72 63 { 73 64 std::map<uint32_t, NetworkFunctionBase*>::iterator it = idMap_.find(id); -
code/branches/core7/src/libraries/network/NetworkFunctionManager.h
r10471 r10474 42 42 static NetworkFunctionManager& getInstance(); 43 43 44 static void setNetworkID(const std::string& name, uint32_t id); 45 static void destroyAllNetworkFunctions(); 46 static std::map<std::string, NetworkFunctionBase*>& getNameMap(); 44 void setNetworkID(const std::string& name, uint32_t id); 45 void destroyAllNetworkFunctions(); 47 46 48 static inline std::map<NetworkFunctionPointer, NetworkFunctionBase*>& getFunctorMap() 47 inline std::map<std::string, NetworkFunctionBase*>& getNameMap() 48 { return nameMap_; } 49 inline std::map<NetworkFunctionPointer, NetworkFunctionBase*>& getFunctorMap() 49 50 { return functorMap_; } 50 staticinline std::map<uint32_t, NetworkFunctionBase*>& getIdMap()51 inline std::map<uint32_t, NetworkFunctionBase*>& getIdMap() 51 52 { return idMap_; } 52 53 53 staticNetworkFunctionBase* getFunction(const NetworkFunctionPointer& p);54 staticNetworkFunctionBase* getFunction(uint32_t id);54 NetworkFunctionBase* getFunction(const NetworkFunctionPointer& p); 55 NetworkFunctionBase* getFunction(uint32_t id); 55 56 56 57 private: 57 static std::map<NetworkFunctionPointer, NetworkFunctionBase*> functorMap_; 58 static std::map<uint32_t, NetworkFunctionBase*> idMap_; 58 std::map<std::string, NetworkFunctionBase*> nameMap_; 59 std::map<NetworkFunctionPointer, NetworkFunctionBase*> functorMap_; 60 std::map<uint32_t, NetworkFunctionBase*> idMap_; 59 61 }; 60 62 } -
code/branches/core7/src/libraries/network/packet/FunctionIDs.cc
r10470 r10474 56 56 57 57 //calculate total needed size (for all strings and integers) 58 std::map<std::string, NetworkFunctionBase*>& map = NetworkFunctionManager::get NameMap();58 std::map<std::string, NetworkFunctionBase*>& map = NetworkFunctionManager::getInstance().getNameMap(); 59 59 std::map<std::string, NetworkFunctionBase*>::iterator it; 60 60 for (it = map.begin(); it != map.end(); ++it) … … 140 140 functionname = temp+2*sizeof(uint32_t); 141 141 orxout(internal_info, context::packets) << "processing functionid: " << networkID << " name: " << functionname << endl; 142 NetworkFunctionManager:: setNetworkID((const char*)functionname, networkID);142 NetworkFunctionManager::getInstance().setNetworkID((const char*)functionname, networkID); 143 143 temp += 2*sizeof(uint32_t) + stringsize; 144 144 }
Note: See TracChangeset
for help on using the changeset viewer.