Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 24, 2013, 6:08:42 PM (12 years ago)
Author:
landauf
Message:

moved static functions from Identifier.cc/h to IdentifierManager.cc/h (still static though)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core6/src/libraries/core/class/Identifier.cc

    r9563 r9564  
    4646    // ###       Identifier        ###
    4747    // ###############################
    48     int Identifier::hierarchyCreatingCounter_s = 0;
    49     unsigned int Identifier::classIDCounter_s = 0;
    50 
    5148    /**
    5249        @brief Constructor: No factory, no object created, new ObjectList and a unique networkID.
    5350    */
    5451    Identifier::Identifier()
    55         : classID_(classIDCounter_s++)
     52        : classID_(IdentifierManager::classIDCounter_s++)
    5653    {
    5754        this->objects_ = new ObjectListBase(this);
     
    8784
    8885    /**
    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 available
    99         @param name The name of the identifier as typeid().name() suggests
    100         @param proposal A pointer to a newly created identifier for the case of non existence in the map
    101         @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 proposal
    110             delete proposal;
    111             return it->second;
    112         }
    113         else
    114         {
    115             // There is no entry: put the proposal into the map and return it
    116             getTypeIDIdentifierMap()[name] = proposal;
    117             return proposal;
    118         }
    119     }
    120 
    121     /**
    12286        @brief Registers a class, which means that the name and the parents get stored.
    12387        @param parents A list, containing the Identifiers of all parents of the class
     
    12791    {
    12892        // Check if at least one object of the given type was created
    129         if (!this->bCreatedOneObject_ && Identifier::isCreatingHierarchy())
     93        if (!this->bCreatedOneObject_ && IdentifierManager::isCreatingHierarchy())
    13094        {
    13195            // If no: We have to store the information and initialize the Identifier
     
    187151
    188152    /**
    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     /**
    218153        @brief Sets the name of the class.
    219154    */
     
    224159            this->name_ = name;
    225160            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;
    229164        }
    230165    }
     
    256191    {
    257192//        Identifier::getIDIdentifierMapIntern().erase(this->networkID_);
    258         Identifier::getIDIdentifierMapIntern()[id] = this;
     193        IdentifierManager::getIDIdentifierMapIntern()[id] = this;
    259194        this->networkID_ = id;
    260195    }
     
    312247    {
    313248        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 map
    319     */
    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 map
    329     */
    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 map
    339     */
    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 Identifier
    349         @return The Identifier
    350     */
    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         else
    357             return 0;
    358     }
    359 
    360     /**
    361         @brief Returns the Identifier with a given name in lowercase.
    362         @param name The name of the wanted Identifier
    363         @return The Identifier
    364     */
    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         else
    371             return 0;
    372     }
    373 
    374     /**
    375         @brief Returns the Identifier with a given network ID.
    376         @param id The network ID of the wanted Identifier
    377         @return The Identifier
    378     */
    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         else
    385             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();
    394249    }
    395250
Note: See TracChangeset for help on using the changeset viewer.