Orxonox  0.0.5 Codename: Arcturus
OrxEnum.h
Go to the documentation of this file.
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  * Reto Grieder
24  * Co-authors:
25  * ...
26  *
27  */
28 
34 #ifndef _OrxEnum_H__
35 #define _OrxEnum_H__
36 
37 #include "UtilPrereqs.h"
38 
39 namespace orxonox
40 {
59  template <class T>
60  struct OrxEnum
61  {
62  public:
63  constexpr OrxEnum() : type_() {}
64  constexpr OrxEnum(int type) : type_(type) {}
65  constexpr OrxEnum(const T& instance) : type_(instance.type_) {}
66  constexpr OrxEnum(const OrxEnum& instance) = delete;
67 
68  constexpr operator int() const { return type_; }
69  T& operator =(int type) { type_ = type; return *this; }
70  constexpr bool operator <(const T& right) const { return (type_ < right.type_); }
71  constexpr bool operator >(const T& right) const { return (type_ > right.type_); }
72 
73  private:
74  int type_;
75  };
76 }
77 
79 #define OrxEnumConstructors(enumName) \
80 constexpr enumName() { } \
81 constexpr enumName(int type) : OrxEnum<enumName>(type) { } \
82 constexpr enumName(const enumName& inst) : OrxEnum<enumName>(inst) { } \
83 void dummyFunction()
84 
85 #endif /* _OrxEnum_H__ */
int type_
Definition: OrxEnum.h:74
constexpr OrxEnum()
Definition: OrxEnum.h:63
constexpr bool operator>(const T &right) const
Definition: OrxEnum.h:71
constexpr OrxEnum(const T &instance)
Definition: OrxEnum.h:65
constexpr bool operator<(const T &right) const
Definition: OrxEnum.h:70
T & operator=(int type)
Definition: OrxEnum.h:69
Die Wagnis Klasse hat die folgenden Aufgaben:
Definition: ApplicationPaths.cc:66
Shared library macros, enums, constants and forward declarations for the util library ...
constexpr OrxEnum(int type)
Definition: OrxEnum.h:64
Definition: InputPrereqs.h:78
Lightweight enumeration class that can be extended at run time.
Definition: OrxEnum.h:60