| 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 | *      Fabian 'x3n' Landau | 
|---|
| 24 | *   Co-authors: | 
|---|
| 25 | *      ... | 
|---|
| 26 | * | 
|---|
| 27 | */ | 
|---|
| 28 |  | 
|---|
| 29 | /** | 
|---|
| 30 | @file | 
|---|
| 31 | @brief Declaration of the MultiType and some helper constructs. | 
|---|
| 32 |  | 
|---|
| 33 | The MultiType can hold a value of one of the following types: | 
|---|
| 34 | - all primitives | 
|---|
| 35 | - all pointers | 
|---|
| 36 | - string | 
|---|
| 37 | - Vector2, Vector3, Vector4 | 
|---|
| 38 | - Quaternion | 
|---|
| 39 | - ColourValue | 
|---|
| 40 | - Radian, Degree | 
|---|
| 41 |  | 
|---|
| 42 | The MultiType has a "type" determined by the first assigned value, either through | 
|---|
| 43 | - the constructor, | 
|---|
| 44 | - the assignment operator= or | 
|---|
| 45 | - setValue(value). | 
|---|
| 46 | If you assign another value of another type, the MultiType keeps "it's" type and | 
|---|
| 47 | converts the new value to this type. | 
|---|
| 48 |  | 
|---|
| 49 | If you want to change the type, there are three possibilities: | 
|---|
| 50 | - convert<T>() set's the type to T and converts the currently assigned value | 
|---|
| 51 | - setType<T>() set's the type to T and resets the value | 
|---|
| 52 | - setValue<T>(value) assigns a new value and changes the type to T. | 
|---|
| 53 |  | 
|---|
| 54 | @example | 
|---|
| 55 | MultiType a = 10;;         // a has now the type int and the value 10 | 
|---|
| 56 | a.setValue("3.14");        // a has still the type int and "3.14" gets converted, therefore the value is now 3 | 
|---|
| 57 | a.setValue<float>("3.14"); // a has now the type float and "3.14" gets converted to 3.14 | 
|---|
| 58 | a.convert<bool>();         // converts 3.14 to bool, which is true | 
|---|
| 59 | a = false;                 // assigns false, this is equivalent to a.setValue(false) | 
|---|
| 60 |  | 
|---|
| 61 | @note | 
|---|
| 62 | Whenever a value gets converted, there is a boolean return value telling you whether it was | 
|---|
| 63 | successful or not. If it wasn't a zero value is assigned with the help of zeroise<T>(). | 
|---|
| 64 | */ | 
|---|
| 65 |  | 
|---|
| 66 | #ifndef _MultiType_H__ | 
|---|
| 67 | #define _MultiType_H__ | 
|---|
| 68 |  | 
|---|
| 69 | #include "UtilPrereqs.h" | 
|---|
| 70 |  | 
|---|
| 71 | #include <cassert> | 
|---|
| 72 | #include <string> | 
|---|
| 73 | #include <OgreVector2.h> | 
|---|
| 74 | #include <OgreVector3.h> | 
|---|
| 75 | #include <OgreVector4.h> | 
|---|
| 76 | #include <OgreQuaternion.h> | 
|---|
| 77 | #include <OgreColourValue.h> | 
|---|
| 78 |  | 
|---|
| 79 | #include "TypeTraits.h" | 
|---|
| 80 |  | 
|---|
| 81 | namespace orxonox | 
|---|
| 82 | { | 
|---|
| 83 | /** | 
|---|
| 84 | @brief Enum of all possible types of a MultiType. | 
|---|
| 85 | */ | 
|---|
| 86 | namespace MT_Type | 
|---|
| 87 | { | 
|---|
| 88 | enum Value | 
|---|
| 89 | { | 
|---|
| 90 | Null, | 
|---|
| 91 | Char, | 
|---|
| 92 | UnsignedChar, | 
|---|
| 93 | Short, | 
|---|
| 94 | UnsignedShort, | 
|---|
| 95 | Int, | 
|---|
| 96 | UnsignedInt, | 
|---|
| 97 | Long, | 
|---|
| 98 | UnsignedLong, | 
|---|
| 99 | LongLong, | 
|---|
| 100 | UnsignedLongLong, | 
|---|
| 101 | Float, | 
|---|
| 102 | Double, | 
|---|
| 103 | LongDouble, | 
|---|
| 104 | Bool, | 
|---|
| 105 | VoidPointer, | 
|---|
| 106 | String, | 
|---|
| 107 | Vector2, | 
|---|
| 108 | Vector3, | 
|---|
| 109 | Vector4, | 
|---|
| 110 | ColourValue, | 
|---|
| 111 | Quaternion, | 
|---|
| 112 | Radian, | 
|---|
| 113 | Degree | 
|---|
| 114 | }; | 
|---|
| 115 | } | 
|---|
| 116 |  | 
|---|
| 117 | /** | 
|---|
| 118 | @brief The MultiType can hold a value of many possible types and convert them to other types. | 
|---|
| 119 |  | 
|---|
| 120 | The following types are supported by the MultiType: | 
|---|
| 121 | - all primitves | 
|---|
| 122 | - all pointers | 
|---|
| 123 | - string | 
|---|
| 124 | - Vector2, Vector3, Vector4 | 
|---|
| 125 | - Quaternion | 
|---|
| 126 | - ColourValue | 
|---|
| 127 | - Radian, Degree | 
|---|
| 128 |  | 
|---|
| 129 | The internal type of a MultiType is determined by the first assigned value, but can be | 
|---|
| 130 | changed by using setType<T>(), convert<T>() or setValue<T>(value). If a value gets assigned | 
|---|
| 131 | the normal way (operator=, setValue(value)), the value gets converted to the current internal | 
|---|
| 132 | type of the MultiType. | 
|---|
| 133 | */ | 
|---|
| 134 | class _UtilExport MultiType | 
|---|
| 135 | { | 
|---|
| 136 | _UtilExport friend std::ostream& operator<<(std::ostream& outstream, const MultiType& mt); | 
|---|
| 137 | template <typename T> friend class MT_Value; | 
|---|
| 138 |  | 
|---|
| 139 | public: | 
|---|
| 140 | /** | 
|---|
| 141 | @brief MT_ValueBase is an almost pure virtual baseclass of MT_Value<T>, which holds the value of the MultiType. | 
|---|
| 142 | This class is only used within the MultiType. | 
|---|
| 143 | */ | 
|---|
| 144 | class _UtilExport MT_ValueBase | 
|---|
| 145 | { | 
|---|
| 146 | public: | 
|---|
| 147 | MT_ValueBase(MT_Type::Value type) : type_(type), bHasDefaultValue_(false) {} | 
|---|
| 148 | virtual ~MT_ValueBase() {} | 
|---|
| 149 |  | 
|---|
| 150 | virtual MT_ValueBase* clone() const = 0; | 
|---|
| 151 |  | 
|---|
| 152 | virtual void reset() = 0; | 
|---|
| 153 | virtual bool assimilate(const MultiType& other) = 0; | 
|---|
| 154 |  | 
|---|
| 155 | /** @brief Returns the type of the current value. */ | 
|---|
| 156 | const MT_Type::Value& getType() const { return this->type_; } | 
|---|
| 157 |  | 
|---|
| 158 | /** @brief Checks whether the value is a default one. */ | 
|---|
| 159 | bool hasDefaultValue()   const { return this->bHasDefaultValue_; } | 
|---|
| 160 |  | 
|---|
| 161 | virtual bool setValue(const char& value)                 = 0; | 
|---|
| 162 | virtual bool setValue(const unsigned char& value)        = 0; | 
|---|
| 163 | virtual bool setValue(const short& value)                = 0; | 
|---|
| 164 | virtual bool setValue(const unsigned short& value)       = 0; | 
|---|
| 165 | virtual bool setValue(const int& value)                  = 0; | 
|---|
| 166 | virtual bool setValue(const unsigned int& value)         = 0; | 
|---|
| 167 | virtual bool setValue(const long& value)                 = 0; | 
|---|
| 168 | virtual bool setValue(const unsigned long& value)        = 0; | 
|---|
| 169 | virtual bool setValue(const long long& value)            = 0; | 
|---|
| 170 | virtual bool setValue(const unsigned long long& value)   = 0; | 
|---|
| 171 | virtual bool setValue(const float& value)                = 0; | 
|---|
| 172 | virtual bool setValue(const double& value)               = 0; | 
|---|
| 173 | virtual bool setValue(const long double& value)          = 0; | 
|---|
| 174 | virtual bool setValue(const bool& value)                 = 0; | 
|---|
| 175 | virtual bool setValue(      void* const& value)          = 0; | 
|---|
| 176 | virtual bool setValue(const std::string& value)          = 0; | 
|---|
| 177 | virtual bool setValue(const orxonox::Vector2& value)     = 0; | 
|---|
| 178 | virtual bool setValue(const orxonox::Vector3& value)     = 0; | 
|---|
| 179 | virtual bool setValue(const orxonox::Vector4& value)     = 0; | 
|---|
| 180 | virtual bool setValue(const orxonox::ColourValue& value) = 0; | 
|---|
| 181 | virtual bool setValue(const orxonox::Quaternion& value)  = 0; | 
|---|
| 182 | virtual bool setValue(const orxonox::Radian& value)      = 0; | 
|---|
| 183 | virtual bool setValue(const orxonox::Degree& value)      = 0; | 
|---|
| 184 |  | 
|---|
| 185 | virtual bool getValue(char*                 value) const = 0; | 
|---|
| 186 | virtual bool getValue(unsigned char*        value) const = 0; | 
|---|
| 187 | virtual bool getValue(short*                value) const = 0; | 
|---|
| 188 | virtual bool getValue(unsigned short*       value) const = 0; | 
|---|
| 189 | virtual bool getValue(int*                  value) const = 0; | 
|---|
| 190 | virtual bool getValue(unsigned int*         value) const = 0; | 
|---|
| 191 | virtual bool getValue(long*                 value) const = 0; | 
|---|
| 192 | virtual bool getValue(unsigned long*        value) const = 0; | 
|---|
| 193 | virtual bool getValue(long long*            value) const = 0; | 
|---|
| 194 | virtual bool getValue(unsigned long long*   value) const = 0; | 
|---|
| 195 | virtual bool getValue(float*                value) const = 0; | 
|---|
| 196 | virtual bool getValue(double*               value) const = 0; | 
|---|
| 197 | virtual bool getValue(long double*          value) const = 0; | 
|---|
| 198 | virtual bool getValue(bool*                 value) const = 0; | 
|---|
| 199 | virtual bool getValue(void**                value) const = 0; | 
|---|
| 200 | virtual bool getValue(std::string*          value) const = 0; | 
|---|
| 201 | virtual bool getValue(orxonox::Vector2*     value) const = 0; | 
|---|
| 202 | virtual bool getValue(orxonox::Vector3*     value) const = 0; | 
|---|
| 203 | virtual bool getValue(orxonox::Vector4*     value) const = 0; | 
|---|
| 204 | virtual bool getValue(orxonox::ColourValue* value) const = 0; | 
|---|
| 205 | virtual bool getValue(orxonox::Quaternion*  value) const = 0; | 
|---|
| 206 | virtual bool getValue(orxonox::Radian*      value) const = 0; | 
|---|
| 207 | virtual bool getValue(orxonox::Degree*      value) const = 0; | 
|---|
| 208 |  | 
|---|
| 209 | virtual operator char()                 const = 0; | 
|---|
| 210 | virtual operator unsigned char()        const = 0; | 
|---|
| 211 | virtual operator short()                const = 0; | 
|---|
| 212 | virtual operator unsigned short()       const = 0; | 
|---|
| 213 | virtual operator int()                  const = 0; | 
|---|
| 214 | virtual operator unsigned int()         const = 0; | 
|---|
| 215 | virtual operator long()                 const = 0; | 
|---|
| 216 | virtual operator unsigned long()        const = 0; | 
|---|
| 217 | virtual operator long long()            const = 0; | 
|---|
| 218 | virtual operator unsigned long long()   const = 0; | 
|---|
| 219 | virtual operator float()                const = 0; | 
|---|
| 220 | virtual operator double()               const = 0; | 
|---|
| 221 | virtual operator long double()          const = 0; | 
|---|
| 222 | virtual operator bool()                 const = 0; | 
|---|
| 223 | virtual operator void*()                const = 0; | 
|---|
| 224 | virtual operator std::string()          const = 0; | 
|---|
| 225 | virtual operator orxonox::Vector2()     const = 0; | 
|---|
| 226 | virtual operator orxonox::Vector3()     const = 0; | 
|---|
| 227 | virtual operator orxonox::Vector4()     const = 0; | 
|---|
| 228 | virtual operator orxonox::ColourValue() const = 0; | 
|---|
| 229 | virtual operator orxonox::Quaternion()  const = 0; | 
|---|
| 230 | virtual operator orxonox::Radian()      const = 0; | 
|---|
| 231 | virtual operator orxonox::Degree()      const = 0; | 
|---|
| 232 |  | 
|---|
| 233 | virtual void toString(std::ostream& outstream) const = 0; | 
|---|
| 234 |  | 
|---|
| 235 | virtual void importData( uint8_t*& mem )=0; | 
|---|
| 236 | virtual void exportData( uint8_t*& mem ) const=0; | 
|---|
| 237 | virtual uint8_t getSize() const=0; | 
|---|
| 238 |  | 
|---|
| 239 | MT_Type::Value type_;   //!< The type of the current value | 
|---|
| 240 | bool bHasDefaultValue_; //!< True if the last conversion wasn't successful | 
|---|
| 241 | }; | 
|---|
| 242 |  | 
|---|
| 243 | public: | 
|---|
| 244 | inline MultiType()                                  : value_(0) {}                                      /** @brief Default constructor: Assigns no value and no type. The type will be determined by the first assignment of a value. */ | 
|---|
| 245 | inline MultiType(const char& value)                 : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */ | 
|---|
| 246 | inline MultiType(const unsigned char& value)        : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */ | 
|---|
| 247 | inline MultiType(const short& value)                : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */ | 
|---|
| 248 | inline MultiType(const unsigned short& value)       : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */ | 
|---|
| 249 | inline MultiType(const int& value)                  : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */ | 
|---|
| 250 | inline MultiType(const unsigned int& value)         : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */ | 
|---|
| 251 | inline MultiType(const long& value)                 : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */ | 
|---|
| 252 | inline MultiType(const unsigned long& value)        : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */ | 
|---|
| 253 | inline MultiType(const long long& value)            : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */ | 
|---|
| 254 | inline MultiType(const unsigned long long& value)   : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */ | 
|---|
| 255 | inline MultiType(const float& value)                : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */ | 
|---|
| 256 | inline MultiType(const double& value)               : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */ | 
|---|
| 257 | inline MultiType(const long double& value)          : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */ | 
|---|
| 258 | inline MultiType(const bool& value)                 : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */ | 
|---|
| 259 | inline MultiType(      void* const& value)          : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */ | 
|---|
| 260 | inline MultiType(const std::string& value)          : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */ | 
|---|
| 261 | inline MultiType(const orxonox::Vector2& value)     : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */ | 
|---|
| 262 | inline MultiType(const orxonox::Vector3& value)     : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */ | 
|---|
| 263 | inline MultiType(const orxonox::Vector4& value)     : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */ | 
|---|
| 264 | inline MultiType(const orxonox::ColourValue& value) : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */ | 
|---|
| 265 | inline MultiType(const orxonox::Quaternion& value)  : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */ | 
|---|
| 266 | inline MultiType(const orxonox::Radian& value)      : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */ | 
|---|
| 267 | inline MultiType(const orxonox::Degree& value)      : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */ | 
|---|
| 268 | inline MultiType(const char* value)                 : value_(0) { this->setValue(std::string(value)); } /** @brief Constructor: Converts the char array to a std::string, assigns the value and sets the type. */ | 
|---|
| 269 | inline MultiType(const MultiType& other)            : value_(0) { this->setValue(other); }              /** @brief Copyconstructor: Assigns value and type of the other MultiType. */ | 
|---|
| 270 | inline MultiType(MT_Type::Value type)               : value_(0) { this->setType(type); }                /** @brief Constructor: Sets the type, the next assignment will determine the value. */ | 
|---|
| 271 |  | 
|---|
| 272 | /** @brief Destructor: Deletes the MT_Value. */ | 
|---|
| 273 | inline ~MultiType() { if (this->value_) { delete this->value_; } } | 
|---|
| 274 |  | 
|---|
| 275 | template <typename V> inline const MultiType& operator=(const V& value)         { this->setValue(value); return (*this); } /** @brief Assigns a new value. The value will be converted to the current type of the MultiType. */ | 
|---|
| 276 | template <typename V> inline const MultiType& operator=(V* value)               { this->setValue(value); return (*this); } /** @brief Assigns a pointer. */ | 
|---|
| 277 | inline                       const MultiType& operator=(const MultiType& other) { this->setValue(other); return (*this); } /** @brief Assigns the value of the other MultiType and converts it to the current type of the MultiType. */ | 
|---|
| 278 | inline                       const MultiType& operator=(MT_Type::Value type)    { this->setType(type);   return (*this); } /** @brief Resets the value and changes the type. */ | 
|---|
| 279 |  | 
|---|
| 280 | inline bool                                   setValue(const char& value); | 
|---|
| 281 | inline bool                                   setValue(const unsigned char& value); | 
|---|
| 282 | inline bool                                   setValue(const short& value); | 
|---|
| 283 | inline bool                                   setValue(const unsigned short& value); | 
|---|
| 284 | inline bool                                   setValue(const int& value); | 
|---|
| 285 | inline bool                                   setValue(const unsigned int& value); | 
|---|
| 286 | inline bool                                   setValue(const long& value); | 
|---|
| 287 | inline bool                                   setValue(const unsigned long& value); | 
|---|
| 288 | inline bool                                   setValue(const long long& value); | 
|---|
| 289 | inline bool                                   setValue(const unsigned long long& value); | 
|---|
| 290 | inline bool                                   setValue(const float& value); | 
|---|
| 291 | inline bool                                   setValue(const double& value); | 
|---|
| 292 | inline bool                                   setValue(const long double& value); | 
|---|
| 293 | inline bool                                   setValue(const bool& value); | 
|---|
| 294 | inline bool                                   setValue(      void* const& value); | 
|---|
| 295 | inline bool                                   setValue(const std::string& value); | 
|---|
| 296 | inline bool                                   setValue(const orxonox::Vector2& value); | 
|---|
| 297 | inline bool                                   setValue(const orxonox::Vector3& value); | 
|---|
| 298 | inline bool                                   setValue(const orxonox::Vector4& value); | 
|---|
| 299 | inline bool                                   setValue(const orxonox::ColourValue& value); | 
|---|
| 300 | inline bool                                   setValue(const orxonox::Quaternion& value); | 
|---|
| 301 | inline bool                                   setValue(const orxonox::Radian& value); | 
|---|
| 302 | inline bool                                   setValue(const orxonox::Degree& value); | 
|---|
| 303 | inline bool                                   setValue(const char* value); | 
|---|
| 304 | /** @brief Assigns a pointer. */ | 
|---|
| 305 | template <typename V> inline bool setValue(V* value) | 
|---|
| 306 | { | 
|---|
| 307 | if (this->value_) | 
|---|
| 308 | return this->value_->setValue(static_cast<void*>(const_cast<typename Loki::TypeTraits<V>::UnqualifiedType*>(value))); | 
|---|
| 309 | else | 
|---|
| 310 | return this->assignValue     (static_cast<void*>(const_cast<typename Loki::TypeTraits<V>::UnqualifiedType*>(value))); | 
|---|
| 311 | } | 
|---|
| 312 | /** @brief Assigns the value of the other MultiType and converts it to the current type. */ | 
|---|
| 313 | bool                                          setValue(const MultiType& other) { if (this->value_) { return this->value_->assimilate(other); } else { if (other.value_) { this->value_ = other.value_->clone(); } return true; } } | 
|---|
| 314 | /** @brief Changes the type to T and assigns the new value (which might be of another type than T - it gets converted). */ | 
|---|
| 315 | template <typename T, typename V> inline bool setValue(const V& value) { this->setType<T>(); return this->setValue(value); } | 
|---|
| 316 |  | 
|---|
| 317 |  | 
|---|
| 318 | /** @brief Copies the other MultiType by assigning value and type. */ | 
|---|
| 319 | inline void                       copy(const MultiType& other)    { if (this == &other) { return; } if (this->value_) { delete this->value_; } this->value_ = (other.value_) ? other.value_->clone() : 0; } | 
|---|
| 320 |  | 
|---|
| 321 | template <typename T> inline bool convert()                       { return this->setValue<T>((T)(*this));  } /** @brief Converts the current value to type T. */ | 
|---|
| 322 | inline bool                       convert(const MultiType& other) { return this->convert(other.getType()); } /** @brief Converts the current value to the type of the other MultiType. */ | 
|---|
| 323 | bool                              convert(MT_Type::Value type); | 
|---|
| 324 |  | 
|---|
| 325 | /** @brief Current content gets deleted. New type is MT_Type::Null */ | 
|---|
| 326 | inline void                       reset()                         { if (this->value_) delete this->value_; this->value_ = 0; } | 
|---|
| 327 | /** @brief Current content gets overridden with default zero value */ | 
|---|
| 328 | inline void                       resetValue()                    { if (this->value_) this->value_->reset(); } | 
|---|
| 329 |  | 
|---|
| 330 | template <typename T> inline void setType()                       { this->assignValue(typename Loki::TypeTraits<T>::UnqualifiedReferredType()); } /** @brief Resets the value and changes the internal type to T. */ | 
|---|
| 331 | inline void                       setType(const MultiType& other) { this->setType(other.getType());                                             } /** @brief Resets the value and changes the internal type to the type of the other MultiType. */ | 
|---|
| 332 | inline void                       setType(MT_Type::Value type)    { this->reset(); this->convert(type); this->resetValue();                     } /** @brief Resets the value and changes the internal type to the given type. */ | 
|---|
| 333 |  | 
|---|
| 334 | /** @brief Returns the current type. */ | 
|---|
| 335 | inline MT_Type::Value             getType()                   const { return (this->value_) ? this->value_->type_ : MT_Type::Null; } | 
|---|
| 336 | /** @brief Returns true if the current type equals the given type. */ | 
|---|
| 337 | inline bool                       isType(MT_Type::Value type) const { return (this->value_) ? (this->value_->type_ == type) : (type == MT_Type::Null); } | 
|---|
| 338 | /** @brief Returns true if the current type is T. */ | 
|---|
| 339 | template <typename T> inline bool isType()                    const { return false; } // Only works for specialized values - see below | 
|---|
| 340 | std::string                       getTypename()               const; | 
|---|
| 341 |  | 
|---|
| 342 | /** @brief Saves the value of the MT to a bytestream (pointed at by mem) and increases mem pointer by size of MT */ | 
|---|
| 343 | inline void                       exportData(uint8_t*& mem) const { assert(sizeof(MT_Type::Value)<=8); *static_cast<uint8_t*>(mem) = this->getType(); mem+=sizeof(uint8_t); this->value_->exportData(mem); } | 
|---|
| 344 | /** @brief Loads the value of the MT from a bytestream (pointed at by mem) and increases mem pointer by size of MT */ | 
|---|
| 345 | inline void                       importData(uint8_t*& mem) { assert(sizeof(MT_Type::Value)<=8); this->setType(static_cast<MT_Type::Value>(*static_cast<uint8_t*>(mem))); mem+=sizeof(uint8_t); this->value_->importData(mem); } | 
|---|
| 346 | /** @brief Saves the value of the MT to a bytestream and increases pointer to bytestream by size of MT */ | 
|---|
| 347 | inline uint8_t*&                  operator << (uint8_t*& mem) { importData(mem); return mem; } | 
|---|
| 348 | /** @brief Loads the value of the MT to a bytestream and increases pointer to bytestream by size of MT */ | 
|---|
| 349 | inline void                       operator >> (uint8_t*& mem) const { exportData(mem); } | 
|---|
| 350 | inline uint32_t                   getNetworkSize() const { assert(this->value_); return this->value_->getSize() + sizeof(uint8_t); } | 
|---|
| 351 |  | 
|---|
| 352 | /** @brief Checks whether the value is a default one. */ | 
|---|
| 353 | bool                              hasDefaultValue()         const { return this->value_->hasDefaultValue(); } | 
|---|
| 354 |  | 
|---|
| 355 | operator char()                  const; | 
|---|
| 356 | operator unsigned char()         const; | 
|---|
| 357 | operator short()                 const; | 
|---|
| 358 | operator unsigned short()        const; | 
|---|
| 359 | operator int()                   const; | 
|---|
| 360 | operator unsigned int()          const; | 
|---|
| 361 | operator long()                  const; | 
|---|
| 362 | operator unsigned long()         const; | 
|---|
| 363 | operator long long()             const; | 
|---|
| 364 | operator unsigned long long()    const; | 
|---|
| 365 | operator float()                 const; | 
|---|
| 366 | operator double()                const; | 
|---|
| 367 | operator long double()           const; | 
|---|
| 368 | operator bool()                  const; | 
|---|
| 369 | operator void*()                 const; | 
|---|
| 370 | operator std::string()           const; | 
|---|
| 371 | operator orxonox::Vector2()      const; | 
|---|
| 372 | operator orxonox::Vector3()      const; | 
|---|
| 373 | operator orxonox::Vector4()      const; | 
|---|
| 374 | operator orxonox::ColourValue()  const; | 
|---|
| 375 | operator orxonox::Quaternion()   const; | 
|---|
| 376 | operator orxonox::Radian()       const; | 
|---|
| 377 | operator orxonox::Degree()       const; | 
|---|
| 378 | /** @brief Returns the current value, converted to a T* pointer. */ | 
|---|
| 379 | template <class T> operator T*() const { return (static_cast<T*>(this->operator void*())); } | 
|---|
| 380 |  | 
|---|
| 381 | inline bool getValue(char*                 value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ | 
|---|
| 382 | inline bool getValue(unsigned char*        value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ | 
|---|
| 383 | inline bool getValue(short*                value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ | 
|---|
| 384 | inline bool getValue(unsigned short*       value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ | 
|---|
| 385 | inline bool getValue(int*                  value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ | 
|---|
| 386 | inline bool getValue(unsigned int*         value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ | 
|---|
| 387 | inline bool getValue(long*                 value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ | 
|---|
| 388 | inline bool getValue(unsigned long*        value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ | 
|---|
| 389 | inline bool getValue(long long*            value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ | 
|---|
| 390 | inline bool getValue(unsigned long long*   value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ | 
|---|
| 391 | inline bool getValue(float*                value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ | 
|---|
| 392 | inline bool getValue(double*               value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ | 
|---|
| 393 | inline bool getValue(long double*          value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ | 
|---|
| 394 | inline bool getValue(bool*                 value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ | 
|---|
| 395 | inline bool getValue(void**                value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ | 
|---|
| 396 | inline bool getValue(std::string*          value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ | 
|---|
| 397 | inline bool getValue(orxonox::Vector2*     value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ | 
|---|
| 398 | inline bool getValue(orxonox::Vector3*     value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ | 
|---|
| 399 | inline bool getValue(orxonox::Vector4*     value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ | 
|---|
| 400 | inline bool getValue(orxonox::ColourValue* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ | 
|---|
| 401 | inline bool getValue(orxonox::Quaternion*  value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ | 
|---|
| 402 | inline bool getValue(orxonox::Radian*      value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ | 
|---|
| 403 | inline bool getValue(orxonox::Degree*      value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ | 
|---|
| 404 |  | 
|---|
| 405 | inline char                     getChar()             const { return this->operator char();                 } /** @brief Returns the current value, converted to the requested type. */ | 
|---|
| 406 | inline unsigned char            getUnsignedChar()     const { return this->operator unsigned char();        } /** @brief Returns the current value, converted to the requested type. */ | 
|---|
| 407 | inline short                    getShort()            const { return this->operator short();                } /** @brief Returns the current value, converted to the requested type. */ | 
|---|
| 408 | inline unsigned short           getUnsignedShort()    const { return this->operator unsigned short();       } /** @brief Returns the current value, converted to the requested type. */ | 
|---|
| 409 | inline int                      getInt()              const { return this->operator int();                  } /** @brief Returns the current value, converted to the requested type. */ | 
|---|
| 410 | inline unsigned int             getUnsignedInt()      const { return this->operator unsigned int();         } /** @brief Returns the current value, converted to the requested type. */ | 
|---|
| 411 | inline long                     getLong()             const { return this->operator long();                 } /** @brief Returns the current value, converted to the requested type. */ | 
|---|
| 412 | inline unsigned long            getUnsignedLong()     const { return this->operator unsigned long();        } /** @brief Returns the current value, converted to the requested type. */ | 
|---|
| 413 | inline long long                getLongLong()         const { return this->operator long long();            } /** @brief Returns the current value, converted to the requested type. */ | 
|---|
| 414 | inline unsigned long long       getUnsignedLongLong() const { return this->operator unsigned long long();   } /** @brief Returns the current value, converted to the requested type. */ | 
|---|
| 415 | inline float                    getFloat()            const { return this->operator float();                } /** @brief Returns the current value, converted to the requested type. */ | 
|---|
| 416 | inline double                   getDouble()           const { return this->operator double();               } /** @brief Returns the current value, converted to the requested type. */ | 
|---|
| 417 | inline long double              getLongDouble()       const { return this->operator long double();          } /** @brief Returns the current value, converted to the requested type. */ | 
|---|
| 418 | inline bool                     getBool()             const { return this->operator bool();                 } /** @brief Returns the current value, converted to the requested type. */ | 
|---|
| 419 | inline void*                    getVoid()             const { return this->operator void*();                } /** @brief Returns the current value, converted to the requested type. */ | 
|---|
| 420 | inline std::string              getString()           const { return this->operator std::string();          } /** @brief Returns the current value, converted to the requested type. */ | 
|---|
| 421 | inline orxonox::Vector2         getVector2()          const { return this->operator orxonox::Vector2();     } /** @brief Returns the current value, converted to the requested type. */ | 
|---|
| 422 | inline orxonox::Vector3         getVector3()          const { return this->operator orxonox::Vector3();     } /** @brief Returns the current value, converted to the requested type. */ | 
|---|
| 423 | inline orxonox::Vector4         getVector4()          const { return this->operator orxonox::Vector4();     } /** @brief Returns the current value, converted to the requested type. */ | 
|---|
| 424 | inline orxonox::ColourValue     getColourValue()      const { return this->operator orxonox::ColourValue(); } /** @brief Returns the current value, converted to the requested type. */ | 
|---|
| 425 | inline orxonox::Quaternion      getQuaternion()       const { return this->operator orxonox::Quaternion();  } /** @brief Returns the current value, converted to the requested type. */ | 
|---|
| 426 | inline orxonox::Radian          getRadian()           const { return this->operator orxonox::Radian();      } /** @brief Returns the current value, converted to the requested type. */ | 
|---|
| 427 | inline orxonox::Degree          getDegree()           const { return this->operator orxonox::Degree();      } /** @brief Returns the current value, converted to the requested type. */ | 
|---|
| 428 | template <typename T> inline T* getPointer()          const { return static_cast<T*>(this->getVoid());      } /** @brief Returns the current value, converted to a T* pointer. */ | 
|---|
| 429 |  | 
|---|
| 430 | private: | 
|---|
| 431 | inline bool assignValue(const char& value)                 { if (this->value_ && this->value_->type_ == MT_Type::Char)             { return this->value_->setValue(value); } else { this->changeValueContainer<char>(value);                 return true; } } /** @brief Assigns a new value by changing type and creating a new container. */ | 
|---|
| 432 | inline bool assignValue(const unsigned char& value)        { if (this->value_ && this->value_->type_ == MT_Type::UnsignedChar)     { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned char>(value);        return true; } } /** @brief Assigns a new value by changing type and creating a new container. */ | 
|---|
| 433 | inline bool assignValue(const short& value)                { if (this->value_ && this->value_->type_ == MT_Type::Short)            { return this->value_->setValue(value); } else { this->changeValueContainer<short>(value);                return true; } } /** @brief Assigns a new value by changing type and creating a new container. */ | 
|---|
| 434 | inline bool assignValue(const unsigned short& value)       { if (this->value_ && this->value_->type_ == MT_Type::UnsignedShort)    { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned short>(value);       return true; } } /** @brief Assigns a new value by changing type and creating a new container. */ | 
|---|
| 435 | inline bool assignValue(const int& value)                  { if (this->value_ && this->value_->type_ == MT_Type::Int)              { return this->value_->setValue(value); } else { this->changeValueContainer<int>(value);                  return true; } } /** @brief Assigns a new value by changing type and creating a new container. */ | 
|---|
| 436 | inline bool assignValue(const unsigned int& value)         { if (this->value_ && this->value_->type_ == MT_Type::UnsignedInt)      { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned int>(value);         return true; } } /** @brief Assigns a new value by changing type and creating a new container. */ | 
|---|
| 437 | inline bool assignValue(const long& value)                 { if (this->value_ && this->value_->type_ == MT_Type::Long)             { return this->value_->setValue(value); } else { this->changeValueContainer<long>(value);                 return true; } } /** @brief Assigns a new value by changing type and creating a new container. */ | 
|---|
| 438 | inline bool assignValue(const unsigned long& value)        { if (this->value_ && this->value_->type_ == MT_Type::UnsignedLong)     { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned long>(value);        return true; } } /** @brief Assigns a new value by changing type and creating a new container. */ | 
|---|
| 439 | inline bool assignValue(const long long& value)            { if (this->value_ && this->value_->type_ == MT_Type::LongLong)         { return this->value_->setValue(value); } else { this->changeValueContainer<long long>(value);            return true; } } /** @brief Assigns a new value by changing type and creating a new container. */ | 
|---|
| 440 | inline bool assignValue(const unsigned long long& value)   { if (this->value_ && this->value_->type_ == MT_Type::UnsignedLongLong) { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned long long>(value);   return true; } } /** @brief Assigns a new value by changing type and creating a new container. */ | 
|---|
| 441 | inline bool assignValue(const float& value)                { if (this->value_ && this->value_->type_ == MT_Type::Float)            { return this->value_->setValue(value); } else { this->changeValueContainer<float>(value);                return true; } } /** @brief Assigns a new value by changing type and creating a new container. */ | 
|---|
| 442 | inline bool assignValue(const double& value)               { if (this->value_ && this->value_->type_ == MT_Type::Double)           { return this->value_->setValue(value); } else { this->changeValueContainer<double>(value);               return true; } } /** @brief Assigns a new value by changing type and creating a new container. */ | 
|---|
| 443 | inline bool assignValue(const long double& value)          { if (this->value_ && this->value_->type_ == MT_Type::LongDouble)       { return this->value_->setValue(value); } else { this->changeValueContainer<long double>(value);          return true; } } /** @brief Assigns a new value by changing type and creating a new container. */ | 
|---|
| 444 | inline bool assignValue(const bool& value)                 { if (this->value_ && this->value_->type_ == MT_Type::Bool)             { return this->value_->setValue(value); } else { this->changeValueContainer<bool>(value);                 return true; } } /** @brief Assigns a new value by changing type and creating a new container. */ | 
|---|
| 445 | inline bool assignValue(      void* const& value)          { if (this->value_ && this->value_->type_ == MT_Type::VoidPointer)      { return this->value_->setValue(value); } else { this->changeValueContainer<void*>(value);                return true; } } /** @brief Assigns a new value by changing type and creating a new container. */ | 
|---|
| 446 | inline bool assignValue(const std::string& value)          { if (this->value_ && this->value_->type_ == MT_Type::String)           { return this->value_->setValue(value); } else { this->changeValueContainer<std::string>(value);          return true; } } /** @brief Assigns a new value by changing type and creating a new container. */ | 
|---|
| 447 | inline bool assignValue(const orxonox::Vector2& value)     { if (this->value_ && this->value_->type_ == MT_Type::Vector2)          { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector2>(value);     return true; } } /** @brief Assigns a new value by changing type and creating a new container. */ | 
|---|
| 448 | inline bool assignValue(const orxonox::Vector3& value)     { if (this->value_ && this->value_->type_ == MT_Type::Vector3)          { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector3>(value);     return true; } } /** @brief Assigns a new value by changing type and creating a new container. */ | 
|---|
| 449 | inline bool assignValue(const orxonox::Vector4& value)     { if (this->value_ && this->value_->type_ == MT_Type::Vector4)          { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector4>(value);     return true; } } /** @brief Assigns a new value by changing type and creating a new container. */ | 
|---|
| 450 | inline bool assignValue(const orxonox::ColourValue& value) { if (this->value_ && this->value_->type_ == MT_Type::ColourValue)      { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::ColourValue>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */ | 
|---|
| 451 | inline bool assignValue(const orxonox::Quaternion& value)  { if (this->value_ && this->value_->type_ == MT_Type::Quaternion)       { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Quaternion>(value);  return true; } } /** @brief Assigns a new value by changing type and creating a new container. */ | 
|---|
| 452 | inline bool assignValue(const orxonox::Radian& value)      { if (this->value_ && this->value_->type_ == MT_Type::Radian)           { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Radian>(value);      return true; } } /** @brief Assigns a new value by changing type and creating a new container. */ | 
|---|
| 453 | inline bool assignValue(const orxonox::Degree& value)      { if (this->value_ && this->value_->type_ == MT_Type::Degree)           { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Degree>(value);      return true; } } /** @brief Assigns a new value by changing type and creating a new container. */ | 
|---|
| 454 |  | 
|---|
| 455 | /** @brief Changes the value container. */ | 
|---|
| 456 | template <typename T> inline void changeValueContainer(const T& value) { if (this->value_) { delete this->value_; } this->createNewValueContainer<T>(value); } | 
|---|
| 457 | /** @brief Creates a new value container (works only with specialized types). */ | 
|---|
| 458 | template <typename T>        void createNewValueContainer(const T& value) { /* STATIC ASSERT */ *****value; return false; } | 
|---|
| 459 |  | 
|---|
| 460 | MT_ValueBase* value_; //!< A pointer to the value container | 
|---|
| 461 | }; | 
|---|
| 462 |  | 
|---|
| 463 | /** @brief Puts the MultiType on a stream by using the native << operator of the current type. */ | 
|---|
| 464 | _UtilExport inline std::ostream& operator<<(std::ostream& outstream, const MultiType& mt) { if (mt.value_) { mt.value_->toString(outstream); } return outstream; } | 
|---|
| 465 |  | 
|---|
| 466 | template <> inline bool MultiType::isType<char>()                 const { return (this->value_ && this->value_->type_ == MT_Type::Char);             } /** @brief Returns true if the current type equals the given type. */ | 
|---|
| 467 | template <> inline bool MultiType::isType<unsigned char>()        const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedChar);     } /** @brief Returns true if the current type equals the given type. */ | 
|---|
| 468 | template <> inline bool MultiType::isType<short>()                const { return (this->value_ && this->value_->type_ == MT_Type::Short);            } /** @brief Returns true if the current type equals the given type. */ | 
|---|
| 469 | template <> inline bool MultiType::isType<unsigned short>()       const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedShort);    } /** @brief Returns true if the current type equals the given type. */ | 
|---|
| 470 | template <> inline bool MultiType::isType<int>()                  const { return (this->value_ && this->value_->type_ == MT_Type::Int);              } /** @brief Returns true if the current type equals the given type. */ | 
|---|
| 471 | template <> inline bool MultiType::isType<unsigned int>()         const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedInt);      } /** @brief Returns true if the current type equals the given type. */ | 
|---|
| 472 | template <> inline bool MultiType::isType<long>()                 const { return (this->value_ && this->value_->type_ == MT_Type::Long);             } /** @brief Returns true if the current type equals the given type. */ | 
|---|
| 473 | template <> inline bool MultiType::isType<unsigned long>()        const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedLong);     } /** @brief Returns true if the current type equals the given type. */ | 
|---|
| 474 | template <> inline bool MultiType::isType<long long>()            const { return (this->value_ && this->value_->type_ == MT_Type::LongLong);         } /** @brief Returns true if the current type equals the given type. */ | 
|---|
| 475 | template <> inline bool MultiType::isType<unsigned long long>()   const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedLongLong); } /** @brief Returns true if the current type equals the given type. */ | 
|---|
| 476 | template <> inline bool MultiType::isType<float>()                const { return (this->value_ && this->value_->type_ == MT_Type::Float);            } /** @brief Returns true if the current type equals the given type. */ | 
|---|
| 477 | template <> inline bool MultiType::isType<double>()               const { return (this->value_ && this->value_->type_ == MT_Type::Double);           } /** @brief Returns true if the current type equals the given type. */ | 
|---|
| 478 | template <> inline bool MultiType::isType<long double>()          const { return (this->value_ && this->value_->type_ == MT_Type::LongDouble);       } /** @brief Returns true if the current type equals the given type. */ | 
|---|
| 479 | template <> inline bool MultiType::isType<bool>()                 const { return (this->value_ && this->value_->type_ == MT_Type::Bool);             } /** @brief Returns true if the current type equals the given type. */ | 
|---|
| 480 | template <> inline bool MultiType::isType<void*>()                const { return (this->value_ && this->value_->type_ == MT_Type::VoidPointer);      } /** @brief Returns true if the current type equals the given type. */ | 
|---|
| 481 | template <> inline bool MultiType::isType<std::string>()          const { return (this->value_ && this->value_->type_ == MT_Type::String);           } /** @brief Returns true if the current type equals the given type. */ | 
|---|
| 482 | template <> inline bool MultiType::isType<orxonox::Vector2>()     const { return (this->value_ && this->value_->type_ == MT_Type::Vector2);          } /** @brief Returns true if the current type equals the given type. */ | 
|---|
| 483 | template <> inline bool MultiType::isType<orxonox::Vector3>()     const { return (this->value_ && this->value_->type_ == MT_Type::Vector3);          } /** @brief Returns true if the current type equals the given type. */ | 
|---|
| 484 | template <> inline bool MultiType::isType<orxonox::Vector4>()     const { return (this->value_ && this->value_->type_ == MT_Type::Vector4);          } /** @brief Returns true if the current type equals the given type. */ | 
|---|
| 485 | template <> inline bool MultiType::isType<orxonox::ColourValue>() const { return (this->value_ && this->value_->type_ == MT_Type::ColourValue);      } /** @brief Returns true if the current type equals the given type. */ | 
|---|
| 486 | template <> inline bool MultiType::isType<orxonox::Quaternion>()  const { return (this->value_ && this->value_->type_ == MT_Type::Quaternion);       } /** @brief Returns true if the current type equals the given type. */ | 
|---|
| 487 | template <> inline bool MultiType::isType<orxonox::Radian>()      const { return (this->value_ && this->value_->type_ == MT_Type::Radian);           } /** @brief Returns true if the current type equals the given type. */ | 
|---|
| 488 | template <> inline bool MultiType::isType<orxonox::Degree>()      const { return (this->value_ && this->value_->type_ == MT_Type::Degree);           } /** @brief Returns true if the current type equals the given type. */ | 
|---|
| 489 |  | 
|---|
| 490 | // Specialization to avoid ambiguities with the conversion operator | 
|---|
| 491 | template <> inline bool MultiType::convert<std::string>()          { return this->setValue<std::string>         (this->operator std::string());          } /** @brief Converts the current value to the given type. */ | 
|---|
| 492 | template <> inline bool MultiType::convert<orxonox::Vector2>()     { return this->setValue<orxonox::Vector2>    (this->operator orxonox::Vector2());     } /** @brief Converts the current value to the given type. */ | 
|---|
| 493 | template <> inline bool MultiType::convert<orxonox::Vector3>()     { return this->setValue<orxonox::Vector3>    (this->operator orxonox::Vector3());     } /** @brief Converts the current value to the given type. */ | 
|---|
| 494 | template <> inline bool MultiType::convert<orxonox::Vector4>()     { return this->setValue<orxonox::Vector4>    (this->operator orxonox::Vector4());     } /** @brief Converts the current value to the given type. */ | 
|---|
| 495 | template <> inline bool MultiType::convert<orxonox::ColourValue>() { return this->setValue<orxonox::ColourValue>(this->operator orxonox::ColourValue()); } /** @brief Converts the current value to the given type. */ | 
|---|
| 496 | template <> inline bool MultiType::convert<orxonox::Quaternion>()  { return this->setValue<orxonox::Quaternion> (this->operator orxonox::Quaternion());  } /** @brief Converts the current value to the given type. */ | 
|---|
| 497 | template <> inline bool MultiType::convert<orxonox::Radian>()      { return this->setValue<orxonox::Radian>     (this->operator orxonox::Radian());      } /** @brief Converts the current value to the given type. */ | 
|---|
| 498 | template <> inline bool MultiType::convert<orxonox::Degree>()      { return this->setValue<orxonox::Degree>     (this->operator orxonox::Degree());      } /** @brief Converts the current value to the given type. */ | 
|---|
| 499 |  | 
|---|
| 500 | // Specialization to avoid ambiguities with the conversion operator | 
|---|
| 501 | template <> inline bool MultiType::convert<const std::string&>()          { return this->convert<std::string>();          } /** @brief Converts the current value to the given type. */ | 
|---|
| 502 | template <> inline bool MultiType::convert<const orxonox::Vector2&>()     { return this->convert<orxonox::Vector2>();     } /** @brief Converts the current value to the given type. */ | 
|---|
| 503 | template <> inline bool MultiType::convert<const orxonox::Vector3&>()     { return this->convert<orxonox::Vector3>();     } /** @brief Converts the current value to the given type. */ | 
|---|
| 504 | template <> inline bool MultiType::convert<const orxonox::Vector4&>()     { return this->convert<orxonox::Vector4>();     } /** @brief Converts the current value to the given type. */ | 
|---|
| 505 | template <> inline bool MultiType::convert<const orxonox::ColourValue&>() { return this->convert<orxonox::ColourValue>(); } /** @brief Converts the current value to the given type. */ | 
|---|
| 506 | template <> inline bool MultiType::convert<const orxonox::Quaternion&>()  { return this->convert<orxonox::Quaternion>();  } /** @brief Converts the current value to the given type. */ | 
|---|
| 507 | template <> inline bool MultiType::convert<const orxonox::Radian&>()      { return this->convert<orxonox::Radian>();      } /** @brief Converts the current value to the given type. */ | 
|---|
| 508 | template <> inline bool MultiType::convert<const orxonox::Degree&>()      { return this->convert<orxonox::Degree>();      } /** @brief Converts the current value to the given type. */ | 
|---|
| 509 |  | 
|---|
| 510 | template <> void MultiType::createNewValueContainer(const char& value); | 
|---|
| 511 | template <> void MultiType::createNewValueContainer(const unsigned char& value); | 
|---|
| 512 | template <> void MultiType::createNewValueContainer(const short& value); | 
|---|
| 513 | template <> void MultiType::createNewValueContainer(const unsigned short& value); | 
|---|
| 514 | template <> void MultiType::createNewValueContainer(const int& value); | 
|---|
| 515 | template <> void MultiType::createNewValueContainer(const unsigned int& value); | 
|---|
| 516 | template <> void MultiType::createNewValueContainer(const long& value); | 
|---|
| 517 | template <> void MultiType::createNewValueContainer(const unsigned long& value); | 
|---|
| 518 | template <> void MultiType::createNewValueContainer(const long long& value); | 
|---|
| 519 | template <> void MultiType::createNewValueContainer(const unsigned long long& value); | 
|---|
| 520 | template <> void MultiType::createNewValueContainer(const float& value); | 
|---|
| 521 | template <> void MultiType::createNewValueContainer(const double& value); | 
|---|
| 522 | template <> void MultiType::createNewValueContainer(const bool& value); | 
|---|
| 523 | template <> void MultiType::createNewValueContainer(const long double& value); | 
|---|
| 524 | template <> void MultiType::createNewValueContainer(      void* const& value); | 
|---|
| 525 | template <> void MultiType::createNewValueContainer(const std::string& value); | 
|---|
| 526 | template <> void MultiType::createNewValueContainer(const orxonox::Vector2& value); | 
|---|
| 527 | template <> void MultiType::createNewValueContainer(const orxonox::Vector3& value); | 
|---|
| 528 | template <> void MultiType::createNewValueContainer(const orxonox::Vector4& value); | 
|---|
| 529 | template <> void MultiType::createNewValueContainer(const orxonox::ColourValue& value); | 
|---|
| 530 | template <> void MultiType::createNewValueContainer(const orxonox::Quaternion& value); | 
|---|
| 531 | template <> void MultiType::createNewValueContainer(const orxonox::Radian& value); | 
|---|
| 532 | template <> void MultiType::createNewValueContainer(const orxonox::Degree& value); | 
|---|
| 533 |  | 
|---|
| 534 | inline bool MultiType::setValue(const char& value)                  { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ | 
|---|
| 535 | inline bool MultiType::setValue(const unsigned char& value)         { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ | 
|---|
| 536 | inline bool MultiType::setValue(const short& value)                 { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ | 
|---|
| 537 | inline bool MultiType::setValue(const unsigned short& value)        { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ | 
|---|
| 538 | inline bool MultiType::setValue(const int& value)                   { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ | 
|---|
| 539 | inline bool MultiType::setValue(const unsigned int& value)          { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ | 
|---|
| 540 | inline bool MultiType::setValue(const long& value)                  { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ | 
|---|
| 541 | inline bool MultiType::setValue(const unsigned long& value)         { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ | 
|---|
| 542 | inline bool MultiType::setValue(const long long& value)             { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ | 
|---|
| 543 | inline bool MultiType::setValue(const unsigned long long& value)    { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ | 
|---|
| 544 | inline bool MultiType::setValue(const float& value)                 { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ | 
|---|
| 545 | inline bool MultiType::setValue(const double& value)                { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ | 
|---|
| 546 | inline bool MultiType::setValue(const long double& value)           { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ | 
|---|
| 547 | inline bool MultiType::setValue(const bool& value)                  { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ | 
|---|
| 548 | inline bool MultiType::setValue(      void* const& value)           { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ | 
|---|
| 549 | inline bool MultiType::setValue(const std::string& value)           { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ | 
|---|
| 550 | inline bool MultiType::setValue(const orxonox::Vector2& value)      { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ | 
|---|
| 551 | inline bool MultiType::setValue(const orxonox::Vector3& value)      { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ | 
|---|
| 552 | inline bool MultiType::setValue(const orxonox::Vector4& value)      { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ | 
|---|
| 553 | inline bool MultiType::setValue(const orxonox::ColourValue& value)  { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ | 
|---|
| 554 | inline bool MultiType::setValue(const orxonox::Quaternion& value)   { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ | 
|---|
| 555 | inline bool MultiType::setValue(const orxonox::Radian& value)       { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ | 
|---|
| 556 | inline bool MultiType::setValue(const orxonox::Degree& value)       { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ | 
|---|
| 557 |  | 
|---|
| 558 | inline bool MultiType::setValue(const char* value)                  { if (this->value_) { return this->value_->setValue(std::string(value)); } else { return this->assignValue(std::string(value)); } }  /** @brief Assigns the given value and converts it to the current type. */ | 
|---|
| 559 | } | 
|---|
| 560 |  | 
|---|
| 561 | #endif /* _MultiType_H__ */ | 
|---|