Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/chat/src/orxonox/pickup/PickupIdentifier.h @ 6874

Last change on this file since 6874 was 6524, checked in by dafrick, 15 years ago

Merged pickup branch into trunk. Yay. Persisting bugs will be fixed, very soon.

File size: 3.4 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#ifndef _PickupIdentifier_H__
30#define _PickupIdentifier_H__
31
32#include "OrxonoxPrereqs.h"
33
34#include <map>
35#include <string>
36#include "core/Identifier.h"
37
38#include "core/OrxonoxClass.h"
39
40namespace orxonox
41{
42   
43    /**
44    @brief
45        The purpose of the PickupIdentifier class is to identify different types of pickups allthough they are of the same class.
46        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.
47        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.
48        Lastly a struct is provided that can be used in stl containers to establish a strictly lesser ordering between PickupIdentifiers (and thus Pickupables).
49    @author
50        Damian 'Mozork' Frick
51    */
52    class _OrxonoxExport PickupIdentifier : virtual public OrxonoxClass
53    {
54       
55        public:
56            PickupIdentifier(Pickupable* pickup); //!< Constructor.
57            ~PickupIdentifier(); //!< Destructor.
58           
59            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).
60           
61            bool addParameter(std::string & name, std::string & value); //!< Add a parameter to the PickupIdentifier.
62           
63        private:
64            Pickupable* pickup_; //!< The Pickupable the PickupIdentififer is for.
65            std::map<std::string, std::string> parameters_; //!< The parameters identifying the type of the pickup beyond the class.
66           
67    };
68   
69    /**
70    @brief
71        Struct that overloads the compare operation between two PickupIdentifier pointers.
72    */
73    struct PickupIdentifierCompare
74    {
75        bool operator() (const PickupIdentifier* lhs, const PickupIdentifier* rhs) const
76            { return lhs->compare(rhs) < 0; }
77    };
78   
79}
80
81#endif // _PickupIdentifier_H__
Note: See TracBrowser for help on using the repository browser.