[Orxonox-commit 1762] r6480 - in code/branches/pickup3/src: modules/pickup modules/pickup/items orxonox/interfaces orxonox/pickup

dafrick at orxonox.net dafrick at orxonox.net
Sun Mar 7 14:05:06 CET 2010


Author: dafrick
Date: 2010-03-07 14:05:05 +0100 (Sun, 07 Mar 2010)
New Revision: 6480

Modified:
   code/branches/pickup3/src/modules/pickup/Pickup.cc
   code/branches/pickup3/src/modules/pickup/PickupCollection.cc
   code/branches/pickup3/src/modules/pickup/PickupCollectionIdentifier.cc
   code/branches/pickup3/src/modules/pickup/PickupCollectionIdentifier.h
   code/branches/pickup3/src/modules/pickup/items/HealthPickup.cc
   code/branches/pickup3/src/orxonox/interfaces/Pickupable.cc
   code/branches/pickup3/src/orxonox/pickup/PickupIdentifier.cc
   code/branches/pickup3/src/orxonox/pickup/PickupIdentifier.h
Log:
Simplification in creation of PickupIdentifier.


Modified: code/branches/pickup3/src/modules/pickup/Pickup.cc
===================================================================
--- code/branches/pickup3/src/modules/pickup/Pickup.cc	2010-03-07 10:07:03 UTC (rev 6479)
+++ code/branches/pickup3/src/modules/pickup/Pickup.cc	2010-03-07 13:05:05 UTC (rev 6480)
@@ -71,10 +71,7 @@
         Initializes the PickupIdentififer of this Pickup.
     */
     void Pickup::initializeIdentifier(void)
-    {
-        //TODO: Check whether this could not be done in the Constructor if Pickupable. Would be much more convenient.
-        this->pickupIdentifier_->addClass(this->getIdentifier());
-        
+    {        
         //TODO: Works?
         std::string val1 = this->getActivationType();
         std::string type1 = "activationType";

Modified: code/branches/pickup3/src/modules/pickup/PickupCollection.cc
===================================================================
--- code/branches/pickup3/src/modules/pickup/PickupCollection.cc	2010-03-07 10:07:03 UTC (rev 6479)
+++ code/branches/pickup3/src/modules/pickup/PickupCollection.cc	2010-03-07 13:05:05 UTC (rev 6480)
@@ -52,7 +52,7 @@
     {
         RegisterObject(PickupCollection);
         
-        this->pickupCollectionIdentifier_ = new PickupCollectionIdentifier();
+        this->pickupCollectionIdentifier_ = new PickupCollectionIdentifier(this);
     }
     
     /**
@@ -84,8 +84,6 @@
     
     void PickupCollection::initializeIdentifier(void)
     {
-        this->pickupCollectionIdentifier_->addClass(this->getIdentifier());
-        
         for(std::vector<Pickupable*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
         {
             this->pickupCollectionIdentifier_->addPickup((*it)->getPickupIdentifier());

Modified: code/branches/pickup3/src/modules/pickup/PickupCollectionIdentifier.cc
===================================================================
--- code/branches/pickup3/src/modules/pickup/PickupCollectionIdentifier.cc	2010-03-07 10:07:03 UTC (rev 6479)
+++ code/branches/pickup3/src/modules/pickup/PickupCollectionIdentifier.cc	2010-03-07 13:05:05 UTC (rev 6480)
@@ -33,7 +33,7 @@
 namespace orxonox
 {
     
-    PickupCollectionIdentifier::PickupCollectionIdentifier(void)
+    PickupCollectionIdentifier::PickupCollectionIdentifier(Pickupable* pickup) : PickupIdentifier(pickup)
     {
         RegisterObject(PickupCollectionIdentifier);
     }

Modified: code/branches/pickup3/src/modules/pickup/PickupCollectionIdentifier.h
===================================================================
--- code/branches/pickup3/src/modules/pickup/PickupCollectionIdentifier.h	2010-03-07 10:07:03 UTC (rev 6479)
+++ code/branches/pickup3/src/modules/pickup/PickupCollectionIdentifier.h	2010-03-07 13:05:05 UTC (rev 6480)
@@ -41,7 +41,7 @@
     {
         
         public:
-            PickupCollectionIdentifier(void);
+            PickupCollectionIdentifier(Pickupable* pickup);
             ~PickupCollectionIdentifier();
             
             virtual int compare(const PickupIdentifier* identifier) const;

Modified: code/branches/pickup3/src/modules/pickup/items/HealthPickup.cc
===================================================================
--- code/branches/pickup3/src/modules/pickup/items/HealthPickup.cc	2010-03-07 10:07:03 UTC (rev 6479)
+++ code/branches/pickup3/src/modules/pickup/items/HealthPickup.cc	2010-03-07 13:05:05 UTC (rev 6480)
@@ -87,8 +87,6 @@
     */
     void HealthPickup::initializeIdentifier(void)
     {
-        this->pickupIdentifier_->addClass(this->getIdentifier());
-        
         std::stringstream stream;
         stream << this->getHealth();
         std::string type1 = "health";

Modified: code/branches/pickup3/src/orxonox/interfaces/Pickupable.cc
===================================================================
--- code/branches/pickup3/src/orxonox/interfaces/Pickupable.cc	2010-03-07 10:07:03 UTC (rev 6479)
+++ code/branches/pickup3/src/orxonox/interfaces/Pickupable.cc	2010-03-07 13:05:05 UTC (rev 6480)
@@ -54,7 +54,7 @@
         
         this->carrier_ = NULL;
         
-        this->pickupIdentifier_ = new PickupIdentifier();
+        this->pickupIdentifier_ = new PickupIdentifier(this);
     }
     
     /**

Modified: code/branches/pickup3/src/orxonox/pickup/PickupIdentifier.cc
===================================================================
--- code/branches/pickup3/src/orxonox/pickup/PickupIdentifier.cc	2010-03-07 10:07:03 UTC (rev 6479)
+++ code/branches/pickup3/src/orxonox/pickup/PickupIdentifier.cc	2010-03-07 13:05:05 UTC (rev 6480)
@@ -29,6 +29,7 @@
 #include "PickupIdentifier.h"
 
 #include "core/CoreIncludes.h"
+#include "interfaces/Pickupable.h"
 
 namespace orxonox
 {
@@ -37,11 +38,11 @@
     @brief
         Constructor. Registers the object and initializes member variables.
     */
-    PickupIdentifier::PickupIdentifier()
+    PickupIdentifier::PickupIdentifier(Pickupable* pickup)
     {
         RegisterRootObject(PickupIdentifier);
         
-        this->classIdentifier_ = NULL;
+        this->pickup_ = pickup;
     }
     
     PickupIdentifier::~PickupIdentifier()
@@ -60,8 +61,8 @@
     int PickupIdentifier::compare(const PickupIdentifier* identifier) const
     {
         //! 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.
-        if(!identifier->classIdentifier_->isExactlyA(this->classIdentifier_))
-            return this->classIdentifier_->getName().compare(identifier->classIdentifier_->getName());
+        if(!identifier->pickup_->getIdentifier()->isExactlyA(this->pickup_->getIdentifier()))
+            return this->pickup_->getIdentifier()->getName().compare(identifier->pickup_->getIdentifier()->getName());
         
         //! If the class is the same for both PickupIdentifiers we go on to check the parameters of the class.
         //! If the two have a different number of parameters then obviusly something is very wrong.
@@ -89,17 +90,6 @@
     
     /**
     @brief
-        Add the class of the Pickupable to its PickupIdentifier.
-    @param identifier
-        A pointer to the Identifier of the class.
-    */
-    void PickupIdentifier::addClass(Identifier* identifier)
-    {
-        this->classIdentifier_ = identifier;
-    }
-    
-    /**
-    @brief
         Add a parameter to the PickupIdentifier.
     @param name
         The name of the parameter.

Modified: code/branches/pickup3/src/orxonox/pickup/PickupIdentifier.h
===================================================================
--- code/branches/pickup3/src/orxonox/pickup/PickupIdentifier.h	2010-03-07 10:07:03 UTC (rev 6479)
+++ code/branches/pickup3/src/orxonox/pickup/PickupIdentifier.h	2010-03-07 13:05:05 UTC (rev 6480)
@@ -53,16 +53,15 @@
     {
         
         public:
-            PickupIdentifier(void); //!< Constructor.
+            PickupIdentifier(Pickupable* pickup); //!< Constructor.
             ~PickupIdentifier(); //!< Destructor.
             
             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).
             
-            void addClass(Identifier* identifier); //!< Add the class of the Pickupable to its PickupIdentifier.
             bool addParameter(std::string & name, std::string & value); //!< Add a parameter to the PickupIdentifier.
             
         private:
-            Identifier* classIdentifier_; //!< The Identifier of the class.
+            Pickupable* pickup_; //!< The Pickupable the PickupIdentififer is for.
             std::map<std::string, std::string> parameters_; //!< The parameters identifying the type of the pickup beyond the class.
             
     };




More information about the Orxonox-commit mailing list