- Timestamp:
- Aug 8, 2010, 8:53:52 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation3/src/orxonox/interfaces/PickupCarrier.h
r7150 r7162 79 79 PickupCarrier(); //!< Constructor. 80 80 virtual ~PickupCarrier(); //!< Destructor. 81 void preDestroy(void); 81 82 82 83 /** … … 138 139 virtual const Vector3& getCarrierPosition(void) = 0; 139 140 140 /**141 @brief Get the name of this PickupCarrier.142 @return Returns the name as a string.143 */144 const std::string& getCarrierName(void) { return this->carrierName_; } // tolua_export145 146 141 protected: 147 142 /** … … 160 155 161 156 /** 157 @brief Get all Pickupables this PickupCarrier has. 158 @return Returns the set of all Pickupables this PickupCarrier has. 159 */ 160 std::set<Pickupable*>& getPickups(void) 161 { return this->pickups_; } 162 163 private: 164 std::set<Pickupable*> pickups_; //!< The list of Pickupables carried by this PickupCarrier. 165 166 /** 162 167 @brief Adds a Pickupable to the list of pickups that are carried by this PickupCarrier. 163 168 @param pickup A pointer to the pickup to be added. … … 165 170 */ 166 171 bool addPickup(Pickupable* pickup) 167 { return this->pickups_.insert(pickup).second; } 172 { 173 COUT(4) << "Adding Pickupable (&" << pickup << ") to PickupCarrier (&" << this << ")" << std::endl; 174 return this->pickups_.insert(pickup).second; 175 } 168 176 169 177 /** … … 173 181 */ 174 182 bool removePickup(Pickupable* pickup) 175 { return this->pickups_.erase(pickup) == 1; }176 177 /**178 @brief Get all Pickupables this PickupCarrier has.179 @return Returns the set of all Pickupables this PickupCarrier has.180 */181 std::set<Pickupable*>& getPickups(void)182 { return this->pickups_; }183 184 /**185 @brief Set the name of this PickupCarrier.186 The name needs to be set in the constructor of every class inheriting from PickupCarrier, by calling setCarrierName().187 @param name The name to be set.188 */189 void setCarrierName(const std::string& name)190 { this->carrierName_ = name; }191 192 private:193 std::set<Pickupable*> pickups_; //!< The list of Pickupables carried by this PickupCarrier.194 std::string carrierName_; //!< The name of the PickupCarrier, as displayed in the PickupInventory.195 196 /**197 @brief Get the number of carrier children this PickupCarrier has.198 @return Returns the number of carrier children.199 */200 unsigned int getNumCarrierChildren(void)201 183 { 202 std::vector<PickupCarrier*>* list = this->getCarrierChildren(); 203 unsigned int size = list->size(); 204 delete list; 205 return size; 206 } 207 208 /** 209 @brief Get the index-th child of this PickupCarrier. 210 @param index The index of the child to return. 211 @return Returns the index-th child. 212 */ 213 PickupCarrier* getCarrierChild(unsigned int index) 214 { 215 std::vector<PickupCarrier*>* list = this->getCarrierChildren(); 216 if(list->size() < index) 217 return NULL; 218 PickupCarrier* carrier = (*list)[index]; 219 delete list; 220 return carrier; 221 } 222 223 /** 224 @brief Get the number of Pickupables this PickupCarrier carries. 225 @return returns the number of pickups. 226 */ 227 unsigned int getNumPickups(void) 228 { return this->pickups_.size(); } 229 230 /** 231 @brief Get the index-th Pickupable of this PickupCarrier. 232 @param index The index of the Pickupable to return. 233 @return Returns the index-th pickup. 234 */ 235 Pickupable* getPickup(unsigned int index) 236 { 237 std::set<Pickupable*>::iterator it; 238 for(it = this->pickups_.begin(); index != 0 && it != this->pickups_.end(); it++) 239 index--; 240 if(it == this->pickups_.end()) 241 return NULL; 242 return *it; 184 COUT(4) << "Removing Pickupable (&" << pickup << ") from PickupCarrier (&" << this << ")" << std::endl; 185 return this->pickups_.erase(pickup) == 1; 243 186 } 244 187
Note: See TracChangeset
for help on using the changeset viewer.