Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 24, 2009, 2:47:53 AM (15 years ago)
Author:
landauf
Message:

Removed the Factory class.
Moved the networkID↔Identifier map from Factory to Identifier.
Replaced the name↔Identifier map from Factory with the already existing Identifier map in Identifier. This map additionally contains Identifiers without Factory. You can separate them with the new function identifier→hasFactory().

File:
1 edited

Legend:

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

    r5777 r5778  
    196196
    197197    /**
     198        @brief Creates the class-hierarchy by creating and destroying one object of each type.
     199    */
     200    void Identifier::createClassHierarchy()
     201    {
     202        COUT(3) << "*** Identifier: Create class-hierarchy" << std::endl;
     203        std::map<std::string, Identifier*>::const_iterator it;
     204        it = Identifier::getStringIdentifierMap().begin();
     205        Identifier::getStringIdentifierMap().begin()->second->startCreatingHierarchy();
     206        for (it = Identifier::getStringIdentifierMap().begin(); it != Identifier::getStringIdentifierMap().end(); ++it)
     207        {
     208            // To create the new branch of the class-hierarchy, we create a new object and delete it afterwards.
     209            if (it->second->hasFactory())
     210            {
     211                BaseObject* temp = it->second->fabricate(0);
     212                delete temp;
     213            }
     214        }
     215        Identifier::getStringIdentifierMap().begin()->second->stopCreatingHierarchy();
     216        COUT(3) << "*** Identifier: Finished class-hierarchy creation" << std::endl;
     217    }
     218
     219    /**
    198220        @brief Destroys all Identifiers. Called when exiting the program.
    199221    */
     
    214236            this->name_ = name;
    215237            this->bSetName_ = true;
    216             Identifier::getIdentifierMapIntern()[name] = this;
    217             Identifier::getLowercaseIdentifierMapIntern()[getLowercase(name)] = this;
     238            Identifier::getStringIdentifierMapIntern()[name] = this;
     239            Identifier::getLowercaseStringIdentifierMapIntern()[getLowercase(name)] = this;
     240            Identifier::getIDIdentifierMapIntern()[this->networkID_] = this;
    218241        }
    219242    }
     
    240263
    241264    /**
    242         @brief Sets the network ID to a new value and changes the entry in the Factory.
     265        @brief Sets the network ID to a new value and changes the entry in the ID-Identifier-map.
    243266        @param id The new network ID
    244267    */
    245268    void Identifier::setNetworkID(uint32_t id)
    246269    {
    247         Factory::changeNetworkID(this, this->networkID_, id);
     270//        Identifier::getIDIdentifierMapIntern().erase(this->networkID_);
     271        Identifier::getIDIdentifierMapIntern()[id] = this;
    248272        this->networkID_ = id;
    249273    }
     
    304328
    305329    /**
    306         @brief Returns the map that stores all Identifiers.
     330        @brief Returns the map that stores all Identifiers with their names.
    307331        @return The map
    308332    */
    309     std::map<std::string, Identifier*>& Identifier::getIdentifierMapIntern()
     333    std::map<std::string, Identifier*>& Identifier::getStringIdentifierMapIntern()
    310334    {
    311335        static std::map<std::string, Identifier*> identifierMap;
     
    314338
    315339    /**
    316         @brief Returns the map that stores all Identifiers.
     340        @brief Returns the map that stores all Identifiers with their names in lowercase.
    317341        @return The map
    318342    */
    319     std::map<std::string, Identifier*>& Identifier::getLowercaseIdentifierMapIntern()
     343    std::map<std::string, Identifier*>& Identifier::getLowercaseStringIdentifierMapIntern()
    320344    {
    321345        static std::map<std::string, Identifier*> lowercaseIdentifierMap;
    322346        return lowercaseIdentifierMap;
     347    }
     348
     349    /**
     350        @brief Returns the map that stores all Identifiers with their network IDs.
     351        @return The map
     352    */
     353    std::map<uint32_t, Identifier*>& Identifier::getIDIdentifierMapIntern()
     354    {
     355        static std::map<uint32_t, Identifier*> identifierMap;
     356        return identifierMap;
     357    }
     358
     359    /**
     360        @brief Returns the Identifier with a given name.
     361        @param name The name of the wanted Identifier
     362        @return The Identifier
     363    */
     364    Identifier* Identifier::getIdentifierByString(const std::string& name)
     365    {
     366        std::map<std::string, Identifier*>::const_iterator it = Identifier::getStringIdentifierMapIntern().find(name);
     367        if (it != Identifier::getStringIdentifierMapIntern().end())
     368            return it->second;
     369        else
     370            return 0;
     371    }
     372
     373    /**
     374        @brief Returns the Identifier with a given network ID.
     375        @param id The network ID of the wanted Identifier
     376        @return The Identifier
     377    */
     378    Identifier* Identifier::getIdentifierByID(const uint32_t id)
     379    {
     380        std::map<uint32_t, Identifier*>::const_iterator it = Identifier::getIDIdentifierMapIntern().find(id);
     381        if (it != Identifier::getIDIdentifierMapIntern().end())
     382            return it->second;
     383        else
     384            return 0;
     385    }
     386
     387    /**
     388        @brief Cleans the NetworkID map (needed on clients for correct initialization)
     389    */
     390    void Identifier::clearNetworkIDs()
     391    {
     392        Identifier::getIDIdentifierMapIntern().clear();
    323393    }
    324394
Note: See TracChangeset for help on using the changeset viewer.