Changeset 7163 for code/trunk/src/orxonox/pickup
- Timestamp:
- Aug 11, 2010, 8:55:13 AM (14 years ago)
- Location:
- code/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/pickup/PickupIdentifier.cc
- Property svn:eol-style set to native
r6725 r7163 39 39 namespace orxonox 40 40 { 41 41 42 42 /** 43 43 @brief … … 47 47 { 48 48 RegisterRootObject(PickupIdentifier); 49 49 50 50 if(pickup == NULL) 51 51 COUT(1) << "Error, PickupIdentifier was created without a valid Pickupable." << std::endl; 52 52 53 53 this->pickup_ = pickup; 54 54 } 55 55 56 56 PickupIdentifier::~PickupIdentifier() 57 57 { 58 58 59 59 } 60 60 61 61 /** 62 62 @brief … … 74 74 COUT(1) << "Error in PickupIdentifier::compare: Input Identifier is NULL." << std::endl; 75 75 } 76 76 77 77 if(identifier->pickup_ == NULL && this->pickup_ == NULL) 78 78 { … … 80 80 COUT(1) << "Error in PickupIdentifier::compare: Pickup stored by Identifier is NULL." << std::endl; 81 81 } 82 82 83 83 if(identifier->pickup_ == NULL) 84 84 { … … 86 86 COUT(1) << "Error in PickupIdentifier::compare: Pickup stored by Identifier is NULL." << std::endl; 87 87 } 88 88 89 89 if(this->pickup_ == NULL) 90 90 { … … 92 92 COUT(1) << "Error in PickupIdentifier::compare: Pickup stored by Identifier is NULL." << std::endl; 93 93 } 94 94 95 95 //! 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. 96 96 if(!identifier->pickup_->getIdentifier()->isExactlyA(this->pickup_->getIdentifier())) 97 97 return this->pickup_->getIdentifier()->getName().compare(identifier->pickup_->getIdentifier()->getName()); 98 98 99 99 //! If the class is the same for both PickupIdentifiers we go on to check the parameters of the class. 100 100 //! If the two have a different number of parameters then obviusly something is very wrong. … … 104 104 return this->parameters_.size()-identifier->parameters_.size(); 105 105 } 106 107 //! We iterate through all parameters and compar their values (which are strings). The first parameter is the most significant. The ordering is once again established by the alphabetical comparison of the two value strings.106 107 //! We iterate through all parameters and compare their values (which are strings). The first parameter is the most significant. The ordering is once again established by the alphabetical comparison of the two value strings. 108 108 for(std::map<std::string, std::string>::const_iterator it = this->parameters_.begin(); it != this->parameters_.end(); it++) 109 109 { … … 117 117 return it->second.compare(identifier->parameters_.find(it->first)->second); 118 118 } 119 119 120 120 return 0; 121 121 } 122 122 123 123 /** 124 124 @brief … … 134 134 { 135 135 COUT(4) << "PickupIdentifier " << name << ", " << value << std::endl; 136 136 137 137 if(!(this->parameters_.find(name) == this->parameters_.end())) 138 138 { … … 140 140 return false; 141 141 } 142 142 143 143 this->parameters_[name] = value; 144 144 145 145 return true; 146 146 } 147 147 148 148 } -
code/trunk/src/orxonox/pickup/PickupIdentifier.h
- Property svn:eol-style set to native
r6540 r7163 41 41 #include "core/Identifier.h" 42 42 43 #include "core/OrxonoxClass.h" 43 #include "core/OrxonoxClass.h" 44 44 45 45 namespace orxonox 46 46 { 47 47 48 48 /** 49 49 @brief … … 57 57 class _OrxonoxExport PickupIdentifier : virtual public OrxonoxClass 58 58 { 59 59 60 60 public: 61 61 PickupIdentifier(Pickupable* pickup); //!< Constructor. 62 62 ~PickupIdentifier(); //!< Destructor. 63 63 64 64 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). 65 65 66 66 bool addParameter(std::string & name, std::string & value); //!< Add a parameter to the PickupIdentifier. 67 67 68 68 private: 69 69 Pickupable* pickup_; //!< The Pickupable the PickupIdentififer is for. 70 70 std::map<std::string, std::string> parameters_; //!< The parameters identifying the type of the pickup beyond the class. 71 71 72 72 }; 73 73 74 74 /** 75 75 @brief … … 81 81 { return lhs->compare(rhs) < 0; } 82 82 }; 83 83 84 84 } 85 85
Note: See TracChangeset
for help on using the changeset viewer.