Index: code/trunk/src/modules/pickup/PickupCollection.cc
===================================================================
--- code/trunk/src/modules/pickup/PickupCollection.cc	(revision 6533)
+++ code/trunk/src/modules/pickup/PickupCollection.cc	(revision 6538)
@@ -28,17 +28,15 @@
 
 /**
-    @file
+    @file PickupCollection.cc
     @brief Implementation of PickupCollection.
 */
 
-#include "PickupCollection.h"
-
 #include "core/CoreIncludes.h"
-#include "core/Template.h"
 #include "core/XMLPort.h"
 #include "interfaces/PickupCarrier.h"
 #include "DroppedPickup.h"
-
 #include "PickupCollectionIdentifier.h"
+
+#include "PickupCollection.h"
 
 namespace orxonox
@@ -60,5 +58,5 @@
     /**
     @brief
-        Destructor.
+        Destructor. Iterates through all Pickupables this PickupCollection consists of and destroys them if they haven't been already.
     */
     PickupCollection::~PickupCollection()
@@ -85,4 +83,8 @@
     }
     
+    /**
+    @brief
+        Initializes the PickupIdentifier for this pickup.
+    */
     void PickupCollection::initializeIdentifier(void)
     {
@@ -93,4 +95,139 @@
     }
     
+    /**
+    @brief
+        Is called when the pickup has transited from used to unused or the other way around.
+        Any Class overwriting this method must call its SUPER function by adding SUPER(Classname, changedUsed); to their changdeUsed method.
+    */
+    void PickupCollection::changedUsed(void)
+    {
+        SUPER(PickupCollection, changedUsed);
+        
+        //! Change used for all Pickupables this PickupCollection consists of.
+        for(std::vector<WeakPtr<Pickupable> >::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
+        {
+            (*it).get()->setUsed(this->isUsed());
+        }
+    }
+    
+    /**
+    @brief
+        Is called when the pickup has changed its PickupCarrier.
+        Any Class overwriting this method must call its SUPER function by adding SUPER(Classname, changedCarrier); to their changedCarrier method.
+    */
+    void PickupCollection::changedCarrier(void)
+    {
+        SUPER(PickupCollection, changedCarrier);
+        
+        //! Change the PickupCarrier for all Pickupables this PickupCollection consists of.
+        for(std::vector<WeakPtr<Pickupable> >::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
+        {
+            (*it).get()->setCarrier(this->getCarrier());
+        }
+    }
+    
+    /**
+    @brief
+        Is called when the pickup has transited from picked up to dropped or the other way around.
+        Any Class overwriting this method must call its SUPER function by adding SUPER(Classname, changedPickedUp); to their changedPickedUp method.
+    */
+    void PickupCollection::changedPickedUp()
+    {
+        SUPER(PickupCollection, changedPickedUp);
+        
+        //! Change the pickedUp status for all Pickupables this PickupCollection consists of.
+        for(std::vector<WeakPtr<Pickupable> >::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
+        {
+            (*it).get()->setPickedUp(this->isPickedUp());
+        }
+    }
+    
+    /**
+    @brief
+        Creates a duplicate of the input OrxonoxClass.
+        This method needs to be implemented by any Class inheriting from Pickupable.
+    @param item
+        A reference to a pointer to the OrxonoxClass that is to be duplicated.
+    */
+    void PickupCollection::clone(OrxonoxClass*& item)
+    {
+        if(item == NULL)
+            item = new PickupCollection(this);
+        
+        SUPER(PickupCollection, clone, item);
+        
+        PickupCollection* pickup = dynamic_cast<PickupCollection*>(item);
+        //! Clone allPickupables this PickupCollection consist of.
+        for(std::vector<WeakPtr<Pickupable> >::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
+        {
+            Pickupable* newPickup = (*it).get()->clone();
+            pickup->addPickupable(newPickup);
+        }
+
+        pickup->initializeIdentifier();
+    }
+    
+    /**
+    @brief
+        Get whether a given class, represented by the input Identifier, is a target of this PickupCollection.
+    @param identifier
+        A pointer to the PickupIdentifier of the PickupCarrier we want to know of, whether it is a target of this PickupCollection.
+    @return
+        Returns true if the PickupCarrier identified by the input PickupIdentififer it is a target of this PickupCollection, false if not.
+    */
+    bool PickupCollection::isTarget(Identifier* identifier) const
+    {
+        for(std::vector<WeakPtr<Pickupable> >::const_iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
+        {
+            if(!(*it).get()->isTarget(identifier))
+                return false;
+        }
+        
+        return true;
+    }
+    
+    /**
+    @brief
+        Get the PickupIdentifier of this PickupCollection.
+        This is in fact the PickupCollectionIdentifier.
+    @return
+        Returns a pointer to the PickupIdentifier of this PickupCollection.
+    */
+    const PickupIdentifier* PickupCollection::getPickupIdentifier(void)
+    {
+        return this->pickupCollectionIdentifier_;
+    }
+    
+    /**
+    @brief
+        Add the input Pickupable to list of Pickupables combined by this PickupCollection.
+    @param pickup
+        The Pickupable to be added.
+    @return
+        Returns true if successful,
+    */
+    bool PickupCollection::addPickupable(Pickupable* pickup)
+    {
+        if(pickup == NULL)
+            return false;
+        
+        WeakPtr<Pickupable> ptr = pickup; //!< Create a weak pointer to be able to test in the constructor if the Pointer is still valid.
+        this->pickups_.push_back(ptr);
+        return true;
+    }
+    
+    /**
+    @brief
+        Get the Pickupable at the given index.
+    @param index
+        The index the Pickupable is fetched from.
+    @return
+        Returns a pointer to the Pickupable at the index given by index.
+    */
+    const Pickupable* PickupCollection::getPickupable(unsigned int index)
+    {
+        return this->pickups_[index].get();
+    }
+        
     /**
     @brief
@@ -109,100 +246,3 @@
     }
     
-    /**
-    @brief
-        Add the input Pickupable to list of Pickupables combined by this PickupCollection.
-    @param pickup
-        The Pickupable to be added.
-    @return
-        Returns true if successful,
-    */
-    bool PickupCollection::addPickupable(Pickupable* pickup)
-    {
-        if(pickup == NULL)
-            return false;
-        
-        WeakPtr<Pickupable> ptr = pickup;
-        this->pickups_.push_back(ptr);
-        return true;
-    }
-    
-    /**
-    @brief
-        Get the Pickupable at the given index.
-    @param index
-        The index the Pickupable is fetched from.
-    @return
-        Returns a pointer to the Pickupable at the index given by index.
-    */
-    const Pickupable* PickupCollection::getPickupable(unsigned int index)
-    {
-        return this->pickups_[index].get(); //TODO. Does this work?
-    }
-    
-    void PickupCollection::changedUsed(void)
-    {
-        SUPER(PickupCollection, changedUsed);
-        
-        //! Change used for all Pickupables this PickupCollection consists of.
-        for(std::vector<WeakPtr<Pickupable> >::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
-        {
-            (*it).get()->setUsed(this->isUsed());
-        }
-    }
-    
-    void PickupCollection::changedCarrier(void)
-    {
-        SUPER(PickupCollection, changedCarrier);
-        
-        //! Change used for all Pickupables this PickupCollection consists of.
-        for(std::vector<WeakPtr<Pickupable> >::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
-        {
-            (*it).get()->setCarrier(this->getCarrier());
-        }
-    }
-    
-    void PickupCollection::changedPickedUp()
-    {
-        SUPER(PickupCollection, changedPickedUp);
-        
-        //! Change the carrier for all Pickupables this PickupCollection consists of.
-        for(std::vector<WeakPtr<Pickupable> >::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
-        {
-            (*it).get()->setPickedUp(this->isPickedUp());
-        }
-    }
-    
-    void PickupCollection::clone(OrxonoxClass*& item)
-    {
-        if(item == NULL)
-            item = new PickupCollection(this);
-        
-        SUPER(PickupCollection, clone, item);
-        
-        PickupCollection* pickup = dynamic_cast<PickupCollection*>(item);
-        for(std::vector<WeakPtr<Pickupable> >::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
-        {
-            Pickupable* newPickup = (*it).get()->clone();
-            pickup->addPickupable(newPickup);
-        }
-
-        pickup->initializeIdentifier();
-    }
-    
-    bool PickupCollection::isTarget(Identifier* identifier) const
-    {
-        for(std::vector<WeakPtr<Pickupable> >::const_iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
-        {
-            if(!(*it).get()->isTarget(identifier))
-                return false;
-        }
-        
-        return true;
-    }
-    
-    const PickupIdentifier* PickupCollection::getPickupIdentifier(void)
-    {
-        return this->pickupCollectionIdentifier_;
-    }
-    
 }
