Changeset 6474 for code/branches/pickup3/src/orxonox
- Timestamp:
- Mar 5, 2010, 9:49:56 AM (15 years ago)
- Location:
- code/branches/pickup3/src/orxonox
- Files:
-
- 3 added
- 18 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/pickup3/src/orxonox/interfaces/InterfaceCompilation.cc
r6466 r6474 59 59 { 60 60 RegisterRootObject(PickupCarrier); 61 62 } 63 64 PickupCarrier::~PickupCarrier() 65 { 66 for(std::set<Pickupable*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++) 67 { 68 (*it)->destroy(); 69 } 70 71 this->pickups_.clear(); 61 72 } 62 73 -
code/branches/pickup3/src/orxonox/interfaces/PickupCarrier.h
r6466 r6474 36 36 37 37 #include "OrxonoxPrereqs.h" 38 #include "core/OrxonoxClass.h" 38 39 #include <list> 40 #include <set> 39 41 #include "Pickupable.h" 40 42 41 #include <set> 42 #include <list> 43 #include "core/OrxonoxClass.h" 43 44 44 45 namespace orxonox 45 46 { 46 47 48 /** 49 @brief 50 The PickupCarrier interface provides the means, for any class implementing it, to possess Pickupables. 51 @author 52 Damian 'Mozork' Frick 53 */ 47 54 class _OrxonoxExport PickupCarrier : virtual public OrxonoxClass 48 55 { 49 friend class Pickupable; 56 friend class Pickupable; //!< The Pickupable has full acces to its PickupCarrier. 50 57 51 58 public: 52 PickupCarrier(); 53 virtual ~PickupCarrier() {}59 PickupCarrier(); //!< Constructor. 60 virtual ~PickupCarrier(); //!< Destructor. 54 61 55 //TODO: Secure uniqueness of each item in the set, if neccessary, check. 62 /** 63 @brief Can be called to pick up a Pickupable. 64 @param pickup A pointer to the Pickupable. 65 @return Returns true if the Pickupable was picked up, false if not. 66 */ 56 67 inline bool pickup(Pickupable* pickup) 57 68 { 58 69 bool pickedUp = this->pickups_.insert(pickup).second; 59 if(pickedUp) pickup->pickedUp(this); 70 if(pickedUp) 71 pickup->pickedUp(this); 60 72 return pickedUp; 61 73 } 62 74 75 /** 76 @brief Can be called to drop a Pickupable. 77 @param pickup A pointer to the Pickupable. 78 @return Returns true if the Pickupable has been dropped, false if not. 79 */ 63 80 inline bool drop(Pickupable* pickup) 64 81 { -
code/branches/pickup3/src/orxonox/interfaces/Pickupable.h
r6466 r6474 36 36 37 37 #include "OrxonoxPrereqs.h" 38 #include "core/OrxonoxClass.h"39 38 39 #include <list> 40 40 #include "core/Super.h" 41 41 #include "pickup/PickupIdentifier.h" 42 #include <list> 42 43 #include "core/OrxonoxClass.h" 43 44 44 45 namespace orxonox … … 47 48 /** 48 49 @brief 49 An Interface (or more precisely an abstract Class) to model and represent different (all kinds of) pickups.50 An Interface (or more precisely an abstract class) to model and represent different (all kinds of) pickups. 50 51 @author 51 52 Damian 'Mozork' Frick … … 57 58 public: 58 59 Pickupable(); //!< Default constructor. 59 virtual ~Pickupable() {} //!< Default destructor. 60 60 virtual ~Pickupable(); //!< Default destructor. 61 62 /** 63 @brief Get whether the pickup is currently in use or not. 64 @return Returns true if the pickup is currently in use. 65 */ 66 inline bool isUsed(void) 67 { return this->used_; } 68 /** 69 @brief Should be called when the pickup has transited from used to unused or the other way around. 70 Any Class overwriting this method must call its SUPER function by adding SUPER(Classname, changedUsed); to their changdeUsed method. 71 */ 72 virtual void changedUsed(void) {} 73 bool setUsed(bool used); //!< Sets the Pickupable to used or unused, depending on the input. 74 75 /** 76 @brief Returns whether the Pickupable is currently picked up. 77 @return Returns true if the Pickupable is currently picked up, false if not. 78 */ 79 inline bool isPickedUp(void) 80 { return this->pickedUp_; } 81 //TODO: Better private, or protected? 82 bool pickedUp(PickupCarrier* carrier); //!< Sets the Pickupable to picked up. 83 bool dropped(void); //!< Sets the Pickupable to not picked up or dropped. 84 85 bool isTarget(PickupCarrier* carrier); //!< Get whether the given PickupCarrier is a target of this pickup. 86 bool addTarget(PickupCarrier* target); //!< Add a PickupCarrier as target of this pickup. 87 61 88 /** 62 89 @brief Get the carrier of the pickup. … … 65 92 inline PickupCarrier* getCarrier(void) 66 93 { return this->carrier_; } 67 68 /**69 @brief Get whether the pickup is currently in use or not.70 @return Returns true if the pickup is currently in use.71 */72 inline bool isUsed(void)73 { return this->used_; }74 75 bool isTarget(PickupCarrier* carrier);76 bool addTarget(PickupCarrier* target);77 78 bool setUsed(bool used);79 80 bool pickedUp(PickupCarrier* carrier);81 bool dropped(void);82 83 inline bool isPickedUp(void)84 { return this->pickedUp_; }85 86 Pickupable* clone(void);87 88 virtual const PickupIdentifier* getPickupIdentifier(void)89 { return &this->pickupIdentifier_; }90 91 virtual void clone(OrxonoxClass* item);92 93 /**94 @brief Should be called when the pickup has transited from used to unused or the other way around.95 Any Class overwriting this method must call its SUPER function by adding SUPER(Classname, changedUsed); to their changdeUsed method.96 */97 virtual void changedUsed(void) {}98 99 94 /** 100 95 @brief Should be called when the pickup has transited from picked up to dropped or the other way around. … … 102 97 */ 103 98 virtual void changedCarrier(void) {} 99 //TODO: Maybe private? 100 bool setCarrier(PickupCarrier* carrier); //!< Sets the carrier of the pickup. 104 101 105 bool setCarrier(PickupCarrier* carrier); 102 Pickupable* clone(void); //!< Creates a duplicate of the Pickupable. 103 virtual void clone(OrxonoxClass* item); //!< Creates a duplicate of the input OrxonoxClass. 104 105 /** 106 @brief Get the PickupIdentifier of this Pickupable. 107 @return Returns a pointer to the PickupIdentifier of this Pickupable. 108 */ 109 virtual const PickupIdentifier* getPickupIdentifier(void) 110 { return &this->pickupIdentifier_; } 111 112 virtual void destroy(void) 113 { delete this; } 106 114 107 115 protected: 116 /** 117 @brief Helper method to initialize the PickupIdentifier. 118 */ 119 //TODO: Really needed? 108 120 void initializeIdentifier(void) {} 109 121 110 PickupIdentifier pickupIdentifier_; 122 //TODO: Move to private and create get method in protected. 123 PickupIdentifier pickupIdentifier_; //!< The PickupIdentifier of this Pickupable. 111 124 112 125 private: 126 /** 127 @brief Helper method to set the Pickupable to either picked up or not picked up. 128 @param pickedUp The value this->pickedUp_ should be set to. 129 */ 113 130 inline void setPickedUp(bool pickedUp) 114 131 { this->pickedUp_ = pickedUp; } … … 117 134 bool pickedUp_; //!< Whether the pickup is currently picked up or not. 118 135 119 PickupCarrier* carrier_; //!< The owner of the pickup.136 PickupCarrier* carrier_; //!< The carrier of the pickup. 120 137 std::list<Identifier*> targets_; //!< The possible targets of this pickup. 121 138
Note: See TracChangeset
for help on using the changeset viewer.