Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/gamestates3/src/orxonox/pickup/PickupIdentifier.h @ 10181

Last change on this file since 10181 was 6540, checked in by dafrick, 15 years ago

Removed some TODO's. Finished up documenting pickup module.

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