Changeset 5929 for code/trunk/src/libraries/core/Identifier.cc
- Timestamp:
- Oct 12, 2009, 8:20:07 PM (15 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/core5 (added) merged: 5768-5769,5772,5775-5780,5783-5785,5791-5792,5795-5807,5809-5814,5816-5832,5836-5839,5842-5853,5855-5899,5904-5922,5924-5928
- Property svn:mergeinfo changed
-
code/trunk/src/libraries/core/Identifier.cc
r5781 r5929 39 39 #include "ConfigValueContainer.h" 40 40 #include "ConsoleCommand.h" 41 #include " Factory.h"41 #include "ClassFactory.h" 42 42 #include "XMLPort.h" 43 43 … … 61 61 this->bSetName_ = false; 62 62 this->factory_ = 0; 63 this->bLoadable_ = true;63 this->bLoadable_ = false; 64 64 65 65 this->bHasConfigValues_ = false; 66 66 this->bHasConsoleCommands_ = false; 67 67 68 this->children_ = new std::set<const Identifier*>();69 this->directChildren_ = new std::set<const Identifier*>();70 71 68 // Default network ID is the class ID 72 69 this->networkID_ = this->classID_; … … 78 75 Identifier::~Identifier() 79 76 { 80 delete this->children_;81 delete this->directChildren_;82 77 delete this->objects_; 83 78 … … 118 113 // There is already an entry: return it and delete the proposal 119 114 delete proposal; 120 return (*it).second;115 return it->second; 121 116 } 122 117 else … … 165 160 { 166 161 // Tell the parent we're one of it's children 167 (*it)-> getChildrenIntern().insert((*it)->getChildrenIntern().end(), this);162 (*it)->children_.insert((*it)->children_.end(), this); 168 163 169 164 // Erase all parents of our parent from our direct-parent-list … … 187 182 { 188 183 // Tell the parent we're one of it's direct children 189 (*it)-> getDirectChildrenIntern().insert((*it)->getDirectChildrenIntern().end(), this);184 (*it)->directChildren_.insert((*it)->directChildren_.end(), this); 190 185 191 186 // Create the super-function dependencies … … 196 191 197 192 /** 193 @brief Creates the class-hierarchy by creating and destroying one object of each type. 194 */ 195 void Identifier::createClassHierarchy() 196 { 197 COUT(3) << "*** Identifier: Create class-hierarchy" << std::endl; 198 Identifier::startCreatingHierarchy(); 199 for (std::map<std::string, Identifier*>::const_iterator it = Identifier::getStringIdentifierMap().begin(); it != Identifier::getStringIdentifierMap().end(); ++it) 200 { 201 // To create the new branch of the class-hierarchy, we create a new object and delete it afterwards. 202 if (it->second->hasFactory()) 203 { 204 BaseObject* temp = it->second->fabricate(0); 205 temp->destroy(); 206 } 207 } 208 Identifier::stopCreatingHierarchy(); 209 COUT(3) << "*** Identifier: Finished class-hierarchy creation" << std::endl; 210 } 211 212 /** 198 213 @brief Destroys all Identifiers. Called when exiting the program. 199 214 */ … … 214 229 this->name_ = name; 215 230 this->bSetName_ = true; 216 Identifier::getIdentifierMapIntern()[name] = this; 217 Identifier::getLowercaseIdentifierMapIntern()[getLowercase(name)] = this; 231 Identifier::getStringIdentifierMapIntern()[name] = this; 232 Identifier::getLowercaseStringIdentifierMapIntern()[getLowercase(name)] = this; 233 Identifier::getIDIdentifierMapIntern()[this->networkID_] = this; 218 234 } 219 235 } … … 235 251 COUT(1) << "Aborting..." << std::endl; 236 252 abort(); 237 return NULL;238 } 239 } 240 241 /** 242 @brief Sets the network ID to a new value and changes the entry in the Factory.253 return 0; 254 } 255 } 256 257 /** 258 @brief Sets the network ID to a new value and changes the entry in the ID-Identifier-map. 243 259 @param id The new network ID 244 260 */ 245 261 void Identifier::setNetworkID(uint32_t id) 246 262 { 247 Factory::changeNetworkID(this, this->networkID_, id); 263 // Identifier::getIDIdentifierMapIntern().erase(this->networkID_); 264 Identifier::getIDIdentifierMapIntern()[id] = this; 248 265 this->networkID_ = id; 249 266 } … … 291 308 bool Identifier::isParentOf(const Identifier* identifier) const 292 309 { 293 return (this->children_ ->find(identifier) != this->children_->end());310 return (this->children_.find(identifier) != this->children_.end()); 294 311 } 295 312 … … 300 317 bool Identifier::isDirectParentOf(const Identifier* identifier) const 301 318 { 302 return (this->directChildren_ ->find(identifier) != this->directChildren_->end());303 } 304 305 /** 306 @brief Returns the map that stores all Identifiers .319 return (this->directChildren_.find(identifier) != this->directChildren_.end()); 320 } 321 322 /** 323 @brief Returns the map that stores all Identifiers with their names. 307 324 @return The map 308 325 */ 309 std::map<std::string, Identifier*>& Identifier::get IdentifierMapIntern()326 std::map<std::string, Identifier*>& Identifier::getStringIdentifierMapIntern() 310 327 { 311 328 static std::map<std::string, Identifier*> identifierMap; … … 314 331 315 332 /** 316 @brief Returns the map that stores all Identifiers .333 @brief Returns the map that stores all Identifiers with their names in lowercase. 317 334 @return The map 318 335 */ 319 std::map<std::string, Identifier*>& Identifier::getLowercase IdentifierMapIntern()336 std::map<std::string, Identifier*>& Identifier::getLowercaseStringIdentifierMapIntern() 320 337 { 321 338 static std::map<std::string, Identifier*> lowercaseIdentifierMap; 322 339 return lowercaseIdentifierMap; 340 } 341 342 /** 343 @brief Returns the map that stores all Identifiers with their network IDs. 344 @return The map 345 */ 346 std::map<uint32_t, Identifier*>& Identifier::getIDIdentifierMapIntern() 347 { 348 static std::map<uint32_t, Identifier*> identifierMap; 349 return identifierMap; 350 } 351 352 /** 353 @brief Returns the Identifier with a given name. 354 @param name The name of the wanted Identifier 355 @return The Identifier 356 */ 357 Identifier* Identifier::getIdentifierByString(const std::string& name) 358 { 359 std::map<std::string, Identifier*>::const_iterator it = Identifier::getStringIdentifierMapIntern().find(name); 360 if (it != Identifier::getStringIdentifierMapIntern().end()) 361 return it->second; 362 else 363 return 0; 364 } 365 366 /** 367 @brief Returns the Identifier with a given name in lowercase. 368 @param name The name of the wanted Identifier 369 @return The Identifier 370 */ 371 Identifier* Identifier::getIdentifierByLowercaseString(const std::string& name) 372 { 373 std::map<std::string, Identifier*>::const_iterator it = Identifier::getLowercaseStringIdentifierMapIntern().find(name); 374 if (it != Identifier::getLowercaseStringIdentifierMapIntern().end()) 375 return it->second; 376 else 377 return 0; 378 } 379 380 /** 381 @brief Returns the Identifier with a given network ID. 382 @param id The network ID of the wanted Identifier 383 @return The Identifier 384 */ 385 Identifier* Identifier::getIdentifierByID(const uint32_t id) 386 { 387 std::map<uint32_t, Identifier*>::const_iterator it = Identifier::getIDIdentifierMapIntern().find(id); 388 if (it != Identifier::getIDIdentifierMapIntern().end()) 389 return it->second; 390 else 391 return 0; 392 } 393 394 /** 395 @brief Cleans the NetworkID map (needed on clients for correct initialization) 396 */ 397 void Identifier::clearNetworkIDs() 398 { 399 Identifier::getIDIdentifierMapIntern().clear(); 323 400 } 324 401 … … 351 428 std::map<std::string, ConfigValueContainer*>::const_iterator it = configValues_.find(varname); 352 429 if (it != configValues_.end()) 353 return ((*it).second);430 return it->second; 354 431 else 355 432 return 0; … … 365 442 std::map<std::string, ConfigValueContainer*>::const_iterator it = configValues_LC_.find(varname); 366 443 if (it != configValues_LC_.end()) 367 return ((*it).second);444 return it->second; 368 445 else 369 446 return 0; … … 404 481 std::map<std::string, ConsoleCommand*>::const_iterator it = this->consoleCommands_.find(name); 405 482 if (it != this->consoleCommands_.end()) 406 return (*it).second;483 return it->second; 407 484 else 408 485 return 0; … … 418 495 std::map<std::string, ConsoleCommand*>::const_iterator it = this->consoleCommands_LC_.find(name); 419 496 if (it != this->consoleCommands_LC_.end()) 420 return (*it).second;497 return it->second; 421 498 else 422 499 return 0; … … 432 509 std::map<std::string, XMLPortParamContainer*>::const_iterator it = this->xmlportParamContainers_.find(paramname); 433 510 if (it != this->xmlportParamContainers_.end()) 434 return ((*it).second);511 return it->second; 435 512 else 436 513 return 0; … … 463 540 std::map<std::string, XMLPortObjectContainer*>::const_iterator it = this->xmlportObjectContainers_.find(sectionname); 464 541 if (it != this->xmlportObjectContainers_.end()) 465 return ((*it).second);542 return it->second; 466 543 else 467 544 return 0; … … 483 560 484 561 this->xmlportObjectContainers_[sectionname] = container; 485 }486 487 /**488 @brief Returns a XMLPortEventContainer that attaches an event to this class.489 @param sectionname The name of the section that contains the event490 @return The container491 */492 XMLPortObjectContainer* Identifier::getXMLPortEventContainer(const std::string& eventname)493 {494 std::map<std::string, XMLPortObjectContainer*>::const_iterator it = this->xmlportEventContainers_.find(eventname);495 if (it != this->xmlportEventContainers_.end())496 return ((*it).second);497 else498 return 0;499 }500 501 /**502 @brief Adds a new XMLPortEventContainer that attaches an event to this class.503 @param sectionname The name of the section that contains the event504 @param container The container505 */506 void Identifier::addXMLPortEventContainer(const std::string& eventname, XMLPortObjectContainer* container)507 {508 std::map<std::string, XMLPortObjectContainer*>::const_iterator it = this->xmlportEventContainers_.find(eventname);509 if (it != this->xmlportEventContainers_.end())510 {511 COUT(2) << "Warning: Overwriting XMLPortEventContainer in class " << this->getName() << "." << std::endl;512 delete (it->second);513 }514 515 this->xmlportEventContainers_[eventname] = container;516 562 } 517 563 … … 525 571 { 526 572 for (std::set<const Identifier*>::const_iterator it = list.begin(); it != list.end(); ++it) 527 out << (*it)->getName() << " "; 573 { 574 if (it != list.begin()) 575 out << " "; 576 out << (*it)->getName(); 577 } 528 578 529 579 return out;
Note: See TracChangeset
for help on using the changeset viewer.