Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6480


Ignore:
Timestamp:
Mar 7, 2010, 2:05:05 PM (14 years ago)
Author:
dafrick
Message:

Simplification in creation of PickupIdentifier.

Location:
code/branches/pickup3/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • code/branches/pickup3/src/modules/pickup/Pickup.cc

    r6477 r6480  
    7272    */
    7373    void Pickup::initializeIdentifier(void)
    74     {
    75         //TODO: Check whether this could not be done in the Constructor if Pickupable. Would be much more convenient.
    76         this->pickupIdentifier_->addClass(this->getIdentifier());
    77        
     74    {       
    7875        //TODO: Works?
    7976        std::string val1 = this->getActivationType();
  • code/branches/pickup3/src/modules/pickup/PickupCollection.cc

    r6475 r6480  
    5353        RegisterObject(PickupCollection);
    5454       
    55         this->pickupCollectionIdentifier_ = new PickupCollectionIdentifier();
     55        this->pickupCollectionIdentifier_ = new PickupCollectionIdentifier(this);
    5656    }
    5757   
     
    8585    void PickupCollection::initializeIdentifier(void)
    8686    {
    87         this->pickupCollectionIdentifier_->addClass(this->getIdentifier());
    88        
    8987        for(std::vector<Pickupable*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
    9088        {
  • code/branches/pickup3/src/modules/pickup/PickupCollectionIdentifier.cc

    r6475 r6480  
    3434{
    3535   
    36     PickupCollectionIdentifier::PickupCollectionIdentifier(void)
     36    PickupCollectionIdentifier::PickupCollectionIdentifier(Pickupable* pickup) : PickupIdentifier(pickup)
    3737    {
    3838        RegisterObject(PickupCollectionIdentifier);
  • code/branches/pickup3/src/modules/pickup/PickupCollectionIdentifier.h

    r6475 r6480  
    4242       
    4343        public:
    44             PickupCollectionIdentifier(void);
     44            PickupCollectionIdentifier(Pickupable* pickup);
    4545            ~PickupCollectionIdentifier();
    4646           
  • code/branches/pickup3/src/modules/pickup/items/HealthPickup.cc

    r6478 r6480  
    8888    void HealthPickup::initializeIdentifier(void)
    8989    {
    90         this->pickupIdentifier_->addClass(this->getIdentifier());
    91        
    9290        std::stringstream stream;
    9391        stream << this->getHealth();
  • code/branches/pickup3/src/orxonox/interfaces/Pickupable.cc

    r6478 r6480  
    5555        this->carrier_ = NULL;
    5656       
    57         this->pickupIdentifier_ = new PickupIdentifier();
     57        this->pickupIdentifier_ = new PickupIdentifier(this);
    5858    }
    5959   
  • code/branches/pickup3/src/orxonox/pickup/PickupIdentifier.cc

    r6478 r6480  
    3030
    3131#include "core/CoreIncludes.h"
     32#include "interfaces/Pickupable.h"
    3233
    3334namespace orxonox
     
    3839        Constructor. Registers the object and initializes member variables.
    3940    */
    40     PickupIdentifier::PickupIdentifier()
     41    PickupIdentifier::PickupIdentifier(Pickupable* pickup)
    4142    {
    4243        RegisterRootObject(PickupIdentifier);
    4344       
    44         this->classIdentifier_ = NULL;
     45        this->pickup_ = pickup;
    4546    }
    4647   
     
    6162    {
    6263        //! If the classIdentifiers are not the same (meaning the PickupIdentifiers identify different classes), the obviously the two Pickupables identified by the PickupIdentifiers cannot be the same. An ordering is established through the alphabetical ordering of the respective classnames.
    63         if(!identifier->classIdentifier_->isExactlyA(this->classIdentifier_))
    64             return this->classIdentifier_->getName().compare(identifier->classIdentifier_->getName());
     64        if(!identifier->pickup_->getIdentifier()->isExactlyA(this->pickup_->getIdentifier()))
     65            return this->pickup_->getIdentifier()->getName().compare(identifier->pickup_->getIdentifier()->getName());
    6566       
    6667        //! If the class is the same for both PickupIdentifiers we go on to check the parameters of the class.
     
    8687           
    8788        return false;
    88     }
    89    
    90     /**
    91     @brief
    92         Add the class of the Pickupable to its PickupIdentifier.
    93     @param identifier
    94         A pointer to the Identifier of the class.
    95     */
    96     void PickupIdentifier::addClass(Identifier* identifier)
    97     {
    98         this->classIdentifier_ = identifier;
    9989    }
    10090   
  • code/branches/pickup3/src/orxonox/pickup/PickupIdentifier.h

    r6475 r6480  
    5454       
    5555        public:
    56             PickupIdentifier(void); //!< Constructor.
     56            PickupIdentifier(Pickupable* pickup); //!< Constructor.
    5757            ~PickupIdentifier(); //!< Destructor.
    5858           
    5959            virtual int compare(const PickupIdentifier* identifier) const; //!< Compares two PickupIdentifiers and returns 0 if a == b, <0 if a < b and >0 if a > b for a.compare(b).
    6060           
    61             void addClass(Identifier* identifier); //!< Add the class of the Pickupable to its PickupIdentifier.
    6261            bool addParameter(std::string & name, std::string & value); //!< Add a parameter to the PickupIdentifier.
    6362           
    6463        private:
    65             Identifier* classIdentifier_; //!< The Identifier of the class.
     64            Pickupable* pickup_; //!< The Pickupable the PickupIdentififer is for.
    6665            std::map<std::string, std::string> parameters_; //!< The parameters identifying the type of the pickup beyond the class.
    6766           
Note: See TracChangeset for help on using the changeset viewer.