- Timestamp:
- Mar 5, 2010, 6:26:54 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/pickup3/src/orxonox/pickup/PickupIdentifier.h
r6474 r6475 32 32 #include "OrxonoxPrereqs.h" 33 33 34 #include "core/OrxonoxClass.h"35 #include "core/Identifier.h"36 34 #include <map> 37 35 #include <string> 36 #include "core/Identifier.h" 37 38 #include "core/OrxonoxClass.h" 38 39 39 40 namespace orxonox 40 41 { 41 42 43 /** 44 @brief 45 The purpose of the PickupIdentifier class is to identify different types of pickups allthough they are of the same class. 46 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. 47 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. 48 Lastly a struct is provided that can be used in stl containers to establish a strictly lesser ordering between PickupIdentifiers (and thus Pickupables). 49 @author 50 Damian 'Mozork' Frick 51 */ 42 52 class _OrxonoxExport PickupIdentifier : virtual public OrxonoxClass 43 53 { 44 54 45 55 public: 46 PickupIdentifier(void); 47 ~PickupIdentifier(); 56 PickupIdentifier(void); //!< Constructor. 57 ~PickupIdentifier(); //!< Destructor. 48 58 49 virtual int compare(const PickupIdentifier & identifier) const;59 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). 50 60 51 void addClass(Identifier* identifier); 52 bool addParameter(std::string & name, std::string & value); 61 void addClass(Identifier* identifier); //!< Add the class of the Pickupable to its PickupIdentifier. 62 bool addParameter(std::string & name, std::string & value); //!< Add a parameter to the PickupIdentifier. 53 63 54 64 private: 55 Identifier* classIdentifier_; 56 std::map<std::string, std::string> parameters_; 57 65 Identifier* classIdentifier_; //!< The Identifier of the class. 66 std::map<std::string, std::string> parameters_; //!< The parameters identifying the type of the pickup beyond the class. 58 67 59 68 }; 60 69 61 //TODO: Needed? 70 /** 71 @brief 72 Struct that overloads the compare operation between two PickupIdentifier pointers. 73 */ 62 74 struct PickupIdentifierCompare 63 75 { 64 bool operator() (const PickupIdentifier& lhs, const PickupIdentifier& rhs) const65 { return lhs.compare(rhs) < 0; }66 };67 68 struct PickupIdentifierPtrCompare69 {70 76 bool operator() (const PickupIdentifier* lhs, const PickupIdentifier* rhs) const 71 { return lhs->compare( *rhs) < 0; }77 { return lhs->compare(rhs) < 0; } 72 78 }; 73 79
Note: See TracChangeset
for help on using the changeset viewer.