Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 5, 2010, 6:26:54 PM (14 years ago)
Author:
dafrick
Message:

Additional documentation, code niceifying and potential bug fixing. Also: Renamed DroppedItem to DroppedPickup.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/pickup3/src/modules/pickup/PickupRepresentation.cc

    r6474 r6475  
    3030
    3131#include "core/CoreIncludes.h"
     32#include "graphics/Billboard.h"
     33#include "util/StringUtils.h"
    3234#include "PickupManager.h"
    33 #include "graphics/Billboard.h"
    3435
    3536namespace orxonox
     
    3839    CreateFactory(PickupRepresentation);
    3940   
     41    /**
     42    @brief
     43        Constructor. Registers the object and initializes its member variables.
     44        This is primarily for use of the PickupManager in creating a default PickupRepresentation.
     45    */
    4046    PickupRepresentation::PickupRepresentation() : BaseObject(this)
    4147    {
     
    4551    }
    4652   
     53    /**
     54    @brief
     55        Default Constructor. Registers the object and initializes its member variables.
     56    */
    4757    PickupRepresentation::PickupRepresentation(BaseObject* creator) : BaseObject(creator)
    4858    {
     
    5262    }
    5363   
     64    /**
     65    @brief
     66        Destructor.
     67    */
    5468    PickupRepresentation::~PickupRepresentation()
    5569    {
    56        
     70        if(this->spawnerRepresentation_ != NULL)
     71            this->spawnerRepresentation_->destroy();
    5772    }
    5873   
     74    /**
     75    @brief
     76        Initializes the member variables of this PickupRepresentation.
     77    */
    5978    void PickupRepresentation::initialize(void)
    6079    {
     
    6685    }
    6786   
     87    /**
     88    @brief
     89        Method for creating a PickupRepresentation object through XML.
     90    */
    6891    void PickupRepresentation::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    6992    {
     
    7699        XMLPortObject(PickupRepresentation, StaticEntity, "spawner-representation", setSpawnerRepresentation, getSpawnerRepresentationIndex, xmlelement, mode);
    77100       
    78         PickupManager::getInstance().registerRepresentation(*this->pickup_->getPickupIdentifier(), this);
     101        PickupManager::getInstance().registerRepresentation(this->pickup_->getPickupIdentifier(), this); //!< Registers the PickupRepresentation with the PickupManager through the PickupIdentifier of the Pickupable it represents.
    79102    }
    80103   
     104    /**
     105    @brief
     106        Get a spawnerRepresentation for a specific PickupSpawner.
     107    @param spawner
     108        A pointer to the PickupSpawner.
     109    @return
     110        Returns a pointer to the StaticEntity.
     111    */
    81112    StaticEntity* PickupRepresentation::getSpawnerRepresentation(PickupSpawner* spawner)
    82113    {
     
    84115        {
    85116            COUT(4) << "PickupRepresentation: No spawner representation found." << std::endl;
    86             if(this->spawnerTemplate_ == "")
     117            if(this->spawnerTemplate_ == BLANKSTRING)
    87118            {
    88119                COUT(4) << "PickupRepresentation: Spawner template is empty." << std::endl;
     120                //!< If neither spawnerRepresentation nor spawnerTemplate was specified
    89121                return this->getDefaultSpawnerRepresentation(spawner);
    90122            }
    91123            this->addTemplate(this->spawnerTemplate_);
    92124        }
     125       
    93126        StaticEntity* representation = this->spawnerRepresentation_;
    94127       
     
    98131    }
    99132   
     133    /**
     134    @brief
     135        Get the default spawnerRepresentation for a specific PickupSpawner.
     136        Helper method of internal use.
     137    @param spawner
     138        A pointer to the PickupSpawner.
     139    @return
     140        Returns a pointer to the StaticEntity.
     141    */
     142    //TODO: Think of more elegant solution.
    100143    StaticEntity* PickupRepresentation::getDefaultSpawnerRepresentation(PickupSpawner* spawner)
    101144    {
Note: See TracChangeset for help on using the changeset viewer.