Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 15, 2008, 4:31:58 PM (16 years ago)
Author:
landauf
Message:
  • removed IdentifierList and replaced it by a std::list
  • changed several doxygen tags
File:
1 edited

Legend:

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

    r811 r813  
    2626 */
    2727
    28 /*!
     28/**
    2929    @file Identifier.cc
    3030    @brief Implementation of the Identifier class.
     
    4949        this->factory_ = 0;
    5050
    51         this->children_ = new IdentifierList;
     51        this->children_ = new std::list<const Identifier*>();
    5252
    5353        // Use a static variable because the classID gets created before main() and that's why we should avoid static member variables
     
    5757
    5858    /**
    59         @brief Destructor: Deletes the IdentifierList containing the children.
     59        @brief Destructor: Deletes the list containing the children.
    6060    */
    6161    Identifier::~Identifier()
     
    6565
    6666    /**
    67         @brief Initializes the Identifier with an IdentifierList containing all parents of the class the Identifier belongs to.
    68         @param parents The IdentifierList containing all parents
     67        @brief Initializes the Identifier with a list containing all parents of the class the Identifier belongs to.
     68        @param parents A list containing all parents
    6969    */
    70     void Identifier::initialize(const IdentifierList* parents)
     70    void Identifier::initialize(std::list<const Identifier*>* parents)
    7171    {
    7272        COUT(4) << "*** Identifier: Initialize " << this->name_ << "-Singleton." << std::endl;
     
    7575        if (parents)
    7676        {
    77             IdentifierListElement* temp1 = parents->first_;
    78             while (temp1)
     77            std::list<const Identifier*>::iterator temp1 = parents->begin();
     78            while (temp1 != parents->end())
    7979            {
    80                 this->parents_.add(temp1->identifier_);
    81                 temp1->identifier_->getChildren().add(this); // We're a child of our parents
     80                this->parents_.insert(this->parents_.end(), *temp1);
     81                (*temp1)->getChildren().insert((*temp1)->getChildren().end(), this); // We're a child of our parents
    8282
    83                 temp1 = temp1->next_;
     83                ++temp1;
    8484            }
    8585        }
     
    118118
    119119    /**
    120         @returns true, if the Identifier is at least of the given type.
     120        @brief Returns true, if the Identifier is at least of the given type.
    121121        @param identifier The identifier to compare with
    122122    */
    123123    bool Identifier::isA(const Identifier* identifier) const
    124124    {
    125         return (identifier == this || this->parents_.isInList(identifier));
     125        return (identifier == this || this->identifierIsInList(identifier, this->parents_));
    126126    }
    127127
    128128    /**
    129         @returns true, if the Identifier is exactly of the given type.
     129        @brief Returns true, if the Identifier is exactly of the given type.
    130130        @param identifier The identifier to compare with
    131131    */
     
    136136
    137137    /**
    138         @returns true, if the assigned identifier is a child of the given identifier.
     138        @brief Returns true, if the assigned identifier is a child of the given identifier.
    139139        @param identifier The identifier to compare with
    140140    */
    141141    bool Identifier::isChildOf(const Identifier* identifier) const
    142142    {
    143         return this->parents_.isInList(identifier);
     143        return this->identifierIsInList(identifier, this->parents_);
    144144    }
    145145
    146146    /**
    147         @returns true, if the assigned identifier is a parent of the given identifier.
     147        @brief Returns true, if the assigned identifier is a parent of the given identifier.
    148148        @param identifier The identifier to compare with
    149149    */
    150150    bool Identifier::isParentOf(const Identifier* identifier) const
    151151    {
    152         return this->children_->isInList(identifier);
     152        return this->identifierIsInList(identifier, *this->children_);
     153    }
     154
     155    /**
     156        @brief Searches for a given identifier in a list and returns whether the identifier is in the list or not.
     157        @param identifier The identifier to look for
     158        @param list The list
     159        @return True = the identifier is in the list
     160    */
     161    bool Identifier::identifierIsInList(const Identifier* identifier, const std::list<const Identifier*>& list)
     162    {
     163        for (std::list<const Identifier*>::const_iterator it = list.begin(); it != list.end(); ++it)
     164            if (identifier == (*it))
     165                return true;
     166
     167        return false;
    153168    }
    154169}
Note: See TracChangeset for help on using the changeset viewer.