Changeset 7494 for code/trunk/src/orxonox/pickup
- Timestamp:
- Sep 28, 2010, 5:31:59 PM (14 years ago)
- Location:
- code/trunk/src/orxonox/pickup
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/orxonox/pickup/PickupIdentifier.cc
r7163 r7494 35 35 36 36 #include "core/CoreIncludes.h" 37 #include "core/Identifier.h" 38 37 39 #include "interfaces/Pickupable.h" 38 40 … … 69 71 int PickupIdentifier::compare(const PickupIdentifier* identifier) const 70 72 { 71 if(identifier == NULL) 72 { 73 return 1; 74 COUT(1) << "Error in PickupIdentifier::compare: Input Identifier is NULL." << std::endl; 75 } 73 assert(identifier); 74 assert(identifier->pickup_); 75 assert(this->pickup_); 76 76 77 if(identifier->pickup_ == NULL && this->pickup_ == NULL) 78 { 79 return 0; 80 COUT(1) << "Error in PickupIdentifier::compare: Pickup stored by Identifier is NULL." << std::endl; 81 } 82 83 if(identifier->pickup_ == NULL) 84 { 85 return 1; 86 COUT(1) << "Error in PickupIdentifier::compare: Pickup stored by Identifier is NULL." << std::endl; 87 } 88 89 if(this->pickup_ == NULL) 90 { 91 return -1; 92 COUT(1) << "Error in PickupIdentifier::compare: Pickup stored by Identifier is NULL." << std::endl; 93 } 94 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. 77 // 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 78 if(!identifier->pickup_->getIdentifier()->isExactlyA(this->pickup_->getIdentifier())) 97 79 return this->pickup_->getIdentifier()->getName().compare(identifier->pickup_->getIdentifier()->getName()); 98 80 99 // !If the class is the same for both PickupIdentifiers we go on to check the parameters of the class.100 // ! If the two have a different number of parameters then obviusly something is very wrong.81 // If the class is the same for both PickupIdentifiers we go on to check the parameters of the class. 82 // If the two have a different number of parameters then obviously something is very wrong. 101 83 if(!(this->parameters_.size() == identifier->parameters_.size())) 102 84 { … … 105 87 } 106 88 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.89 // 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 90 for(std::map<std::string, std::string>::const_iterator it = this->parameters_.begin(); it != this->parameters_.end(); it++) 109 91 { 110 // !<If a parameter present in one of the identifiers is not found in the other, once again, something is very wrong.92 // If a parameter present in one of the identifiers is not found in the other, once again, something is very wrong. 111 93 if(identifier->parameters_.find(it->first) == identifier->parameters_.end()) 112 94 { -
code/trunk/src/orxonox/pickup/PickupIdentifier.h
r7456 r7494 40 40 #include <map> 41 41 #include <string> 42 #include "core/Identifier.h"43 42 44 43 #include "core/OrxonoxClass.h" … … 49 48 /** 50 49 @brief 51 The purpose of the PickupIdentifier class is to identify different types of pickups allthough they are of the same class. 52 This allows for more generic classes (or pickups in this case) that can be a number of different pickup types and can be identified as such without the need for a lot of different classes. An example is the HealthPickup class that encompasses a wide variety of different types of health pickups, e.g a HealthPickup that adds 10 health every second for 10 seconds or a HealthPickup that adds 100 health as soon as it is picked up, a.s.o. 53 To that purpose this class provides functionality to compare two PickupIdentifier (and since all Pickupables have an Identifier through that Pickupables can be compared). It als provides functionality to add parameters that distinguish between different types of pickups in the same pickup class. 54 Lastly a struct is provided that can be used in stl containers to establish a strictly lesser ordering between PickupIdentifiers (and thus Pickupables). 50 The purpose of the PickupIdentifier class is to identify (or differentiate between) different types of pickups although they are of the same class. 51 52 This allows for more generic classes (or pickups in this case) that can be a number of different pickup types and can be identified as such without the need for a lot of different classes. 53 54 An example is the @ref orxonox::HealthPickup "HealthPickup" class that encompasses a wide variety of different types of health pickups, e.g a @ref orxonox::HealthPickup "HealthPickup" that adds 10 health every second for 10 seconds or a @ref orxonox::HealthPickup "HealthPickup" that adds 100 health as soon as it is picked up, a.s.o. 55 56 To that purpose this class provides functionality to compare two @ref orxonox::PickupIdentifier "PickupIdentifiers" (and since all @ref orxonox::Pickupable "Pickupables" have an identifier, we can use it to compare pickups). It als provides functionality to add parameters that distinguish between different types of pickups in the same pickup class. 57 58 Lastly a struct (@ref orxonox::PickupIdentifierCompare "PickupIdentifierCompare") is provided that can be used in stl containers to establish a strictly lesser ordering between @ref orxonox::PickupIdentifier "PickupIdentifiers" (and thus @ref orxonox::Pickupable "Pickupables"). 55 59 @author 56 60 Damian 'Mozork' Frick … … 75 79 /** 76 80 @brief 77 Struct that overloads the compare operation between two PickupIdentifierpointers.81 Struct that overloads the compare operation between two @ref orxonox::PickupIdentifier "PickupIdentifier" pointers. 78 82 */ 79 83 struct PickupIdentifierCompare
Note: See TracChangeset
for help on using the changeset viewer.