- Timestamp:
- Mar 24, 2013, 6:08:42 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core6/src/libraries/core/class/Identifier.cc
r9563 r9564 46 46 // ### Identifier ### 47 47 // ############################### 48 int Identifier::hierarchyCreatingCounter_s = 0;49 unsigned int Identifier::classIDCounter_s = 0;50 51 48 /** 52 49 @brief Constructor: No factory, no object created, new ObjectList and a unique networkID. 53 50 */ 54 51 Identifier::Identifier() 55 : classID_( classIDCounter_s++)52 : classID_(IdentifierManager::classIDCounter_s++) 56 53 { 57 54 this->objects_ = new ObjectListBase(this); … … 87 84 88 85 /** 89 @brief Returns the identifier map with the names as received by typeid(). This is only used internally.90 */91 std::map<std::string, Identifier*>& Identifier::getTypeIDIdentifierMap()92 {93 static std::map<std::string, Identifier*> identifiers; //!< The map to store all Identifiers.94 return identifiers;95 }96 97 /**98 @brief Returns an identifier by name and adds it if not available99 @param name The name of the identifier as typeid().name() suggests100 @param proposal A pointer to a newly created identifier for the case of non existence in the map101 @return The identifier (unique instance)102 */103 Identifier* Identifier::getIdentifierSingleton(const std::string& name, Identifier* proposal)104 {105 std::map<std::string, Identifier*>::const_iterator it = getTypeIDIdentifierMap().find(name);106 107 if (it != getTypeIDIdentifierMap().end())108 {109 // There is already an entry: return it and delete the proposal110 delete proposal;111 return it->second;112 }113 else114 {115 // There is no entry: put the proposal into the map and return it116 getTypeIDIdentifierMap()[name] = proposal;117 return proposal;118 }119 }120 121 /**122 86 @brief Registers a class, which means that the name and the parents get stored. 123 87 @param parents A list, containing the Identifiers of all parents of the class … … 127 91 { 128 92 // Check if at least one object of the given type was created 129 if (!this->bCreatedOneObject_ && Identifier ::isCreatingHierarchy())93 if (!this->bCreatedOneObject_ && IdentifierManager::isCreatingHierarchy()) 130 94 { 131 95 // If no: We have to store the information and initialize the Identifier … … 187 151 188 152 /** 189 @brief Creates the class-hierarchy by creating and destroying one object of each type.190 */191 void Identifier::createClassHierarchy()192 {193 orxout(internal_status) << "Create class-hierarchy" << endl;194 Identifier::startCreatingHierarchy();195 for (std::map<std::string, Identifier*>::const_iterator it = Identifier::getStringIdentifierMap().begin(); it != Identifier::getStringIdentifierMap().end(); ++it)196 {197 // To create the new branch of the class-hierarchy, we create a new object and delete it afterwards.198 if (it->second->hasFactory())199 {200 OrxonoxClass* temp = it->second->fabricate(0);201 temp->destroy();202 }203 }204 Identifier::stopCreatingHierarchy();205 orxout(internal_status) << "Finished class-hierarchy creation" << endl;206 }207 208 /**209 @brief Destroys all Identifiers. Called when exiting the program.210 */211 void Identifier::destroyAllIdentifiers()212 {213 for (std::map<std::string, Identifier*>::iterator it = Identifier::getTypeIDIdentifierMap().begin(); it != Identifier::getTypeIDIdentifierMap().end(); ++it)214 delete (it->second);215 }216 217 /**218 153 @brief Sets the name of the class. 219 154 */ … … 224 159 this->name_ = name; 225 160 this->bSetName_ = true; 226 Identifier ::getStringIdentifierMapIntern()[name] = this;227 Identifier ::getLowercaseStringIdentifierMapIntern()[getLowercase(name)] = this;228 Identifier ::getIDIdentifierMapIntern()[this->networkID_] = this;161 IdentifierManager::getStringIdentifierMapIntern()[name] = this; 162 IdentifierManager::getLowercaseStringIdentifierMapIntern()[getLowercase(name)] = this; 163 IdentifierManager::getIDIdentifierMapIntern()[this->networkID_] = this; 229 164 } 230 165 } … … 256 191 { 257 192 // Identifier::getIDIdentifierMapIntern().erase(this->networkID_); 258 Identifier ::getIDIdentifierMapIntern()[id] = this;193 IdentifierManager::getIDIdentifierMapIntern()[id] = this; 259 194 this->networkID_ = id; 260 195 } … … 312 247 { 313 248 return (this->directChildren_.find(identifier) != this->directChildren_.end()); 314 }315 316 /**317 @brief Returns the map that stores all Identifiers with their names.318 @return The map319 */320 std::map<std::string, Identifier*>& Identifier::getStringIdentifierMapIntern()321 {322 static std::map<std::string, Identifier*> identifierMap;323 return identifierMap;324 }325 326 /**327 @brief Returns the map that stores all Identifiers with their names in lowercase.328 @return The map329 */330 std::map<std::string, Identifier*>& Identifier::getLowercaseStringIdentifierMapIntern()331 {332 static std::map<std::string, Identifier*> lowercaseIdentifierMap;333 return lowercaseIdentifierMap;334 }335 336 /**337 @brief Returns the map that stores all Identifiers with their network IDs.338 @return The map339 */340 std::map<uint32_t, Identifier*>& Identifier::getIDIdentifierMapIntern()341 {342 static std::map<uint32_t, Identifier*> identifierMap;343 return identifierMap;344 }345 346 /**347 @brief Returns the Identifier with a given name.348 @param name The name of the wanted Identifier349 @return The Identifier350 */351 Identifier* Identifier::getIdentifierByString(const std::string& name)352 {353 std::map<std::string, Identifier*>::const_iterator it = Identifier::getStringIdentifierMapIntern().find(name);354 if (it != Identifier::getStringIdentifierMapIntern().end())355 return it->second;356 else357 return 0;358 }359 360 /**361 @brief Returns the Identifier with a given name in lowercase.362 @param name The name of the wanted Identifier363 @return The Identifier364 */365 Identifier* Identifier::getIdentifierByLowercaseString(const std::string& name)366 {367 std::map<std::string, Identifier*>::const_iterator it = Identifier::getLowercaseStringIdentifierMapIntern().find(name);368 if (it != Identifier::getLowercaseStringIdentifierMapIntern().end())369 return it->second;370 else371 return 0;372 }373 374 /**375 @brief Returns the Identifier with a given network ID.376 @param id The network ID of the wanted Identifier377 @return The Identifier378 */379 Identifier* Identifier::getIdentifierByID(const uint32_t id)380 {381 std::map<uint32_t, Identifier*>::const_iterator it = Identifier::getIDIdentifierMapIntern().find(id);382 if (it != Identifier::getIDIdentifierMapIntern().end())383 return it->second;384 else385 return 0;386 }387 388 /**389 @brief Cleans the NetworkID map (needed on clients for correct initialization)390 */391 void Identifier::clearNetworkIDs()392 {393 Identifier::getIDIdentifierMapIntern().clear();394 249 } 395 250
Note: See TracChangeset
for help on using the changeset viewer.