Changeset 7367 for code/branches/doc/src/libraries/util/OrxEnum.h
- Timestamp:
- Sep 6, 2010, 3:51:29 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/doc/src/libraries/util/OrxEnum.h
r5738 r7367 27 27 */ 28 28 29 /**30 @file31 @brief32 Declaration of the OrxEnum class.33 */34 35 29 #ifndef _OrxEnum_H__ 36 30 #define _OrxEnum_H__ … … 40 34 namespace orxonox 41 35 { 36 /** Lightweight enumeration class that can be extended at run time. 37 @details 38 The class accepts type int and also defines operator int(). Therefore 39 int and OrxEnum can be used interchangeably so you can extend the content 40 of the enumeration at run time by adding ints. 41 @par Declaring an OrxEnum 42 Write a struct that inherits OrxEnum and use some macros: 43 @code 44 struct MyEnum : OrxEnum<MyEnum> 45 { 46 OrxEnumConstructors(MyEnum); 47 48 static const int Value1 = -1; 49 static const int Value2 = 0; 50 static const int Value3 = Value2 + 10; 51 }; 52 @endcode 53 */ 42 54 template <class T> 43 55 struct OrxEnum … … 45 57 public: 46 58 OrxEnum() { } 47 OrxEnum(int type) 59 OrxEnum(int type) { type_ = type; } 48 60 OrxEnum(const T& instance) { type_ = instance.type_; } 49 61 50 operator int() 62 operator int() { return type_; } 51 63 T& operator =(int type) { type_ = type; return *this; } 52 64 bool operator <(const T& right) const { return (type_ < right.type_); } … … 59 71 } 60 72 73 /// See orxonox::OrxEnum for more info 61 74 #define OrxEnumConstructors(enumName) \ 62 75 enumName() { } \
Note: See TracChangeset
for help on using the changeset viewer.