[Orxonox-commit 4641] r9312 - code/branches/presentation2012merge/src/modules/pickup/items

landauf at orxonox.net landauf at orxonox.net
Sun Jul 8 17:26:05 CEST 2012


Author: landauf
Date: 2012-07-08 17:26:04 +0200 (Sun, 08 Jul 2012)
New Revision: 9312

Modified:
   code/branches/presentation2012merge/src/modules/pickup/items/DronePickup.cc
   code/branches/presentation2012merge/src/modules/pickup/items/DronePickup.h
   code/branches/presentation2012merge/src/modules/pickup/items/HealthPickup.cc
   code/branches/presentation2012merge/src/modules/pickup/items/HealthPickup.h
   code/branches/presentation2012merge/src/modules/pickup/items/MetaPickup.cc
   code/branches/presentation2012merge/src/modules/pickup/items/MetaPickup.h
Log:
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

Modified: code/branches/presentation2012merge/src/modules/pickup/items/DronePickup.cc
===================================================================
--- code/branches/presentation2012merge/src/modules/pickup/items/DronePickup.cc	2012-07-03 21:46:06 UTC (rev 9311)
+++ code/branches/presentation2012merge/src/modules/pickup/items/DronePickup.cc	2012-07-08 15:26:04 UTC (rev 9312)
@@ -105,7 +105,7 @@
     @param templatename
         The name of the Template to e set.
     */
-    void DronePickup::setDroneTemplate(std::string templatename){
+    void DronePickup::setDroneTemplate(const std::string& templatename){
         droneTemplate_ = templatename;
     }
 

Modified: code/branches/presentation2012merge/src/modules/pickup/items/DronePickup.h
===================================================================
--- code/branches/presentation2012merge/src/modules/pickup/items/DronePickup.h	2012-07-03 21:46:06 UTC (rev 9311)
+++ code/branches/presentation2012merge/src/modules/pickup/items/DronePickup.h	2012-07-08 15:26:04 UTC (rev 9312)
@@ -76,7 +76,7 @@
         protected:
             void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.
 
-            void setDroneTemplate(std::string templatename); //!< Set the droneTemplate.
+            void setDroneTemplate(const std::string& templatename); //!< Set the droneTemplate.
 
         private:
             void initialize(void); //!< Initializes the member variables.

Modified: code/branches/presentation2012merge/src/modules/pickup/items/HealthPickup.cc
===================================================================
--- code/branches/presentation2012merge/src/modules/pickup/items/HealthPickup.cc	2012-07-03 21:46:06 UTC (rev 9311)
+++ code/branches/presentation2012merge/src/modules/pickup/items/HealthPickup.cc	2012-07-08 15:26:04 UTC (rev 9312)
@@ -105,10 +105,10 @@
 
         XMLPortParam(HealthPickup, "health", setHealth, getHealth, xmlelement, mode);
         XMLPortParam(HealthPickup, "healthRate", setHealthRate, getHealthRate, xmlelement, mode);
-        XMLPortParam(HealthPickup, "healthType", setHealthType, getHealthType, xmlelement, mode);
+        XMLPortParam(HealthPickup, "healthType", setHealthTypeAsString, getHealthTypeAsString, xmlelement, mode);
 
         if(!this->isContinuous())
-            this->healthRate_ = 0.0f;
+            this->setHealthRate(0.0f); // TODO: this logic should be inside tick(), not in XMLPort
 
         this->initializeIdentifier();
     }
@@ -138,7 +138,7 @@
             float fullHealth = pawn->getHealth() + health;
             this->setHealth(this->getHealth()-health);
 
-            switch(this->getHealthTypeDirect())
+            switch(this->getHealthType())
             {
                 case pickupHealthType::permanent:
                     if(pawn->getMaxHealth() < fullHealth)
@@ -185,7 +185,7 @@
                     this->Pickupable::destroy();
 
                 float health = 0.0f;
-                switch(this->getHealthTypeDirect())
+                switch(this->getHealthType())
                 {
                     case pickupHealthType::permanent:
                         health = pawn->getHealth()+this->getHealth();
@@ -214,7 +214,7 @@
         }
         else
         {
-            if(this->getHealthTypeDirect() == pickupHealthType::temporary)
+            if(this->getHealthType() == pickupHealthType::temporary)
             {
                 PickupCarrier* carrier = this->getCarrier();
                 Pawn* pawn = orxonox_cast<Pawn*>(carrier);
@@ -275,7 +275,7 @@
         HealthPickup* pickup = orxonox_cast<HealthPickup*>(item);
         pickup->setHealth(this->getHealth());
         pickup->setHealthRate(this->getHealthRate());
-        pickup->setHealthTypeDirect(this->getHealthTypeDirect());
+        pickup->setHealthType(this->getHealthType());
 
         pickup->initializeIdentifier();
     }
@@ -286,9 +286,9 @@
     @return
         Returns the health type as a string.
     */
-    const std::string& HealthPickup::getHealthType(void) const
+    const std::string& HealthPickup::getHealthTypeAsString(void) const
     {
-        switch(this->getHealthTypeDirect())
+        switch(this->getHealthType())
         {
             case pickupHealthType::limited:
                 return HealthPickup::healthTypeLimited_s;
@@ -339,14 +339,14 @@
     @param type
         The type as a string.
     */
-    void HealthPickup::setHealthType(std::string type)
+    void HealthPickup::setHealthTypeAsString(const std::string& type)
     {
         if(type == HealthPickup::healthTypeLimited_s)
-            this->setHealthTypeDirect(pickupHealthType::limited);
+            this->setHealthType(pickupHealthType::limited);
         else if(type == HealthPickup::healthTypeTemporary_s)
-            this->setHealthTypeDirect(pickupHealthType::temporary);
+            this->setHealthType(pickupHealthType::temporary);
         else if(type == HealthPickup::healthTypePermanent_s)
-            this->setHealthTypeDirect(pickupHealthType::permanent);
+            this->setHealthType(pickupHealthType::permanent);
         else
             orxout(internal_error, context::pickups) << "Invalid healthType '" << type << "' in HealthPickup." << endl;
     }

Modified: code/branches/presentation2012merge/src/modules/pickup/items/HealthPickup.h
===================================================================
--- code/branches/presentation2012merge/src/modules/pickup/items/HealthPickup.h	2012-07-03 21:46:06 UTC (rev 9311)
+++ code/branches/presentation2012merge/src/modules/pickup/items/HealthPickup.h	2012-07-08 15:26:04 UTC (rev 9312)
@@ -115,9 +115,9 @@
             @brief Get the type of HealthPickup, this pickup is.
             @return Returns the health type as an enum.
             */
-            inline pickupHealthType::Value getHealthTypeDirect(void) const
+            inline pickupHealthType::Value getHealthType(void) const
                 { return this->healthType_; }
-            const std::string& getHealthType(void) const; //!< Get the health type of this pickup.
+            const std::string& getHealthTypeAsString(void) const; //!< Get the health type of this pickup.
 
         protected:
             void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.
@@ -129,9 +129,9 @@
             @brief Set the health type of this pickup.
             @param type The type of this pickup as an enum.
             */
-            inline void setHealthTypeDirect(pickupHealthType::Value type)
+            inline void setHealthType(pickupHealthType::Value type)
                 { this->healthType_ = type; }
-            void setHealthType(std::string type); //!< Set the type of the HealthPickup.
+            void setHealthTypeAsString(const std::string& type); //!< Set the type of the HealthPickup.
 
         private:
             void initialize(void); //!< Initializes the member variables.

Modified: code/branches/presentation2012merge/src/modules/pickup/items/MetaPickup.cc
===================================================================
--- code/branches/presentation2012merge/src/modules/pickup/items/MetaPickup.cc	2012-07-03 21:46:06 UTC (rev 9311)
+++ code/branches/presentation2012merge/src/modules/pickup/items/MetaPickup.cc	2012-07-08 15:26:04 UTC (rev 9312)
@@ -100,7 +100,7 @@
     {
         SUPER(MetaPickup, XMLPort, xmlelement, mode);
 
-        XMLPortParam(MetaPickup, "metaType", setMetaType, getMetaType, xmlelement, mode);
+        XMLPortParam(MetaPickup, "metaType", setMetaTypeAsString, getMetaTypeAsString, xmlelement, mode);
 
         this->initializeIdentifier();
     }
@@ -118,10 +118,10 @@
         if(this->isUsed() && this->metaType_ != pickupMetaType::none)
         {
             PickupCarrier* carrier = this->getCarrier();
-            if(this->getMetaTypeDirect() != pickupMetaType::none && carrier != NULL)
+            if(this->getMetaType() != pickupMetaType::none && carrier != NULL)
             {
                 // If the metaType is destroyCarrier, then the PickupCarrier is destroyed.
-                if(this->getMetaTypeDirect() == pickupMetaType::destroyCarrier)
+                if(this->getMetaType() == pickupMetaType::destroyCarrier)
                 {
                     Pawn* pawn = orxonox_cast<Pawn*>(carrier);
                     pawn->kill();
@@ -136,17 +136,17 @@
                         continue;
 
                     // If the metaType is use, then the Pickupable is set to used.
-                    if(this->getMetaTypeDirect() == pickupMetaType::use && !pickup->isUsed())
+                    if(this->getMetaType() == pickupMetaType::use && !pickup->isUsed())
                     {
                         pickup->setUsed(true);
                     }
                     // If the metaType is drop, then the Pickupable is dropped.
-                    else if(this->getMetaTypeDirect() == pickupMetaType::drop)
+                    else if(this->getMetaType() == pickupMetaType::drop)
                     {
                         pickup->drop();
                     }
                     // If the metaType is destroy, then the Pickupable is destroyed.
-                    else if(this->getMetaTypeDirect() == pickupMetaType::destroy)
+                    else if(this->getMetaType() == pickupMetaType::destroy)
                     {
                         pickup->Pickupable::destroy();
                     }
@@ -170,7 +170,7 @@
         SUPER(MetaPickup, clone, item);
 
         MetaPickup* pickup = orxonox_cast<MetaPickup*>(item);
-        pickup->setMetaTypeDirect(this->getMetaTypeDirect());
+        pickup->setMetaType(this->getMetaType());
 
         pickup->initializeIdentifier();
     }
@@ -181,9 +181,9 @@
     @return
         Returns a string with the meta type of the MetaPickup.
     */
-    const std::string& MetaPickup::getMetaType(void) const
+    const std::string& MetaPickup::getMetaTypeAsString(void) const
     {
-        switch(this->getMetaTypeDirect())
+        switch(this->getMetaType())
         {
             case pickupMetaType::none:
                 return MetaPickup::metaTypeNone_s;
@@ -206,27 +206,27 @@
     @param type
         A string with the type to be set.
     */
-    void MetaPickup::setMetaType(const std::string& type)
+    void MetaPickup::setMetaTypeAsString(const std::string& type)
     {
         if(type == MetaPickup::metaTypeNone_s)
         {
-            this->setMetaTypeDirect(pickupMetaType::none);
+            this->setMetaType(pickupMetaType::none);
         }
         else if(type == MetaPickup::metaTypeUse_s)
         {
-            this->setMetaTypeDirect(pickupMetaType::use);
+            this->setMetaType(pickupMetaType::use);
         }
         else if(type == MetaPickup::metaTypeDrop_s)
         {
-            this->setMetaTypeDirect(pickupMetaType::drop);
+            this->setMetaType(pickupMetaType::drop);
         }
         else if(type == MetaPickup::metaTypeDestroy_s)
         {
-            this->setMetaTypeDirect(pickupMetaType::destroy);
+            this->setMetaType(pickupMetaType::destroy);
         }
         else if(type == MetaPickup::metaTypeDestroyCarrier_s)
         {
-            this->setMetaTypeDirect(pickupMetaType::destroyCarrier);
+            this->setMetaType(pickupMetaType::destroyCarrier);
         }
         else
             orxout(internal_warning, context::pickups) << "Invalid metaType '" << type << "' in MetaPickup." << endl;

Modified: code/branches/presentation2012merge/src/modules/pickup/items/MetaPickup.h
===================================================================
--- code/branches/presentation2012merge/src/modules/pickup/items/MetaPickup.h	2012-07-03 21:46:06 UTC (rev 9311)
+++ code/branches/presentation2012merge/src/modules/pickup/items/MetaPickup.h	2012-07-08 15:26:04 UTC (rev 9312)
@@ -68,7 +68,7 @@
         - @b destroyCarrier The PickupCarrier is immediately destroyed upon using the MetaPickup.
 
         The default value is <em>none</em>, which basically does nothing.
-        
+
         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.
 
         An example of a XML implementation of a MetaPickup would be:
@@ -100,9 +100,9 @@
             @brief Returns the meta type of the MetaPickup.
             @return Returns an enum with the meta type of the MetaPickup.
             */
-            inline pickupMetaType::Value getMetaTypeDirect(void) const
+            inline pickupMetaType::Value getMetaType(void) const
                 { return this->metaType_; }
-            const std::string& getMetaType(void) const; //!< Get the meta type of this MetaPickup.
+            const std::string& getMetaTypeAsString(void) const; //!< Get the meta type of this MetaPickup.
 
         protected:
             void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.
@@ -111,9 +111,9 @@
             @brief Set the meta type of the MetaPickup.
             @param type The meta type as an enum.
             */
-            inline void setMetaTypeDirect(pickupMetaType::Value type)
+            inline void setMetaType(pickupMetaType::Value type)
                 { this->metaType_ =  type; }
-            void setMetaType(const std::string& type); //!< Set the meta type of this MetaPickup.
+            void setMetaTypeAsString(const std::string& type); //!< Set the meta type of this MetaPickup.
 
         private:
             void initialize(void); //!< Initializes the member variables.




More information about the Orxonox-commit mailing list