Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 10, 2008, 3:01:24 AM (16 years ago)
Author:
landauf
Message:

changed Identifier initialization

File:
1 edited

Legend:

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

    r1574 r1583  
    5858
    5959        this->bCreatedOneObject_ = false;
     60        this->bSetName_ = false;
    6061        this->factory_ = 0;
    6162
     
    8687        @return The identifier (unique instance)
    8788    */
    88     Identifier *Identifier::getIdentifier(std::string &name, Identifier *proposal)
     89    Identifier* Identifier::getIdentifierSingleton(const std::string& name, Identifier* proposal)
    8990    {
    9091        static std::map<std::string, Identifier*> identifiers;    //!< The map to store all Identifiers.
    9192        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
    95103            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        }
    103106    }
    104107
     
    149152
    150153    /**
     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    /**
    151169        @brief Creates an object of the type the Identifier belongs to.
    152170        @return The new object
Note: See TracChangeset for help on using the changeset viewer.