- Timestamp:
- Aug 11, 2013, 9:07:38 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core6/src/libraries/core/class/IdentifierManager.cc
r9634 r9640 43 43 namespace orxonox 44 44 { 45 int IdentifierManager::hierarchyCreatingCounter_s = 0; 46 unsigned int IdentifierManager::classIDCounter_s = 0; 45 /* static */ IdentifierManager& IdentifierManager::getInstance() 46 { 47 static IdentifierManager instance; 48 return instance; 49 } 47 50 48 /** 49 @brief Returns the identifier map with the names as received by typeid(). This is only used internally. 50 */ 51 std::map<std::string, Identifier*>& IdentifierManager::getTypeIDIdentifierMap() 51 IdentifierManager::IdentifierManager() 52 52 { 53 static std::map<std::string, Identifier*> identifiers; //!< The map to store all Identifiers.54 return identifiers;53 this->hierarchyCreatingCounter_s = 0; 54 this->classIDCounter_s = 0; 55 55 } 56 56 … … 63 63 Identifier* IdentifierManager::getIdentifierSingleton(const std::string& name, Identifier* proposal) 64 64 { 65 std::map<std::string, Identifier*>::const_iterator it = getTypeIDIdentifierMap().find(name);65 std::map<std::string, Identifier*>::const_iterator it = this->identifierByTypeId_.find(name); 66 66 67 if (it != getTypeIDIdentifierMap().end())67 if (it != this->identifierByTypeId_.end()) 68 68 { 69 69 // There is already an entry: return it and delete the proposal … … 74 74 { 75 75 // There is no entry: put the proposal into the map and return it 76 getTypeIDIdentifierMap()[name] = proposal;76 this->identifierByTypeId_[name] = proposal; 77 77 return proposal; 78 78 } … … 85 85 { 86 86 orxout(internal_status) << "Create class-hierarchy" << endl; 87 IdentifierManager::startCreatingHierarchy();88 for (std::map<std::string, Identifier*>::const_iterator it = IdentifierManager::getTypeIDIdentifierMap().begin(); it != IdentifierManager::getTypeIDIdentifierMap().end(); ++it)87 this->startCreatingHierarchy(); 88 for (std::map<std::string, Identifier*>::const_iterator it = this->identifierByTypeId_.begin(); it != this->identifierByTypeId_.end(); ++it) 89 89 { 90 90 // To create the new branch of the class-hierarchy, we create a new object and delete it afterwards. … … 95 95 } 96 96 } 97 IdentifierManager::stopCreatingHierarchy();97 this->stopCreatingHierarchy(); 98 98 orxout(internal_status) << "Finished class-hierarchy creation" << endl; 99 99 } … … 104 104 void IdentifierManager::destroyAllIdentifiers() 105 105 { 106 for (std::map<std::string, Identifier*>::iterator it = IdentifierManager::getTypeIDIdentifierMap().begin(); it != IdentifierManager::getTypeIDIdentifierMap().end(); ++it)106 for (std::map<std::string, Identifier*>::iterator it = this->identifierByTypeId_.begin(); it != this->identifierByTypeId_.end(); ++it) 107 107 delete (it->second); 108 108 109 IdentifierManager::getTypeIDIdentifierMap().clear(); 110 IdentifierManager::getStringIdentifierMapIntern().clear(); 111 IdentifierManager::getLowercaseStringIdentifierMapIntern().clear(); 112 IdentifierManager::getIDIdentifierMapIntern().clear(); 113 } 114 115 /** 116 @brief Returns the map that stores all Identifiers with their names. 117 @return The map 118 */ 119 std::map<std::string, Identifier*>& IdentifierManager::getStringIdentifierMapIntern() 120 { 121 static std::map<std::string, Identifier*> identifierMap; 122 return identifierMap; 123 } 124 125 /** 126 @brief Returns the map that stores all Identifiers with their names in lowercase. 127 @return The map 128 */ 129 std::map<std::string, Identifier*>& IdentifierManager::getLowercaseStringIdentifierMapIntern() 130 { 131 static std::map<std::string, Identifier*> lowercaseIdentifierMap; 132 return lowercaseIdentifierMap; 133 } 134 135 /** 136 @brief Returns the map that stores all Identifiers with their network IDs. 137 @return The map 138 */ 139 std::map<uint32_t, Identifier*>& IdentifierManager::getIDIdentifierMapIntern() 140 { 141 static std::map<uint32_t, Identifier*> identifierMap; 142 return identifierMap; 109 this->identifierByTypeId_.clear(); 110 this->identifierByString_.clear(); 111 this->identifierByLowercaseString_.clear(); 112 this->identifierByNetworkId_.clear(); 143 113 } 144 114 … … 150 120 Identifier* IdentifierManager::getIdentifierByString(const std::string& name) 151 121 { 152 std::map<std::string, Identifier*>::const_iterator it = IdentifierManager::getStringIdentifierMapIntern().find(name);153 if (it != IdentifierManager::getStringIdentifierMapIntern().end())122 std::map<std::string, Identifier*>::const_iterator it = this->identifierByString_.find(name); 123 if (it != this->identifierByString_.end()) 154 124 return it->second; 155 125 else … … 164 134 Identifier* IdentifierManager::getIdentifierByLowercaseString(const std::string& name) 165 135 { 166 std::map<std::string, Identifier*>::const_iterator it = IdentifierManager::getLowercaseStringIdentifierMapIntern().find(name);167 if (it != IdentifierManager::getLowercaseStringIdentifierMapIntern().end())136 std::map<std::string, Identifier*>::const_iterator it = this->identifierByLowercaseString_.find(name); 137 if (it != this->identifierByLowercaseString_.end()) 168 138 return it->second; 169 139 else … … 178 148 Identifier* IdentifierManager::getIdentifierByID(const uint32_t id) 179 149 { 180 std::map<uint32_t, Identifier*>::const_iterator it = IdentifierManager::getIDIdentifierMapIntern().find(id);181 if (it != IdentifierManager::getIDIdentifierMapIntern().end())150 std::map<uint32_t, Identifier*>::const_iterator it = this->identifierByNetworkId_.find(id); 151 if (it != this->identifierByNetworkId_.end()) 182 152 return it->second; 183 153 else … … 190 160 void IdentifierManager::clearNetworkIDs() 191 161 { 192 IdentifierManager::getIDIdentifierMapIntern().clear();162 this->identifierByNetworkId_.clear(); 193 163 } 194 164 }
Note: See TracChangeset
for help on using the changeset viewer.