Changeset 6533
- Timestamp:
- Mar 16, 2010, 10:49:35 AM (15 years ago)
- Location:
- code/trunk/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/modules/pickup/Pickup.cc
r6524 r6533 73 73 void Pickup::initializeIdentifier(void) 74 74 { 75 //TODO: Works?76 75 std::string val1 = this->getActivationType(); 77 76 std::string type1 = "activationType"; -
code/trunk/src/modules/pickup/PickupCollection.cc
r6524 r6533 65 65 { 66 66 //! Destroy all Pickupables constructing this PickupCollection. 67 for(std::vector<Pickupable*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++) 68 { 69 (*it)->destroy(); 67 for(std::vector<WeakPtr<Pickupable> >::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++) 68 { 69 if((*it).get() != NULL) 70 (*it).get()->destroy(); 70 71 } 71 72 } … … 86 87 void PickupCollection::initializeIdentifier(void) 87 88 { 88 for(std::vector< Pickupable*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)89 { 90 this->pickupCollectionIdentifier_->addPickup((*it) ->getPickupIdentifier());89 for(std::vector<WeakPtr<Pickupable> >::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++) 90 { 91 this->pickupCollectionIdentifier_->addPickup((*it).get()->getPickupIdentifier()); 91 92 } 92 93 } … … 121 122 return false; 122 123 123 this->pickups_.push_back(pickup); 124 WeakPtr<Pickupable> ptr = pickup; 125 this->pickups_.push_back(ptr); 124 126 return true; 125 127 } … … 135 137 const Pickupable* PickupCollection::getPickupable(unsigned int index) 136 138 { 137 return this->pickups_[index] ; //TODO. Does this work?139 return this->pickups_[index].get(); //TODO. Does this work? 138 140 } 139 141 … … 143 145 144 146 //! Change used for all Pickupables this PickupCollection consists of. 145 for(std::vector< Pickupable*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)146 { 147 (*it) ->setUsed(this->isUsed());147 for(std::vector<WeakPtr<Pickupable> >::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++) 148 { 149 (*it).get()->setUsed(this->isUsed()); 148 150 } 149 151 } … … 154 156 155 157 //! Change used for all Pickupables this PickupCollection consists of. 156 for(std::vector< Pickupable*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)157 { 158 (*it) ->setCarrier(this->getCarrier());158 for(std::vector<WeakPtr<Pickupable> >::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++) 159 { 160 (*it).get()->setCarrier(this->getCarrier()); 159 161 } 160 162 } … … 165 167 166 168 //! Change the carrier for all Pickupables this PickupCollection consists of. 167 for(std::vector< Pickupable*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)168 { 169 (*it) ->setPickedUp(this->isPickedUp());169 for(std::vector<WeakPtr<Pickupable> >::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++) 170 { 171 (*it).get()->setPickedUp(this->isPickedUp()); 170 172 } 171 173 } … … 179 181 180 182 PickupCollection* pickup = dynamic_cast<PickupCollection*>(item); 181 for(std::vector< Pickupable*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)182 { 183 Pickupable* newPickup = (*it) ->clone();183 for(std::vector<WeakPtr<Pickupable> >::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++) 184 { 185 Pickupable* newPickup = (*it).get()->clone(); 184 186 pickup->addPickupable(newPickup); 185 187 } … … 190 192 bool PickupCollection::isTarget(Identifier* identifier) const 191 193 { 192 for(std::vector< Pickupable*>::const_iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)193 { 194 if(!(*it) ->isTarget(identifier))194 for(std::vector<WeakPtr<Pickupable> >::const_iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++) 195 { 196 if(!(*it).get()->isTarget(identifier)) 195 197 return false; 196 198 } -
code/trunk/src/modules/pickup/PickupCollection.h
r6524 r6533 79 79 private: 80 80 81 std::vector< Pickupable*> pickups_;81 std::vector<WeakPtr<Pickupable> > pickups_; 82 82 83 83 }; -
code/trunk/src/orxonox/interfaces/InterfaceCompilation.cc
r6524 r6533 64 64 PickupCarrier::~PickupCarrier() 65 65 { 66 for(std::set<Pickupable*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)66 while(this->pickups_.size() > 0) 67 67 { 68 std::set<Pickupable*>::iterator it = this->pickups_.begin(); 69 this->pickups_.erase(it); 68 70 (*it)->destroy(); 69 71 } 70 72 71 73 this->pickups_.clear(); 72 74 } -
code/trunk/src/orxonox/interfaces/PickupCarrier.h
r6524 r6533 41 41 #include "Pickupable.h" 42 42 #include "core/Identifier.h" 43 #include "core/WeakPtr.h" 43 44 44 45 #include "core/OrxonoxClass.h" -
code/trunk/src/orxonox/interfaces/Pickupable.h
r6524 r6533 114 114 { return this->pickupIdentifier_; } 115 115 116 virtual void destroy(void)117 { delete this; }118 119 116 //TODO: Make them work as protected. 120 117 bool setUsed(bool used); //!< Sets the Pickupable to used or unused, depending on the input.
Note: See TracChangeset
for help on using the changeset viewer.