Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/archive/waypoints/src/orxonox/pickup/PickupIdentifier.h @ 10241

Last change on this file since 10241 was 7551, checked in by dafrick, 14 years ago

Moved documentation for pickup module from wiki to doxygen.

  • Property svn:eol-style set to native
File size: 3.7 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Damian 'Mozork' Frick
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29/**
30    @file PickupIdentifier.h
31    @brief Definition of the PickupIdentifier class.
32    @ingroup Pickup
33*/
34
35#ifndef _PickupIdentifier_H__
36#define _PickupIdentifier_H__
37
38#include "OrxonoxPrereqs.h"
39
40#include <map>
41#include <string>
42
43#include "core/OrxonoxClass.h"
44
45namespace orxonox
46{
47
48    /**
49    @brief
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").
59
60    @author
61        Damian 'Mozork' Frick
62
63    @ingroup Pickup
64    */
65    class _OrxonoxExport PickupIdentifier : virtual public OrxonoxClass
66    {
67
68        public:
69            PickupIdentifier(Pickupable* pickup); //!< Constructor.
70            ~PickupIdentifier(); //!< Destructor.
71
72            virtual int compare(const PickupIdentifier* identifier) const; //!< Compares two PickupIdentifiers and returns 0 if a == b, <0 if a < b and >0 if a > b for a.compare(b).
73
74            bool addParameter(std::string & name, std::string & value); //!< Add a parameter to the PickupIdentifier.
75
76        private:
77            Pickupable* pickup_; //!< The Pickupable the PickupIdentififer is for.
78            std::map<std::string, std::string> parameters_; //!< The parameters identifying the type of the pickup beyond the class.
79
80    };
81
82    /**
83    @brief
84        Struct that overloads the compare operation between two @ref orxonox::PickupIdentifier "PickupIdentifier" pointers.
85
86    @ingroup Pickup
87    */
88    struct PickupIdentifierCompare
89    {
90        bool operator() (const PickupIdentifier* lhs, const PickupIdentifier* rhs) const
91            { return lhs->compare(rhs) < 0; }
92    };
93
94}
95
96#endif // _PickupIdentifier_H__
Note: See TracBrowser for help on using the repository browser.