Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 8, 2012, 5:26:04 PM (12 years ago)
Author:
landauf
Message:

renamed some functions where enums are converted to/from strings for XMLPort to make it more obvious where the value is actually set and where it is only converted

Location:
code/branches/presentation2012merge/src/modules/pickup/items
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2012merge/src/modules/pickup/items/DronePickup.cc

    r9305 r9312  
    106106        The name of the Template to e set.
    107107    */
    108     void DronePickup::setDroneTemplate(std::string templatename){
     108    void DronePickup::setDroneTemplate(const std::string& templatename){
    109109        droneTemplate_ = templatename;
    110110    }
  • code/branches/presentation2012merge/src/modules/pickup/items/DronePickup.h

    r7547 r9312  
    7777            void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.
    7878
    79             void setDroneTemplate(std::string templatename); //!< Set the droneTemplate.
     79            void setDroneTemplate(const std::string& templatename); //!< Set the droneTemplate.
    8080
    8181        private:
  • code/branches/presentation2012merge/src/modules/pickup/items/HealthPickup.cc

    r9305 r9312  
    106106        XMLPortParam(HealthPickup, "health", setHealth, getHealth, xmlelement, mode);
    107107        XMLPortParam(HealthPickup, "healthRate", setHealthRate, getHealthRate, xmlelement, mode);
    108         XMLPortParam(HealthPickup, "healthType", setHealthType, getHealthType, xmlelement, mode);
     108        XMLPortParam(HealthPickup, "healthType", setHealthTypeAsString, getHealthTypeAsString, xmlelement, mode);
    109109
    110110        if(!this->isContinuous())
    111             this->healthRate_ = 0.0f;
     111            this->setHealthRate(0.0f); // TODO: this logic should be inside tick(), not in XMLPort
    112112
    113113        this->initializeIdentifier();
     
    139139            this->setHealth(this->getHealth()-health);
    140140
    141             switch(this->getHealthTypeDirect())
     141            switch(this->getHealthType())
    142142            {
    143143                case pickupHealthType::permanent:
     
    186186
    187187                float health = 0.0f;
    188                 switch(this->getHealthTypeDirect())
     188                switch(this->getHealthType())
    189189                {
    190190                    case pickupHealthType::permanent:
     
    215215        else
    216216        {
    217             if(this->getHealthTypeDirect() == pickupHealthType::temporary)
     217            if(this->getHealthType() == pickupHealthType::temporary)
    218218            {
    219219                PickupCarrier* carrier = this->getCarrier();
     
    276276        pickup->setHealth(this->getHealth());
    277277        pickup->setHealthRate(this->getHealthRate());
    278         pickup->setHealthTypeDirect(this->getHealthTypeDirect());
     278        pickup->setHealthType(this->getHealthType());
    279279
    280280        pickup->initializeIdentifier();
     
    287287        Returns the health type as a string.
    288288    */
    289     const std::string& HealthPickup::getHealthType(void) const
    290     {
    291         switch(this->getHealthTypeDirect())
     289    const std::string& HealthPickup::getHealthTypeAsString(void) const
     290    {
     291        switch(this->getHealthType())
    292292        {
    293293            case pickupHealthType::limited:
     
    340340        The type as a string.
    341341    */
    342     void HealthPickup::setHealthType(std::string type)
     342    void HealthPickup::setHealthTypeAsString(const std::string& type)
    343343    {
    344344        if(type == HealthPickup::healthTypeLimited_s)
    345             this->setHealthTypeDirect(pickupHealthType::limited);
     345            this->setHealthType(pickupHealthType::limited);
    346346        else if(type == HealthPickup::healthTypeTemporary_s)
    347             this->setHealthTypeDirect(pickupHealthType::temporary);
     347            this->setHealthType(pickupHealthType::temporary);
    348348        else if(type == HealthPickup::healthTypePermanent_s)
    349             this->setHealthTypeDirect(pickupHealthType::permanent);
     349            this->setHealthType(pickupHealthType::permanent);
    350350        else
    351351            orxout(internal_error, context::pickups) << "Invalid healthType '" << type << "' in HealthPickup." << endl;
  • code/branches/presentation2012merge/src/modules/pickup/items/HealthPickup.h

    r7551 r9312  
    116116            @return Returns the health type as an enum.
    117117            */
    118             inline pickupHealthType::Value getHealthTypeDirect(void) const
     118            inline pickupHealthType::Value getHealthType(void) const
    119119                { return this->healthType_; }
    120             const std::string& getHealthType(void) const; //!< Get the health type of this pickup.
     120            const std::string& getHealthTypeAsString(void) const; //!< Get the health type of this pickup.
    121121
    122122        protected:
     
    130130            @param type The type of this pickup as an enum.
    131131            */
    132             inline void setHealthTypeDirect(pickupHealthType::Value type)
     132            inline void setHealthType(pickupHealthType::Value type)
    133133                { this->healthType_ = type; }
    134             void setHealthType(std::string type); //!< Set the type of the HealthPickup.
     134            void setHealthTypeAsString(const std::string& type); //!< Set the type of the HealthPickup.
    135135
    136136        private:
  • code/branches/presentation2012merge/src/modules/pickup/items/MetaPickup.cc

    r9305 r9312  
    101101        SUPER(MetaPickup, XMLPort, xmlelement, mode);
    102102
    103         XMLPortParam(MetaPickup, "metaType", setMetaType, getMetaType, xmlelement, mode);
     103        XMLPortParam(MetaPickup, "metaType", setMetaTypeAsString, getMetaTypeAsString, xmlelement, mode);
    104104
    105105        this->initializeIdentifier();
     
    119119        {
    120120            PickupCarrier* carrier = this->getCarrier();
    121             if(this->getMetaTypeDirect() != pickupMetaType::none && carrier != NULL)
     121            if(this->getMetaType() != pickupMetaType::none && carrier != NULL)
    122122            {
    123123                // If the metaType is destroyCarrier, then the PickupCarrier is destroyed.
    124                 if(this->getMetaTypeDirect() == pickupMetaType::destroyCarrier)
     124                if(this->getMetaType() == pickupMetaType::destroyCarrier)
    125125                {
    126126                    Pawn* pawn = orxonox_cast<Pawn*>(carrier);
     
    137137
    138138                    // If the metaType is use, then the Pickupable is set to used.
    139                     if(this->getMetaTypeDirect() == pickupMetaType::use && !pickup->isUsed())
     139                    if(this->getMetaType() == pickupMetaType::use && !pickup->isUsed())
    140140                    {
    141141                        pickup->setUsed(true);
    142142                    }
    143143                    // If the metaType is drop, then the Pickupable is dropped.
    144                     else if(this->getMetaTypeDirect() == pickupMetaType::drop)
     144                    else if(this->getMetaType() == pickupMetaType::drop)
    145145                    {
    146146                        pickup->drop();
    147147                    }
    148148                    // If the metaType is destroy, then the Pickupable is destroyed.
    149                     else if(this->getMetaTypeDirect() == pickupMetaType::destroy)
     149                    else if(this->getMetaType() == pickupMetaType::destroy)
    150150                    {
    151151                        pickup->Pickupable::destroy();
     
    171171
    172172        MetaPickup* pickup = orxonox_cast<MetaPickup*>(item);
    173         pickup->setMetaTypeDirect(this->getMetaTypeDirect());
     173        pickup->setMetaType(this->getMetaType());
    174174
    175175        pickup->initializeIdentifier();
     
    182182        Returns a string with the meta type of the MetaPickup.
    183183    */
    184     const std::string& MetaPickup::getMetaType(void) const
    185     {
    186         switch(this->getMetaTypeDirect())
     184    const std::string& MetaPickup::getMetaTypeAsString(void) const
     185    {
     186        switch(this->getMetaType())
    187187        {
    188188            case pickupMetaType::none:
     
    207207        A string with the type to be set.
    208208    */
    209     void MetaPickup::setMetaType(const std::string& type)
     209    void MetaPickup::setMetaTypeAsString(const std::string& type)
    210210    {
    211211        if(type == MetaPickup::metaTypeNone_s)
    212212        {
    213             this->setMetaTypeDirect(pickupMetaType::none);
     213            this->setMetaType(pickupMetaType::none);
    214214        }
    215215        else if(type == MetaPickup::metaTypeUse_s)
    216216        {
    217             this->setMetaTypeDirect(pickupMetaType::use);
     217            this->setMetaType(pickupMetaType::use);
    218218        }
    219219        else if(type == MetaPickup::metaTypeDrop_s)
    220220        {
    221             this->setMetaTypeDirect(pickupMetaType::drop);
     221            this->setMetaType(pickupMetaType::drop);
    222222        }
    223223        else if(type == MetaPickup::metaTypeDestroy_s)
    224224        {
    225             this->setMetaTypeDirect(pickupMetaType::destroy);
     225            this->setMetaType(pickupMetaType::destroy);
    226226        }
    227227        else if(type == MetaPickup::metaTypeDestroyCarrier_s)
    228228        {
    229             this->setMetaTypeDirect(pickupMetaType::destroyCarrier);
     229            this->setMetaType(pickupMetaType::destroyCarrier);
    230230        }
    231231        else
  • code/branches/presentation2012merge/src/modules/pickup/items/MetaPickup.h

    r7547 r9312  
    6969
    7070        The default value is <em>none</em>, which basically does nothing.
    71        
     71
    7272        The parameter <b>activation type</b> can be used to specify, whether the MetaPickup is used upon pickup (<em>immediate</em>) or not (<em>onUse</em>). With <em>immediate</em> being the default.
    7373
     
    101101            @return Returns an enum with the meta type of the MetaPickup.
    102102            */
    103             inline pickupMetaType::Value getMetaTypeDirect(void) const
     103            inline pickupMetaType::Value getMetaType(void) const
    104104                { return this->metaType_; }
    105             const std::string& getMetaType(void) const; //!< Get the meta type of this MetaPickup.
     105            const std::string& getMetaTypeAsString(void) const; //!< Get the meta type of this MetaPickup.
    106106
    107107        protected:
     
    112112            @param type The meta type as an enum.
    113113            */
    114             inline void setMetaTypeDirect(pickupMetaType::Value type)
     114            inline void setMetaType(pickupMetaType::Value type)
    115115                { this->metaType_ =  type; }
    116             void setMetaType(const std::string& type); //!< Set the meta type of this MetaPickup.
     116            void setMetaTypeAsString(const std::string& type); //!< Set the meta type of this MetaPickup.
    117117
    118118        private:
Note: See TracChangeset for help on using the changeset viewer.