Changeset 1583 for code/branches/core3/src/core/Identifier.cc
- Timestamp:
- Jun 10, 2008, 3:01:24 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core3/src/core/Identifier.cc
r1574 r1583 58 58 59 59 this->bCreatedOneObject_ = false; 60 this->bSetName_ = false; 60 61 this->factory_ = 0; 61 62 … … 86 87 @return The identifier (unique instance) 87 88 */ 88 Identifier *Identifier::getIdentifier(std::string &name, Identifier *proposal)89 Identifier* Identifier::getIdentifierSingleton(const std::string& name, Identifier* proposal) 89 90 { 90 91 static std::map<std::string, Identifier*> identifiers; //!< The map to store all Identifiers. 91 92 std::map<std::string, Identifier*>::const_iterator it = identifiers.find(name); 92 if (it == identifiers.end()) 93 { 94 // there isn't an entry yet, put the proposal in it 93 94 if (it != identifiers.end()) 95 { 96 // There is already an entry: return it and delete the proposal 97 delete proposal; 98 return (*it).second; 99 } 100 else 101 { 102 // There is no entry: put the proposal into the map and return it 95 103 identifiers[name] = proposal; 96 } 97 else 98 { 99 // this happens when a template exists twice --> delete the proposal 100 delete proposal; 101 } 102 return identifiers[name]; 104 return proposal; 105 } 103 106 } 104 107 … … 149 152 150 153 /** 154 @brief Sets the name of the class. 155 @param name The name 156 */ 157 void Identifier::setName(const std::string& name) 158 { 159 if (!this->bSetName_) 160 { 161 this->name_ = name; 162 this->bSetName_ = true; 163 Identifier::getIdentifierMapIntern()[name] = this; 164 Identifier::getLowercaseIdentifierMapIntern()[getLowercase(name)] = this; 165 } 166 } 167 168 /** 151 169 @brief Creates an object of the type the Identifier belongs to. 152 170 @return The new object
Note: See TracChangeset
for help on using the changeset viewer.