Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/data_cleanup/src/orxonox/pickup/PickupIdentifier.h @ 7536

Last change on this file since 7536 was 7494, checked in by dafrick, 14 years ago

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

  • 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    @author
60        Damian 'Mozork' Frick
61    */
62    class _OrxonoxExport PickupIdentifier : virtual public OrxonoxClass
63    {
64
65        public:
66            PickupIdentifier(Pickupable* pickup); //!< Constructor.
67            ~PickupIdentifier(); //!< Destructor.
68
69            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).
70
71            bool addParameter(std::string & name, std::string & value); //!< Add a parameter to the PickupIdentifier.
72
73        private:
74            Pickupable* pickup_; //!< The Pickupable the PickupIdentififer is for.
75            std::map<std::string, std::string> parameters_; //!< The parameters identifying the type of the pickup beyond the class.
76
77    };
78
79    /**
80    @brief
81        Struct that overloads the compare operation between two @ref orxonox::PickupIdentifier "PickupIdentifier" pointers.
82    */
83    struct PickupIdentifierCompare
84    {
85        bool operator() (const PickupIdentifier* lhs, const PickupIdentifier* rhs) const
86            { return lhs->compare(rhs) < 0; }
87    };
88
89}
90
91#endif // _PickupIdentifier_H__
Note: See TracBrowser for help on using the repository browser.