Changeset 6038 for sandbox/src/libraries/core/Identifier.cc
- Timestamp:
- Nov 5, 2009, 9:22:22 PM (14 years ago)
- Location:
- sandbox
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox
- Property svn:mergeinfo changed
-
sandbox/src/libraries/core/Identifier.cc
r5782 r6038 37 37 38 38 #include "util/StringUtils.h" 39 #include "BaseObject.h" 39 40 #include "ConfigValueContainer.h" 40 #include " Factory.h"41 #include "ClassFactory.h" 41 42 42 43 namespace orxonox … … 62 63 this->bHasConfigValues_ = false; 63 64 64 this->children_ = new std::set<const Identifier*>();65 this->directChildren_ = new std::set<const Identifier*>();66 65 } 67 66 … … 71 70 Identifier::~Identifier() 72 71 { 73 delete this->children_;74 delete this->directChildren_;75 72 delete this->objects_; 76 73 … … 105 102 // There is already an entry: return it and delete the proposal 106 103 delete proposal; 107 return (*it).second;104 return it->second; 108 105 } 109 106 else … … 152 149 { 153 150 // Tell the parent we're one of it's children 154 (*it)-> getChildrenIntern().insert((*it)->getChildrenIntern().end(), this);151 (*it)->children_.insert((*it)->children_.end(), this); 155 152 156 153 // Erase all parents of our parent from our direct-parent-list … … 174 171 { 175 172 // Tell the parent we're one of it's direct children 176 (*it)-> getDirectChildrenIntern().insert((*it)->getDirectChildrenIntern().end(), this);173 (*it)->directChildren_.insert((*it)->directChildren_.end(), this); 177 174 } 178 175 } 176 } 177 178 /** 179 @brief Creates the class-hierarchy by creating and destroying one object of each type. 180 */ 181 void Identifier::createClassHierarchy() 182 { 183 COUT(3) << "*** Identifier: Create class-hierarchy" << std::endl; 184 Identifier::startCreatingHierarchy(); 185 for (std::map<std::string, Identifier*>::const_iterator it = Identifier::getStringIdentifierMap().begin(); it != Identifier::getStringIdentifierMap().end(); ++it) 186 { 187 // To create the new branch of the class-hierarchy, we create a new object and delete it afterwards. 188 if (it->second->hasFactory()) 189 { 190 BaseObject* temp = it->second->fabricate(0); 191 delete temp; 192 } 193 } 194 Identifier::stopCreatingHierarchy(); 195 COUT(3) << "*** Identifier: Finished class-hierarchy creation" << std::endl; 179 196 } 180 197 … … 198 215 this->name_ = name; 199 216 this->bSetName_ = true; 200 Identifier::get IdentifierMapIntern()[name] = this;201 Identifier::getLowercase IdentifierMapIntern()[getLowercase(name)] = this;217 Identifier::getStringIdentifierMapIntern()[name] = this; 218 Identifier::getLowercaseStringIdentifierMapIntern()[getLowercase(name)] = this; 202 219 } 203 220 } … … 219 236 COUT(1) << "Aborting..." << std::endl; 220 237 abort(); 221 return NULL;238 return 0; 222 239 } 223 240 } … … 265 282 bool Identifier::isParentOf(const Identifier* identifier) const 266 283 { 267 return (this->children_ ->find(identifier) != this->children_->end());284 return (this->children_.find(identifier) != this->children_.end()); 268 285 } 269 286 … … 274 291 bool Identifier::isDirectParentOf(const Identifier* identifier) const 275 292 { 276 return (this->directChildren_ ->find(identifier) != this->directChildren_->end());277 } 278 279 /** 280 @brief Returns the map that stores all Identifiers .293 return (this->directChildren_.find(identifier) != this->directChildren_.end()); 294 } 295 296 /** 297 @brief Returns the map that stores all Identifiers with their names. 281 298 @return The map 282 299 */ 283 std::map<std::string, Identifier*>& Identifier::get IdentifierMapIntern()300 std::map<std::string, Identifier*>& Identifier::getStringIdentifierMapIntern() 284 301 { 285 302 static std::map<std::string, Identifier*> identifierMap; … … 288 305 289 306 /** 290 @brief Returns the map that stores all Identifiers .307 @brief Returns the map that stores all Identifiers with their names in lowercase. 291 308 @return The map 292 309 */ 293 std::map<std::string, Identifier*>& Identifier::getLowercase IdentifierMapIntern()310 std::map<std::string, Identifier*>& Identifier::getLowercaseStringIdentifierMapIntern() 294 311 { 295 312 static std::map<std::string, Identifier*> lowercaseIdentifierMap; 296 313 return lowercaseIdentifierMap; 314 } 315 316 /** 317 @brief Returns the map that stores all Identifiers with their network IDs. 318 @return The map 319 */ 320 std::map<uint32_t, Identifier*>& Identifier::getIDIdentifierMapIntern() 321 { 322 static std::map<uint32_t, Identifier*> identifierMap; 323 return identifierMap; 324 } 325 326 /** 327 @brief Returns the Identifier with a given name. 328 @param name The name of the wanted Identifier 329 @return The Identifier 330 */ 331 Identifier* Identifier::getIdentifierByString(const std::string& name) 332 { 333 std::map<std::string, Identifier*>::const_iterator it = Identifier::getStringIdentifierMapIntern().find(name); 334 if (it != Identifier::getStringIdentifierMapIntern().end()) 335 return it->second; 336 else 337 return 0; 338 } 339 340 /** 341 @brief Returns the Identifier with a given name in lowercase. 342 @param name The name of the wanted Identifier 343 @return The Identifier 344 */ 345 Identifier* Identifier::getIdentifierByLowercaseString(const std::string& name) 346 { 347 std::map<std::string, Identifier*>::const_iterator it = Identifier::getLowercaseStringIdentifierMapIntern().find(name); 348 if (it != Identifier::getLowercaseStringIdentifierMapIntern().end()) 349 return it->second; 350 else 351 return 0; 297 352 } 298 353 … … 325 380 std::map<std::string, ConfigValueContainer*>::const_iterator it = configValues_.find(varname); 326 381 if (it != configValues_.end()) 327 return ((*it).second);382 return it->second; 328 383 else 329 384 return 0; … … 339 394 std::map<std::string, ConfigValueContainer*>::const_iterator it = configValues_LC_.find(varname); 340 395 if (it != configValues_LC_.end()) 341 return ((*it).second);396 return it->second; 342 397 else 343 398 return 0; … … 353 408 { 354 409 for (std::set<const Identifier*>::const_iterator it = list.begin(); it != list.end(); ++it) 355 out << (*it)->getName() << " "; 410 { 411 if (it != list.begin()) 412 out << " "; 413 out << (*it)->getName(); 414 } 356 415 357 416 return out;
Note: See TracChangeset
for help on using the changeset viewer.