Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 28, 2010, 5:31:59 PM (14 years ago)
Author:
dafrick
Message:

Some documenting and cleaning up/re-organization in pickups module.

Location:
code/trunk/src/orxonox/pickup
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/orxonox/pickup/PickupIdentifier.cc

    r7163 r7494  
    3535
    3636#include "core/CoreIncludes.h"
     37#include "core/Identifier.h"
     38
    3739#include "interfaces/Pickupable.h"
    3840
     
    6971    int PickupIdentifier::compare(const PickupIdentifier* identifier) const
    7072    {
    71         if(identifier == NULL)
    72         {
    73             return 1;
    74             COUT(1) << "Error in PickupIdentifier::compare: Input Identifier is NULL." << std::endl;
    75         }
     73        assert(identifier);
     74        assert(identifier->pickup_);
     75        assert(this->pickup_);
    7676
    77         if(identifier->pickup_ == NULL && this->pickup_ == NULL)
    78         {
    79             return 0;
    80             COUT(1) << "Error in PickupIdentifier::compare: Pickup stored by Identifier is NULL." << std::endl;
    81         }
    82 
    83         if(identifier->pickup_ == NULL)
    84         {
    85             return 1;
    86             COUT(1) << "Error in PickupIdentifier::compare: Pickup stored by Identifier is NULL." << std::endl;
    87         }
    88 
    89         if(this->pickup_ == NULL)
    90         {
    91             return -1;
    92             COUT(1) << "Error in PickupIdentifier::compare: Pickup stored by Identifier is NULL." << std::endl;
    93         }
    94 
    95         //! If the classIdentifiers are not the same (meaning the PickupIdentifiers identify different classes), the obviously the two Pickupables identified by the PickupIdentifiers cannot be the same. An ordering is established through the alphabetical ordering of the respective classnames.
     77        // If the classIdentifiers are not the same (meaning the PickupIdentifiers identify different classes), the obviously the two Pickupables identified by the PickupIdentifiers cannot be the same. An ordering is established through the alphabetical ordering of the respective classnames.
    9678        if(!identifier->pickup_->getIdentifier()->isExactlyA(this->pickup_->getIdentifier()))
    9779            return this->pickup_->getIdentifier()->getName().compare(identifier->pickup_->getIdentifier()->getName());
    9880
    99         //! If the class is the same for both PickupIdentifiers we go on to check the parameters of the class.
    100         //! If the two have a different number of parameters then obviusly something is very wrong.
     81        // If the class is the same for both PickupIdentifiers we go on to check the parameters of the class.
     82        // If the two have a different number of parameters then obviously something is very wrong.
    10183        if(!(this->parameters_.size() == identifier->parameters_.size()))
    10284        {
     
    10587        }
    10688
    107         //! We iterate through all parameters and compare their values (which are strings). The first parameter is the most significant. The ordering is once again established by the alphabetical comparison of the two value strings.
     89        // We iterate through all parameters and compare their values (which are strings). The first parameter is the most significant. The ordering is once again established by the alphabetical comparison of the two value strings.
    10890        for(std::map<std::string, std::string>::const_iterator it = this->parameters_.begin(); it != this->parameters_.end(); it++)
    10991        {
    110             //!< If a parameter present in one of the identifiers is not found in the other, once again, something is very wrong.
     92            // If a parameter present in one of the identifiers is not found in the other, once again, something is very wrong.
    11193            if(identifier->parameters_.find(it->first) == identifier->parameters_.end())
    11294            {
  • code/trunk/src/orxonox/pickup/PickupIdentifier.h

    r7456 r7494  
    4040#include <map>
    4141#include <string>
    42 #include "core/Identifier.h"
    4342
    4443#include "core/OrxonoxClass.h"
     
    4948    /**
    5049    @brief
    51         The purpose of the PickupIdentifier class is to identify different types of pickups allthough they are of the same class.
    52         This allows for more generic classes (or pickups in this case) that can be a number of different pickup types and can be identified as such without the need for a lot of different classes. An example is the HealthPickup class that encompasses a wide variety of different types of health pickups, e.g a HealthPickup that adds 10 health every second for 10 seconds or a HealthPickup that adds 100 health as soon as it is picked up, a.s.o.
    53         To that purpose this class provides functionality to compare two PickupIdentifier (and since all Pickupables have an Identifier through that Pickupables can be compared). It als provides functionality to add parameters that distinguish between different types of pickups in the same pickup class.
    54         Lastly a struct is provided that can be used in stl containers to establish a strictly lesser ordering between PickupIdentifiers (and thus Pickupables).
     50        The purpose of the PickupIdentifier class is to identify (or differentiate between) different types of pickups although they are of the same class.
     51
     52        This allows for more generic classes (or pickups in this case) that can be a number of different pickup types and can be identified as such without the need for a lot of different classes.
     53
     54        An example is the @ref orxonox::HealthPickup "HealthPickup" class that encompasses a wide variety of different types of health pickups, e.g a @ref orxonox::HealthPickup "HealthPickup" that adds 10 health every second for 10 seconds or a @ref orxonox::HealthPickup "HealthPickup" that adds 100 health as soon as it is picked up, a.s.o.
     55
     56        To that purpose this class provides functionality to compare two @ref orxonox::PickupIdentifier "PickupIdentifiers" (and since all @ref orxonox::Pickupable "Pickupables" have an identifier, we can use it to compare pickups). It als provides functionality to add parameters that distinguish between different types of pickups in the same pickup class.
     57
     58        Lastly a struct (@ref orxonox::PickupIdentifierCompare "PickupIdentifierCompare") is provided that can be used in stl containers to establish a strictly lesser ordering between @ref orxonox::PickupIdentifier "PickupIdentifiers" (and thus @ref orxonox::Pickupable "Pickupables").
    5559    @author
    5660        Damian 'Mozork' Frick
     
    7579    /**
    7680    @brief
    77         Struct that overloads the compare operation between two PickupIdentifier pointers.
     81        Struct that overloads the compare operation between two @ref orxonox::PickupIdentifier "PickupIdentifier" pointers.
    7882    */
    7983    struct PickupIdentifierCompare
Note: See TracChangeset for help on using the changeset viewer.