Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 5, 2010, 9:49:56 AM (15 years ago)
Author:
dafrick
Message:

Some documenting done. Added files, that I had forgotten to add. Cleaned the old pickups out.

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  
    5959    {
    6060        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();
    6172    }
    6273
  • code/branches/pickup3/src/orxonox/interfaces/PickupCarrier.h

    r6466 r6474  
    3636
    3737#include "OrxonoxPrereqs.h"
    38 #include "core/OrxonoxClass.h"
     38
     39#include <list>
     40#include <set>
    3941#include "Pickupable.h"
    4042
    41 #include <set>
    42 #include <list>
     43#include "core/OrxonoxClass.h"
    4344
    4445namespace orxonox
    4546{
    4647
     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    */
    4754    class _OrxonoxExport PickupCarrier : virtual public OrxonoxClass
    4855    {
    49         friend class Pickupable;
     56        friend class Pickupable; //!< The Pickupable has full acces to its PickupCarrier.
    5057       
    5158        public:
    52             PickupCarrier();
    53             virtual ~PickupCarrier() {}
     59            PickupCarrier(); //!< Constructor.
     60            virtual ~PickupCarrier(); //!< Destructor.
    5461           
    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            */
    5667            inline bool pickup(Pickupable* pickup)
    5768                {
    5869                    bool pickedUp = this->pickups_.insert(pickup).second;
    59                     if(pickedUp) pickup->pickedUp(this);
     70                    if(pickedUp)
     71                        pickup->pickedUp(this);
    6072                    return pickedUp;
    6173                }
    6274               
     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            */
    6380            inline bool drop(Pickupable* pickup)
    6481                {
  • code/branches/pickup3/src/orxonox/interfaces/Pickupable.h

    r6466 r6474  
    3636
    3737#include "OrxonoxPrereqs.h"
    38 #include "core/OrxonoxClass.h"
    3938
     39#include <list>
    4040#include "core/Super.h"
    4141#include "pickup/PickupIdentifier.h"
    42 #include <list>
     42
     43#include "core/OrxonoxClass.h"
    4344
    4445namespace orxonox
     
    4748    /**
    4849    @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.
    5051    @author
    5152        Damian 'Mozork' Frick
     
    5758        public:
    5859            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           
    6188            /**
    6289            @brief Get the carrier of the pickup.
     
    6592            inline PickupCarrier* getCarrier(void)
    6693                { 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            
    9994            /**
    10095            @brief  Should be called when the pickup has transited from picked up to dropped or the other way around.
     
    10297            */
    10398            virtual void changedCarrier(void) {}
     99            //TODO: Maybe private?
     100            bool setCarrier(PickupCarrier* carrier); //!< Sets the carrier of the pickup.
    104101           
    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; }
    106114           
    107115        protected:
     116            /**
     117            @brief Helper method to initialize the PickupIdentifier.
     118            */
     119            //TODO: Really needed?
    108120            void initializeIdentifier(void) {}
    109121           
    110             PickupIdentifier pickupIdentifier_;
     122            //TODO: Move to private and create get method in protected.
     123            PickupIdentifier pickupIdentifier_; //!< The PickupIdentifier of this Pickupable.
    111124           
    112125        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            */
    113130            inline void setPickedUp(bool pickedUp)
    114131                { this->pickedUp_ = pickedUp; }
     
    117134            bool pickedUp_; //!< Whether the pickup is currently picked up or not.
    118135           
    119             PickupCarrier* carrier_; //!< The owner of the pickup.
     136            PickupCarrier* carrier_; //!< The carrier of the pickup.
    120137            std::list<Identifier*> targets_; //!< The possible targets of this pickup.
    121138
Note: See TracChangeset for help on using the changeset viewer.