- Timestamp:
- May 25, 2015, 2:41:57 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core7/src/libraries/network/NetworkFunctionManager.cc
r10474 r10475 38 38 } 39 39 40 void NetworkFunctionManager:: setNetworkID(const std::string& name, uint32_t id)40 void NetworkFunctionManager::registerFunction(NetworkFunctionBase* function) 41 41 { 42 std::map<std::string, NetworkFunctionBase*>& map = this->nameMap_; 43 assert( map.find(name)!=map.end() ); 44 map[name]->setNetworkID(id); 42 this->functions_.insert(function); 43 this->nameMap_[function->getName()] = function; 44 this->idMap_[function->getNetworkID()] = function; 45 this->functorMap_[function->getPointer()] = function; 46 } 47 48 void NetworkFunctionManager::unregisterFunction(NetworkFunctionBase* function) 49 { 50 this->functions_.erase(function); 51 this->nameMap_.erase(function->getName()); 52 this->idMap_.erase(function->getNetworkID()); 53 this->functorMap_.erase(function->getPointer()); 45 54 } 46 55 47 56 void NetworkFunctionManager::destroyAllNetworkFunctions() 48 57 { 49 std::map<std::string, NetworkFunctionBase*>& map = this->nameMap_; 50 std::map<std::string, NetworkFunctionBase*>::iterator it; 51 for (it = map.begin(); it != map.end(); ++it) 52 delete it->second; 58 std::set<NetworkFunctionBase*>::iterator it; 59 for (it = this->functions_.begin(); it != this->functions_.end(); ++it) 60 delete (*it); 53 61 } 54 62 55 NetworkFunctionBase* NetworkFunctionManager::getFunction(const NetworkFunctionPointer& p) 63 NetworkFunctionBase* NetworkFunctionManager::getFunctionByName(const std::string& name) 64 { 65 std::map<std::string, NetworkFunctionBase*>::iterator it = nameMap_.find(name); 66 assert(it != nameMap_.end()); 67 return it->second; 68 } 69 70 NetworkFunctionBase* NetworkFunctionManager::getFunctionByFunctionPointer(const NetworkFunctionPointer& p) 56 71 { 57 72 std::map<NetworkFunctionPointer, NetworkFunctionBase*>::iterator it = functorMap_.find(p); … … 60 75 } 61 76 62 NetworkFunctionBase* NetworkFunctionManager::getFunction (uint32_t id)77 NetworkFunctionBase* NetworkFunctionManager::getFunctionByNetworkId(uint32_t id) 63 78 { 64 79 std::map<uint32_t, NetworkFunctionBase*>::iterator it = idMap_.find(id);
Note: See TracChangeset
for help on using the changeset viewer.