Changeset 1052 for code/trunk/src/util/MultiTypePrimitive.h
- Timestamp:
- Apr 14, 2008, 3:42:49 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/util/MultiTypePrimitive.h
r890 r1052 36 36 #include "MultiType.h" 37 37 38 namespace orxonox 39 { 40 class BaseObject; 41 } 38 42 class _UtilExport MultiTypePrimitive 39 43 { 40 44 public: 41 MultiTypePrimitive(MultiType type = MT_null); 45 MultiTypePrimitive(MultiType type = MT_null); 46 inline MultiTypePrimitive(void* value) { this->setValue(value); } 42 47 inline MultiTypePrimitive(int value) { this->setValue(value); } 43 48 inline MultiTypePrimitive(unsigned int value) { this->setValue(value); } … … 56 61 57 62 inline MultiTypePrimitive& operator=(MultiType value) { this->type_ = MT_null; return *this; } 63 inline MultiTypePrimitive& operator=(void* value) { this->setValue(value); return *this; } 58 64 inline MultiTypePrimitive& operator=(int value) { this->setValue(value); return *this; } 59 65 inline MultiTypePrimitive& operator=(unsigned int value) { this->setValue(value); return *this; } … … 70 76 inline MultiTypePrimitive& operator=(const MultiTypePrimitive& mtp) { this->setValue(mtp); return *this; } 71 77 78 inline bool operator==(void* value) const { return (this->value_.void_ == value); } 72 79 inline bool operator==(int value) const { return (this->value_.int_ == value); } 73 80 inline bool operator==(unsigned int value) const { return (this->value_.uint_ == value); } … … 84 91 bool operator==(const MultiTypePrimitive& mtp) const; 85 92 86 inline bool operator!=( int value) const { return (this->value_.int_!= value); }93 inline bool operator!=(void* value) const { return (this->value_.void_ != value); } 87 94 inline bool operator!=(unsigned int value) const { return (this->value_.uint_ != value); } 88 95 inline bool operator!=(char value) const { return (this->value_.char_ != value); } … … 98 105 bool operator!=(const MultiTypePrimitive& mtp) const; 99 106 107 template <class T> 108 operator T*() const 109 { return ((T*)this->value_.void_); } 110 virtual operator void*() const; 100 111 virtual operator int() const; 101 112 virtual operator unsigned int() const; … … 111 122 virtual operator bool() const; 112 123 124 inline void setValue(void* value) { this->type_ = MT_void; this->value_.void_ = value; } 113 125 inline void setValue(int value) { this->type_ = MT_int; this->value_.int_ = value; } 114 126 inline void setValue(unsigned int value) { this->type_ = MT_uint; this->value_.uint_ = value; } … … 125 137 void setValue(const MultiTypePrimitive& mtp); 126 138 139 inline void* getVoid() const { return this->value_.void_; } 127 140 inline int getInt() const { return this->value_.int_; } 128 141 inline unsigned int getUnsignedInt() const { return this->value_.uint_; } … … 151 164 inline bool& getBool() { return this->value_.bool_; } 152 165 166 inline void getValue(void* variable) const { variable = this->value_.void_; } 153 167 inline void getValue(int* variable) const { (*variable) = this->value_.int_; } 154 168 inline void getValue(unsigned int* variable) const { (*variable) = this->value_.uint_; } … … 167 181 inline bool isA(MultiType type) const { return (this->type_ == type); } 168 182 183 virtual std::string getTypename() const; 184 169 185 virtual std::string toString() const; 170 186 virtual bool fromString(const std::string value);
Note: See TracChangeset
for help on using the changeset viewer.