Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 12, 2013, 11:13:03 PM (11 years ago)
Author:
landauf
Message:

merged testing branch back to trunk. unbelievable it took me 13 months to finish this chore…

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/libraries/util/MultiType.h

    r8858 r9550  
    5151     - @ref orxonox::MultiType::MultiType "The constructor"
    5252     - The assignment operator= (orxonox::MultiType::operator=())
    53      - @ref orxonox::MultiType::setValue() "setValue(value)"
     53     - @ref orxonox::MultiType::set() "set(value)"
    5454
    5555    If you assign another value of another type, the MultiType keeps "its" type and
     
    5858    If you want to change the type, there are three possibilities:
    5959     - @ref orxonox::MultiType::convert "convert<T>()" sets the type to T and converts the currently assigned value
    60      - @ref orxonox::MultiType::setType "setType<T>()" sets the type to T and resets the value to zero using zeroise<T>()
    61      - setValue<T>(value) assigns a new value and changes the type to T.
     60     - @ref orxonox::MultiType::reset "reset<T>()" sets the type to T and resets the value to zero using zeroise<T>()
     61     - force<T>(value) assigns a new value and changes the type to T.
    6262
    6363    Examples:
    6464    @code
    65     MultiType a = 10;          // a has now the type int and the value 10
    66     a.setValue("3.14");        // a has still the type int and "3.14" gets converted, therefore the value is now 3
    67     a.setValue<float>("3.14"); // a has now the type float and "3.14" gets converted to 3.14f
    68     a.convert<bool>();         // converts 3.14f to bool, which is true
    69     a = false;                 // assigns false, this is equivalent to a.setValue(false)
     65    MultiType a = 10;       // a has now the type int and the value 10
     66    a.set("3.14");          // a has still the type int and "3.14" gets converted, therefore the value is now 3
     67    a.force<float>("3.14"); // a has now the type float and "3.14" gets converted to 3.14f
     68    a.convert<bool>();      // converts 3.14f to bool, which is true
     69    a = false;              // assigns false, this is equivalent to a.setValue(false)
    7070    @endcode
    7171
     
    106106#include <OgreColourValue.h>
    107107#include <loki/TypeTraits.h>
     108#include "Math.h"
    108109#include "mbool.h"
    109110
    110111namespace orxonox
    111112{
    112     /**
    113         @brief Enum of all possible types of a MultiType.
    114     */
    115     namespace MT_Type
    116     {
    117         enum Value
    118         {
    119             Null,
    120             Char,
    121             UnsignedChar,
    122             Short,
    123             UnsignedShort,
    124             Int,
    125             UnsignedInt,
    126             Long,
    127             UnsignedLong,
    128             LongLong,
    129             UnsignedLongLong,
    130             Float,
    131             Double,
    132             LongDouble,
    133             Bool,
    134             VoidPointer,
    135             String,
    136             Vector2,
    137             Vector3,
    138             Vector4,
    139             ColourValue,
    140             Quaternion,
    141             Radian,
    142             Degree
    143         };
    144     }
    145 
    146113    /**
    147114        @brief The MultiType can hold a value of many possible types and convert them to other types.
     
    165132        template <typename T> friend class MT_Value;
    166133
     134        struct Type
     135        {
     136            /**
     137                @brief Enum of all possible types of a MultiType.
     138            */
     139            enum Enum
     140            {
     141                Null,
     142                Char,
     143                UnsignedChar,
     144                Short,
     145                UnsignedShort,
     146                Int,
     147                UnsignedInt,
     148                Long,
     149                UnsignedLong,
     150                LongLong,
     151                UnsignedLongLong,
     152                Float,
     153                Double,
     154                LongDouble,
     155                Bool,
     156                VoidPointer,
     157                String,
     158                Vector2,
     159                Vector3,
     160                Vector4,
     161                ColourValue,
     162                Quaternion,
     163                Radian,
     164                Degree
     165            };
     166        };
     167
    167168    public:
    168169        /**
     
    173174        {
    174175        public:
    175             MT_ValueBase(MT_Type::Value type) : type_(type), bHasDefaultValue_(false) {}
    176             virtual ~MT_ValueBase() {}
     176            inline MT_ValueBase(void* data, Type::Enum type) : type_(type), bLastConversionSuccessful(true), data_(data) {}
     177            inline virtual ~MT_ValueBase() {}
    177178
    178179            virtual MT_ValueBase* clone() const = 0;
    179180
    180181            virtual void reset() = 0;
    181             virtual bool assimilate(const MultiType& other) = 0;
    182182
    183183            /// Returns the type of the current value.
    184             const MT_Type::Value& getType() const { return this->type_; }
     184            inline const Type::Enum& getType() const { return this->type_; }
     185            /// Returns true if the type of the stored value is T.
     186            template <typename T> inline bool isType() const { return false; }
    185187
    186188            /// Checks whether the value is a default one.
    187             bool hasDefaultValue()   const { return this->bHasDefaultValue_; }
     189            inline bool lastConversionSuccessful()   const { return this->bLastConversionSuccessful; }
    188190
    189191            virtual bool setValue(const char& value)                 = 0;
     
    211213            virtual bool setValue(const orxonox::Degree& value)      = 0;
    212214
     215            virtual bool setValue(const MultiType& other)            = 0;
     216
    213217            virtual bool getValue(char*                 value) const = 0;
    214218            virtual bool getValue(unsigned char*        value) const = 0;
     
    235239            virtual bool getValue(orxonox::Degree*      value) const = 0;
    236240
    237             virtual operator char()                 const = 0;
    238             virtual operator unsigned char()        const = 0;
    239             virtual operator short()                const = 0;
    240             virtual operator unsigned short()       const = 0;
    241             virtual operator int()                  const = 0;
    242             virtual operator unsigned int()         const = 0;
    243             virtual operator long()                 const = 0;
    244             virtual operator unsigned long()        const = 0;
    245             virtual operator long long()            const = 0;
    246             virtual operator unsigned long long()   const = 0;
    247             virtual operator float()                const = 0;
    248             virtual operator double()               const = 0;
    249             virtual operator long double()          const = 0;
    250             virtual operator bool()                 const = 0;
    251             virtual operator void*()                const = 0;
    252             virtual operator std::string()          const = 0;
    253             virtual operator orxonox::Vector2()     const = 0;
    254             virtual operator orxonox::Vector3()     const = 0;
    255             virtual operator orxonox::Vector4()     const = 0;
    256             virtual operator orxonox::ColourValue() const = 0;
    257             virtual operator orxonox::Quaternion()  const = 0;
    258             virtual operator orxonox::Radian()      const = 0;
    259             virtual operator orxonox::Degree()      const = 0;
     241            template <typename T> T get() const
     242            {
     243                if (this->isType<T>())
     244                    return *reinterpret_cast<const T*>(this->data_);
     245                else
     246                {
     247                    T value;
     248                    this->getValue(&value);
     249                    return value;
     250                }
     251            }
    260252
    261253            virtual void toString(std::ostream& outstream) const = 0;
    262254
    263             virtual void importData( uint8_t*& mem )=0;
    264             virtual void exportData( uint8_t*& mem ) const=0;
    265             virtual uint8_t getSize() const=0;
    266 
    267             MT_Type::Value type_;   ///< The type of the current value
    268             bool bHasDefaultValue_; ///< True if the last conversion wasn't successful
     255            virtual void importData(uint8_t*& mem) = 0;
     256            virtual void exportData(uint8_t*& mem) const = 0;
     257            virtual uint8_t getSize() const = 0;
     258
     259            Type::Enum type_;               ///< The type of the current value
     260            bool bLastConversionSuccessful; ///< True if the last conversion was successful
     261            void* data_;                    ///< For direct access to the value if the type is known
    269262        };
    270263
    271264        public:
    272             inline MultiType()                                  : value_(0) {}                                      ///< Default constructor: Assigns no value and no type. The type will be determined by the first assignment of a value.
    273             inline MultiType(const char& value)                 : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    274             inline MultiType(const unsigned char& value)        : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    275             inline MultiType(const short& value)                : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    276             inline MultiType(const unsigned short& value)       : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    277             inline MultiType(const int& value)                  : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    278             inline MultiType(const unsigned int& value)         : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    279             inline MultiType(const long& value)                 : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    280             inline MultiType(const unsigned long& value)        : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    281             inline MultiType(const long long& value)            : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    282             inline MultiType(const unsigned long long& value)   : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    283             inline MultiType(const float& value)                : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    284             inline MultiType(const double& value)               : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    285             inline MultiType(const long double& value)          : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    286             inline MultiType(const bool& value)                 : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    287             inline MultiType(      void* const& value)          : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    288             inline MultiType(const std::string& value)          : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    289             inline MultiType(const orxonox::Vector2& value)     : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    290             inline MultiType(const orxonox::Vector3& value)     : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    291             inline MultiType(const orxonox::Vector4& value)     : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    292             inline MultiType(const orxonox::ColourValue& value) : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    293             inline MultiType(const orxonox::Quaternion& value)  : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    294             inline MultiType(const orxonox::Radian& value)      : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    295             inline MultiType(const orxonox::Degree& value)      : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    296             inline MultiType(const orxonox::mbool& value)       : value_(0) { this->assignValue((bool)value); }     ///< Constructor: Assigns the given mbool and converts it to bool.
    297             inline MultiType(const char* value)                 : value_(0) { this->setValue(std::string(value)); } ///< Constructor: Converts the char array to a std::string, assigns the value and sets the type.
    298             inline MultiType(const MultiType& other)            : value_(0) { this->setValue(other); }              ///< Copyconstructor: Assigns value and type of the other MultiType.
    299             inline MultiType(MT_Type::Value type)               : value_(0) { this->setType(type); }                ///< Constructor: Sets the type, the next assignment will determine the value.
     265            static const MultiType Null;
     266
     267            /// Default constructor: Assigns no value and no type. The type will be determined by the first assignment of a value.
     268            inline MultiType()                       : value_(0) { }
     269            /// Constructor: Assigns the given value and sets the type.
     270            template <typename V>
     271            inline MultiType(const V& value)         : value_(0) { this->set(value); }
     272            /// Copyconstructor: Assigns value and type of the other MultiType.
     273            inline MultiType(const MultiType& other) : value_(0) { this->set(other); }
    300274
    301275            /// Destructor: Deletes the MT_Value.
    302276            inline ~MultiType() { if (this->value_) { delete this->value_; } }
    303277
    304             template <typename V> inline MultiType& operator=(const V& value)         { this->setValue(value); return (*this); } ///< Assigns a new value. The value will be converted to the current type of the MultiType.
    305             template <typename V> inline MultiType& operator=(V* value)               { this->setValue(value); return (*this); } ///< Assigns a pointer.
    306             inline                       MultiType& operator=(const MultiType& other) { this->setValue(other); return (*this); } ///< Assigns the value of the other MultiType and converts it to the current type of the MultiType.
    307             inline                       MultiType& operator=(MT_Type::Value type)    { this->setType(type);   return (*this); } ///< Resets the value and changes the type.
    308 
    309             inline bool                                   setValue(const char& value);
    310             inline bool                                   setValue(const unsigned char& value);
    311             inline bool                                   setValue(const short& value);
    312             inline bool                                   setValue(const unsigned short& value);
    313             inline bool                                   setValue(const int& value);
    314             inline bool                                   setValue(const unsigned int& value);
    315             inline bool                                   setValue(const long& value);
    316             inline bool                                   setValue(const unsigned long& value);
    317             inline bool                                   setValue(const long long& value);
    318             inline bool                                   setValue(const unsigned long long& value);
    319             inline bool                                   setValue(const float& value);
    320             inline bool                                   setValue(const double& value);
    321             inline bool                                   setValue(const long double& value);
    322             inline bool                                   setValue(const bool& value);
    323             inline bool                                   setValue(      void* const& value);
    324             inline bool                                   setValue(const std::string& value);
    325             inline bool                                   setValue(const orxonox::Vector2& value);
    326             inline bool                                   setValue(const orxonox::Vector3& value);
    327             inline bool                                   setValue(const orxonox::Vector4& value);
    328             inline bool                                   setValue(const orxonox::ColourValue& value);
    329             inline bool                                   setValue(const orxonox::Quaternion& value);
    330             inline bool                                   setValue(const orxonox::Radian& value);
    331             inline bool                                   setValue(const orxonox::Degree& value);
    332             inline bool                                   setValue(const char* value);
     278            /// Assigns a new value. The value will be converted to the current type of the MultiType.
     279            template <typename V> inline MultiType& operator=(const V& value)         { this->set(value); return (*this); }
    333280            /// Assigns a pointer.
    334             template <typename V> inline bool setValue(V* value)
     281            template <typename V> inline MultiType& operator=(V* value)               { this->set(value); return (*this); }
     282            /// Assigns the value of the other MultiType and converts it to the current type of the MultiType.
     283            inline                       MultiType& operator=(const MultiType& other) { this->set(other); return (*this); }
     284
     285            /// Assigns the given value and converts it to the current type.
     286            template <typename V> inline bool set(const V& value)
     287            {
     288                if (this->value_)
     289                    return this->value_->setValue(value);
     290
     291                this->assignValue(value);
     292                return true;
     293            }
     294            /// Assigns a pointer.
     295            template <typename V> inline bool set(V* value)
    335296            {
    336297                if (this->value_)
    337298                    return this->value_->setValue(static_cast<void*>(const_cast<typename Loki::TypeTraits<V>::UnqualifiedType*>(value)));
    338                 else
    339                     return this->assignValue     (static_cast<void*>(const_cast<typename Loki::TypeTraits<V>::UnqualifiedType*>(value)));
     299
     300                this->assignValue(static_cast<void*>(const_cast<typename Loki::TypeTraits<V>::UnqualifiedType*>(value)));
     301                return true;
    340302            }
    341303            /// Assigns the value of the other MultiType and converts it to the current type.
    342             bool                                          setValue(const MultiType& other) { if (this->value_) { return this->value_->assimilate(other); } else { if (other.value_) { this->value_ = other.value_->clone(); } return true; } }
     304            inline bool set(const MultiType& other)
     305            {
     306                if (this->value_)
     307                    return this->value_->setValue(other);
     308                else if (other.value_)
     309                    this->value_ = other.value_->clone();
     310                return true;
     311            }
     312
    343313            /// Changes the type to T and assigns the new value (which might be of another type than T - it gets converted).
    344             template <typename T, typename V> inline bool setValue(const V& value) { this->setType<T>(); return this->setValue(value); }
    345 
     314            template <typename T, typename V> inline bool force(const V& value)
     315            {
     316                this->reset<T>();
     317                return this->set(value);
     318            }
    346319
    347320            /// Copies the other MultiType by assigning value and type.
    348             inline void                       copy(const MultiType& other)    { if (this == &other) { return; } if (this->value_) { delete this->value_; } this->value_ = (other.value_) ? other.value_->clone() : 0; }
     321            inline void copy(const MultiType& other)
     322            {
     323                if (this == &other)
     324                    return;
     325                if (this->value_)
     326                    delete this->value_;
     327                this->value_ = (other.value_) ? other.value_->clone() : 0;
     328            }
    349329
    350330            /// Converts the current value to type T.
    351             template <typename T> inline bool convert()                       { return this->setValue<T>((typename Loki::TypeTraits<T>::UnqualifiedReferredType)(*this));  }
    352             /// Converts the current value to the type of the other MultiType.
    353             inline bool                       convert(const MultiType& other) { return this->convert(other.getType()); }
    354             bool                              convert(MT_Type::Value type);
    355 
    356             /// Current content gets deleted. New type is MT_Type::Null
    357             inline void                       reset()                         { if (this->value_) delete this->value_; this->value_ = 0; }
    358             /// Current content gets overridden with default zero value
    359             inline void                       resetValue()                    { if (this->value_) this->value_->reset(); }
    360 
     331            template <typename T> inline bool convert() { return this->force<T>(MultiType(*this)); }
     332
     333            /// Resets value and type. Type will be void afterwards and null() returns true.
     334            inline void reset() { if (this->value_) delete this->value_; this->value_ = 0; }
    361335            /// Resets the value and changes the internal type to T.
    362             template <typename T> inline void setType()                       { this->assignValue(typename Loki::TypeTraits<T>::UnqualifiedReferredType()); }
    363             /// Resets the value and changes the internal type to the type of the other MultiType.
    364             inline void                       setType(const MultiType& other) { this->setType(other.getType());                                             }
    365             /// Resets the value and changes the internal type to the given type.
    366             inline void                       setType(MT_Type::Value type)    { this->reset(); this->convert(type); this->resetValue();                     }
    367 
    368             /// Returns the current type.
    369             inline MT_Type::Value             getType()                   const { return (this->value_) ? this->value_->type_ : MT_Type::Null; }
    370             /// Returns true if the current type equals the given type.
    371             inline bool                       isType(MT_Type::Value type) const { return (this->value_) ? (this->value_->type_ == type) : (type == MT_Type::Null); }
    372             /// Returns true if the current type is T.
    373             template <typename T> inline bool isType()                    const { return false; } // Only works for specialized values - see below
    374             std::string                       getTypename()               const;
    375 
    376             /// Saves the value of the MT to a bytestream (pointed at by mem) and increases mem pointer by size of MT
    377             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); }
    378             /// Loads the value of the MT from a bytestream (pointed at by mem) and increases mem pointer by size of MT
    379             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); }
    380             /// Saves the value of the MT to a bytestream and increases pointer to bytestream by size of MT
    381             inline uint8_t*&                  operator << (uint8_t*& mem) { importData(mem); return mem; }
    382             /// Loads the value of the MT to a bytestream and increases pointer to bytestream by size of MT
    383             inline void                       operator >> (uint8_t*& mem) const { exportData(mem); }
    384             inline uint32_t                   getNetworkSize() const { assert(this->value_); return this->value_->getSize() + sizeof(uint8_t); }
    385 
    386             /// Checks whether the value is a default one (assigned after a failed conversion)
    387             bool                              hasDefaultValue() const { return this->value_->hasDefaultValue(); }
     336            template <typename T> inline void reset() { this->assignValue(typename Loki::TypeTraits<T>::UnqualifiedReferredType()); }
     337            /// Current value gets overridden with default zero value
     338            inline void resetValue() { if (this->value_) this->value_->reset(); }
     339
     340            /// Returns true if the type of the current value is T.
     341            template <typename T> inline bool isType() const { return (this->value_ ? this->value_->isType<T>() : false); }
     342            std::string getTypename() const;
     343
     344            /// Checks whether the last conversion was successful
     345            inline bool lastConversionSuccessful() const { return !this->value_ || this->value_->lastConversionSuccessful(); }
    388346
    389347            /// Checks if the MT contains no value.
    390             bool                              null() const { return (!this->value_); }
    391 
    392             operator char()                  const;
    393             operator unsigned char()         const;
    394             operator short()                 const;
    395             operator unsigned short()        const;
    396             operator int()                   const;
    397             operator unsigned int()          const;
    398             operator long()                  const;
    399             operator unsigned long()         const;
    400             operator long long()             const;
    401             operator unsigned long long()    const;
    402             operator float()                 const;
    403             operator double()                const;
    404             operator long double()           const;
    405             operator bool()                  const;
    406             operator void*()                 const;
    407             operator std::string()           const;
    408             operator orxonox::Vector2()      const;
    409             operator orxonox::Vector3()      const;
    410             operator orxonox::Vector4()      const;
    411             operator orxonox::ColourValue()  const;
    412             operator orxonox::Quaternion()   const;
    413             operator orxonox::Radian()       const;
    414             operator orxonox::Degree()       const;
     348            inline bool null() const { return !this->value_; }
     349
     350            inline operator char()                 const { return (this->value_ ? this->value_->get<char>()                 : 0); }
     351            inline operator unsigned char()        const { return (this->value_ ? this->value_->get<unsigned char>()        : 0); }
     352            inline operator short()                const { return (this->value_ ? this->value_->get<short>()                : 0); }
     353            inline operator unsigned short()       const { return (this->value_ ? this->value_->get<unsigned short>()       : 0); }
     354            inline operator int()                  const { return (this->value_ ? this->value_->get<int>()                  : 0); }
     355            inline operator unsigned int()         const { return (this->value_ ? this->value_->get<unsigned int>()         : 0); }
     356            inline operator long()                 const { return (this->value_ ? this->value_->get<long>()                 : 0); }
     357            inline operator unsigned long()        const { return (this->value_ ? this->value_->get<unsigned long>()        : 0); }
     358            inline operator long long()            const { return (this->value_ ? this->value_->get<long long>()            : 0); }
     359            inline operator unsigned long long()   const { return (this->value_ ? this->value_->get<unsigned long long>()   : 0); }
     360            inline operator float()                const { return (this->value_ ? this->value_->get<float>()                : 0); }
     361            inline operator double()               const { return (this->value_ ? this->value_->get<double>()               : 0); }
     362            inline operator long double()          const { return (this->value_ ? this->value_->get<long double>()          : 0); }
     363            inline operator bool()                 const { return (this->value_ ? this->value_->get<bool>()                 : 0); }
     364            inline operator void*()                const { return (this->value_ ? this->value_->get<void*>()                : 0); }
     365            inline operator std::string()          const { return (this->value_ ? this->value_->get<std::string>()          : NilValue<std::string>()); }
     366            inline operator orxonox::Vector2()     const { return (this->value_ ? this->value_->get<orxonox::Vector2>()     : NilValue<orxonox::Vector2>()); }
     367            inline operator orxonox::Vector3()     const { return (this->value_ ? this->value_->get<orxonox::Vector3>()     : NilValue<orxonox::Vector3>()); }
     368            inline operator orxonox::Vector4()     const { return (this->value_ ? this->value_->get<orxonox::Vector4>()     : NilValue<orxonox::Vector4>()); }
     369            inline operator orxonox::ColourValue() const { return (this->value_ ? this->value_->get<orxonox::ColourValue>() : NilValue<orxonox::ColourValue>()); }
     370            inline operator orxonox::Quaternion()  const { return (this->value_ ? this->value_->get<orxonox::Quaternion>()  : NilValue<orxonox::Quaternion>()); }
     371            inline operator orxonox::Radian()      const { return (this->value_ ? this->value_->get<orxonox::Radian>()      : NilValue<orxonox::Radian>()); }
     372            inline operator orxonox::Degree()      const { return (this->value_ ? this->value_->get<orxonox::Degree>()      : NilValue<orxonox::Degree>()); }
    415373            /// Returns the current value, converted to a T* pointer.
    416374            template <class T> operator T*() const { return (static_cast<T*>(this->operator void*())); }
    417375
    418             inline bool getValue(char*                 value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    419             inline bool getValue(unsigned char*        value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    420             inline bool getValue(short*                value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    421             inline bool getValue(unsigned short*       value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    422             inline bool getValue(int*                  value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    423             inline bool getValue(unsigned int*         value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    424             inline bool getValue(long*                 value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    425             inline bool getValue(unsigned long*        value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    426             inline bool getValue(long long*            value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    427             inline bool getValue(unsigned long long*   value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    428             inline bool getValue(float*                value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    429             inline bool getValue(double*               value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    430             inline bool getValue(long double*          value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    431             inline bool getValue(bool*                 value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    432             inline bool getValue(void**                value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    433             inline bool getValue(std::string*          value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    434             inline bool getValue(orxonox::Vector2*     value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    435             inline bool getValue(orxonox::Vector3*     value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    436             inline bool getValue(orxonox::Vector4*     value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    437             inline bool getValue(orxonox::ColourValue* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    438             inline bool getValue(orxonox::Quaternion*  value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    439             inline bool getValue(orxonox::Radian*      value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    440             inline bool getValue(orxonox::Degree*      value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    441 
    442             inline char                     getChar()             const { return this->operator char();                 } ///< Returns the current value, converted to the requested type.
    443             inline unsigned char            getUnsignedChar()     const { return this->operator unsigned char();        } ///< Returns the current value, converted to the requested type.
    444             inline short                    getShort()            const { return this->operator short();                } ///< Returns the current value, converted to the requested type.
    445             inline unsigned short           getUnsignedShort()    const { return this->operator unsigned short();       } ///< Returns the current value, converted to the requested type.
    446             inline int                      getInt()              const { return this->operator int();                  } ///< Returns the current value, converted to the requested type.
    447             inline unsigned int             getUnsignedInt()      const { return this->operator unsigned int();         } ///< Returns the current value, converted to the requested type.
    448             inline long                     getLong()             const { return this->operator long();                 } ///< Returns the current value, converted to the requested type.
    449             inline unsigned long            getUnsignedLong()     const { return this->operator unsigned long();        } ///< Returns the current value, converted to the requested type.
    450             inline long long                getLongLong()         const { return this->operator long long();            } ///< Returns the current value, converted to the requested type.
    451             inline unsigned long long       getUnsignedLongLong() const { return this->operator unsigned long long();   } ///< Returns the current value, converted to the requested type.
    452             inline float                    getFloat()            const { return this->operator float();                } ///< Returns the current value, converted to the requested type.
    453             inline double                   getDouble()           const { return this->operator double();               } ///< Returns the current value, converted to the requested type.
    454             inline long double              getLongDouble()       const { return this->operator long double();          } ///< Returns the current value, converted to the requested type.
    455             inline bool                     getBool()             const { return this->operator bool();                 } ///< Returns the current value, converted to the requested type.
    456             inline void*                    getVoid()             const { return this->operator void*();                } ///< Returns the current value, converted to the requested type.
    457             inline std::string              getString()           const { return this->operator std::string();          } ///< Returns the current value, converted to the requested type.
    458             inline orxonox::Vector2         getVector2()          const { return this->operator orxonox::Vector2();     } ///< Returns the current value, converted to the requested type.
    459             inline orxonox::Vector3         getVector3()          const { return this->operator orxonox::Vector3();     } ///< Returns the current value, converted to the requested type.
    460             inline orxonox::Vector4         getVector4()          const { return this->operator orxonox::Vector4();     } ///< Returns the current value, converted to the requested type.
    461             inline orxonox::ColourValue     getColourValue()      const { return this->operator orxonox::ColourValue(); } ///< Returns the current value, converted to the requested type.
    462             inline orxonox::Quaternion      getQuaternion()       const { return this->operator orxonox::Quaternion();  } ///< Returns the current value, converted to the requested type.
    463             inline orxonox::Radian          getRadian()           const { return this->operator orxonox::Radian();      } ///< Returns the current value, converted to the requested type.
    464             inline orxonox::Degree          getDegree()           const { return this->operator orxonox::Degree();      } ///< Returns the current value, converted to the requested type.
    465             template <typename T> inline T* getPointer()          const { return static_cast<T*>(this->getVoid());      } ///< Returns the current value, converted to a T* pointer.
     376            /// Assigns the value to the given pointer. The value gets converted if the types don't match.
     377            template <typename T> inline bool getValue(T* value) const { if (this->value_) { return this->value_->getValue(value); } return false; }
     378
     379            /// Returns the current value, converted to the requested type.
     380            template <typename T> inline T get() const { return *this; }
     381
     382
     383            ///////////////////////////////
     384            // network-related functions //
     385            ///////////////////////////////
     386            /// Saves the value of the MT to a bytestream (pointed at by mem) and increases mem pointer by size of MT
     387            inline void exportData(uint8_t*& mem) const
     388            {
     389                assert(sizeof(Type::Enum) <= 8);
     390                *static_cast<uint8_t*>(mem) = this->getType();
     391                mem += sizeof(uint8_t);
     392                this->value_->exportData(mem);
     393            }
     394            /// Loads the value of the MT from a bytestream (pointed at by mem) and increases mem pointer by size of MT
     395            inline void importData(uint8_t*& mem)
     396            {
     397                assert(sizeof(Type::Enum) <= 8);
     398                this->setType(static_cast<Type::Enum>(*static_cast<uint8_t*>(mem)));
     399                mem += sizeof(uint8_t);
     400                this->value_->importData(mem);
     401            }
     402            /// Saves the value of the MT to a bytestream and increases pointer to bytestream by size of MT
     403            inline uint8_t*& operator<<(uint8_t*& mem)
     404            {
     405                importData(mem);
     406                return mem;
     407            }
     408            /// Loads the value of the MT to a bytestream and increases pointer to bytestream by size of MT
     409            inline void operator>>(uint8_t*& mem) const
     410            {
     411                exportData(mem);
     412            }
     413            inline uint32_t getNetworkSize() const
     414            {
     415                assert(this->value_);
     416                return this->value_->getSize() + sizeof(uint8_t);
     417            }
    466418
    467419        private:
    468             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; } } ///< Assigns a new value by changing type and creating a new container.
    469             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; } } ///< Assigns a new value by changing type and creating a new container.
    470             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; } } ///< Assigns a new value by changing type and creating a new container.
    471             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; } } ///< Assigns a new value by changing type and creating a new container.
    472             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; } } ///< Assigns a new value by changing type and creating a new container.
    473             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; } } ///< Assigns a new value by changing type and creating a new container.
    474             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; } } ///< Assigns a new value by changing type and creating a new container.
    475             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; } } ///< Assigns a new value by changing type and creating a new container.
    476             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; } } ///< Assigns a new value by changing type and creating a new container.
    477             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; } } ///< Assigns a new value by changing type and creating a new container.
    478             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; } } ///< Assigns a new value by changing type and creating a new container.
    479             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; } } ///< Assigns a new value by changing type and creating a new container.
    480             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; } } ///< Assigns a new value by changing type and creating a new container.
    481             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; } } ///< Assigns a new value by changing type and creating a new container.
    482             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; } } ///< Assigns a new value by changing type and creating a new container.
    483             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; } } ///< Assigns a new value by changing type and creating a new container.
    484             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; } } ///< Assigns a new value by changing type and creating a new container.
    485             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; } } ///< Assigns a new value by changing type and creating a new container.
    486             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; } } ///< Assigns a new value by changing type and creating a new container.
    487             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; } } ///< Assigns a new value by changing type and creating a new container.
    488             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; } } ///< Assigns a new value by changing type and creating a new container.
    489             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; } } ///< Assigns a new value by changing type and creating a new container.
    490             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; } } ///< Assigns a new value by changing type and creating a new container.
     420            /// Assigns a new value by changing type and creating a new container.
     421            template <typename T> inline void assignValue(const T& value)
     422            {
     423                if (this->isType<T>())
     424                    this->value_->setValue(value);
     425                else
     426                    this->changeValueContainer(value);
     427            }
     428            /// Assigns a new value by changing type and creating a new container (overload for pointers).
     429            template <typename T> inline void assignValue(T* const& value)
     430            {
     431                if (this->isType<void*>())
     432                    this->value_->setValue(static_cast<void*>(value));
     433                else
     434                    this->changeValueContainer<void*>(value);
     435            }
     436
     437            /// Resets the value and changes the internal type to the given type.
     438            inline void setType(Type::Enum type) { this->reset(); this->convert(type); this->resetValue(); }
     439            /// Returns the current type.
     440            inline Type::Enum getType() const { return (this->value_) ? this->value_->type_ : Type::Null; }
     441            /// Converts the current value to the given type.
     442            bool convert(Type::Enum type);
    491443
    492444            /// Changes the value container.
    493             template <typename T> inline void changeValueContainer(const T& value) { if (this->value_) { delete this->value_; } this->createNewValueContainer<T>(value); }
     445            template <typename T> inline void changeValueContainer(const T& value)
     446            {
     447                if (this->value_)
     448                    delete this->value_;
     449                this->createNewValueContainer(value);
     450            }
    494451            /// Creates a new value container (works only with specialized types).
    495             template <typename T>       void createNewValueContainer(const T& value) { /* STATIC ASSERT */ *****value; return false; }
     452            template <typename T> inline void createNewValueContainer(const T& value) { /* STATIC ASSERT */ *****value; return false; }
    496453
    497454            MT_ValueBase* value_; //!< A pointer to the value container
     
    499456
    500457    /// Puts the MultiType on a stream by using the native << operator of the current type.
    501     _UtilExport inline std::ostream& operator<<(std::ostream& outstream, const MultiType& mt) { if (mt.value_) { mt.value_->toString(outstream); } return outstream; }
    502 
    503     template <> inline bool MultiType::isType<char>()                 const { return (this->value_ && this->value_->type_ == MT_Type::Char);             } ///< Returns true if the current type equals the given type.
    504     template <> inline bool MultiType::isType<unsigned char>()        const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedChar);     } ///< Returns true if the current type equals the given type.
    505     template <> inline bool MultiType::isType<short>()                const { return (this->value_ && this->value_->type_ == MT_Type::Short);            } ///< Returns true if the current type equals the given type.
    506     template <> inline bool MultiType::isType<unsigned short>()       const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedShort);    } ///< Returns true if the current type equals the given type.
    507     template <> inline bool MultiType::isType<int>()                  const { return (this->value_ && this->value_->type_ == MT_Type::Int);              } ///< Returns true if the current type equals the given type.
    508     template <> inline bool MultiType::isType<unsigned int>()         const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedInt);      } ///< Returns true if the current type equals the given type.
    509     template <> inline bool MultiType::isType<long>()                 const { return (this->value_ && this->value_->type_ == MT_Type::Long);             } ///< Returns true if the current type equals the given type.
    510     template <> inline bool MultiType::isType<unsigned long>()        const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedLong);     } ///< Returns true if the current type equals the given type.
    511     template <> inline bool MultiType::isType<long long>()            const { return (this->value_ && this->value_->type_ == MT_Type::LongLong);         } ///< Returns true if the current type equals the given type.
    512     template <> inline bool MultiType::isType<unsigned long long>()   const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedLongLong); } ///< Returns true if the current type equals the given type.
    513     template <> inline bool MultiType::isType<float>()                const { return (this->value_ && this->value_->type_ == MT_Type::Float);            } ///< Returns true if the current type equals the given type.
    514     template <> inline bool MultiType::isType<double>()               const { return (this->value_ && this->value_->type_ == MT_Type::Double);           } ///< Returns true if the current type equals the given type.
    515     template <> inline bool MultiType::isType<long double>()          const { return (this->value_ && this->value_->type_ == MT_Type::LongDouble);       } ///< Returns true if the current type equals the given type.
    516     template <> inline bool MultiType::isType<bool>()                 const { return (this->value_ && this->value_->type_ == MT_Type::Bool);             } ///< Returns true if the current type equals the given type.
    517     template <> inline bool MultiType::isType<void*>()                const { return (this->value_ && this->value_->type_ == MT_Type::VoidPointer);      } ///< Returns true if the current type equals the given type.
    518     template <> inline bool MultiType::isType<std::string>()          const { return (this->value_ && this->value_->type_ == MT_Type::String);           } ///< Returns true if the current type equals the given type.
    519     template <> inline bool MultiType::isType<orxonox::Vector2>()     const { return (this->value_ && this->value_->type_ == MT_Type::Vector2);          } ///< Returns true if the current type equals the given type.
    520     template <> inline bool MultiType::isType<orxonox::Vector3>()     const { return (this->value_ && this->value_->type_ == MT_Type::Vector3);          } ///< Returns true if the current type equals the given type.
    521     template <> inline bool MultiType::isType<orxonox::Vector4>()     const { return (this->value_ && this->value_->type_ == MT_Type::Vector4);          } ///< Returns true if the current type equals the given type.
    522     template <> inline bool MultiType::isType<orxonox::ColourValue>() const { return (this->value_ && this->value_->type_ == MT_Type::ColourValue);      } ///< Returns true if the current type equals the given type.
    523     template <> inline bool MultiType::isType<orxonox::Quaternion>()  const { return (this->value_ && this->value_->type_ == MT_Type::Quaternion);       } ///< Returns true if the current type equals the given type.
    524     template <> inline bool MultiType::isType<orxonox::Radian>()      const { return (this->value_ && this->value_->type_ == MT_Type::Radian);           } ///< Returns true if the current type equals the given type.
    525     template <> inline bool MultiType::isType<orxonox::Degree>()      const { return (this->value_ && this->value_->type_ == MT_Type::Degree);           } ///< Returns true if the current type equals the given type.
    526 
    527     /// Deletes the content, type becomes MT_Type::Null.
    528     template <> inline bool MultiType::convert<void>()                 { this->reset(); return true; }
    529 
    530     // Specialization to avoid ambiguities with the conversion operator
    531     template <> inline bool MultiType::convert<std::string>()          { return this->setValue<std::string>         (this->operator std::string());          } ///< Converts the current value to the given type.
    532     template <> inline bool MultiType::convert<orxonox::Vector2>()     { return this->setValue<orxonox::Vector2>    (this->operator orxonox::Vector2());     } ///< Converts the current value to the given type.
    533     template <> inline bool MultiType::convert<orxonox::Vector3>()     { return this->setValue<orxonox::Vector3>    (this->operator orxonox::Vector3());     } ///< Converts the current value to the given type.
    534     template <> inline bool MultiType::convert<orxonox::Vector4>()     { return this->setValue<orxonox::Vector4>    (this->operator orxonox::Vector4());     } ///< Converts the current value to the given type.
    535     template <> inline bool MultiType::convert<orxonox::ColourValue>() { return this->setValue<orxonox::ColourValue>(this->operator orxonox::ColourValue()); } ///< Converts the current value to the given type.
    536     template <> inline bool MultiType::convert<orxonox::Quaternion>()  { return this->setValue<orxonox::Quaternion> (this->operator orxonox::Quaternion());  } ///< Converts the current value to the given type.
    537     template <> inline bool MultiType::convert<orxonox::Radian>()      { return this->setValue<orxonox::Radian>     (this->operator orxonox::Radian());      } ///< Converts the current value to the given type.
    538     template <> inline bool MultiType::convert<orxonox::Degree>()      { return this->setValue<orxonox::Degree>     (this->operator orxonox::Degree());      } ///< Converts the current value to the given type.
    539 
    540     // Specialization to avoid ambiguities with the conversion operator
    541     template <> inline bool MultiType::convert<const std::string&>()          { return this->convert<std::string>();          } ///< Converts the current value to the given type.
    542     template <> inline bool MultiType::convert<const orxonox::Vector2&>()     { return this->convert<orxonox::Vector2>();     } ///< Converts the current value to the given type.
    543     template <> inline bool MultiType::convert<const orxonox::Vector3&>()     { return this->convert<orxonox::Vector3>();     } ///< Converts the current value to the given type.
    544     template <> inline bool MultiType::convert<const orxonox::Vector4&>()     { return this->convert<orxonox::Vector4>();     } ///< Converts the current value to the given type.
    545     template <> inline bool MultiType::convert<const orxonox::ColourValue&>() { return this->convert<orxonox::ColourValue>(); } ///< Converts the current value to the given type.
    546     template <> inline bool MultiType::convert<const orxonox::Quaternion&>()  { return this->convert<orxonox::Quaternion>();  } ///< Converts the current value to the given type.
    547     template <> inline bool MultiType::convert<const orxonox::Radian&>()      { return this->convert<orxonox::Radian>();      } ///< Converts the current value to the given type.
    548     template <> inline bool MultiType::convert<const orxonox::Degree&>()      { return this->convert<orxonox::Degree>();      } ///< Converts the current value to the given type.
     458    _UtilExport inline std::ostream& operator<<(std::ostream& outstream, const MultiType& mt)
     459    {
     460        if (mt.value_)
     461            mt.value_->toString(outstream);
     462        return outstream;
     463    }
     464
     465    template <> inline bool MultiType::MT_ValueBase::isType<char>()                 const { return this->type_ == Type::Char;             }
     466    template <> inline bool MultiType::MT_ValueBase::isType<unsigned char>()        const { return this->type_ == Type::UnsignedChar;     }
     467    template <> inline bool MultiType::MT_ValueBase::isType<short>()                const { return this->type_ == Type::Short;            }
     468    template <> inline bool MultiType::MT_ValueBase::isType<unsigned short>()       const { return this->type_ == Type::UnsignedShort;    }
     469    template <> inline bool MultiType::MT_ValueBase::isType<int>()                  const { return this->type_ == Type::Int;              }
     470    template <> inline bool MultiType::MT_ValueBase::isType<unsigned int>()         const { return this->type_ == Type::UnsignedInt;      }
     471    template <> inline bool MultiType::MT_ValueBase::isType<long>()                 const { return this->type_ == Type::Long;             }
     472    template <> inline bool MultiType::MT_ValueBase::isType<unsigned long>()        const { return this->type_ == Type::UnsignedLong;     }
     473    template <> inline bool MultiType::MT_ValueBase::isType<long long>()            const { return this->type_ == Type::LongLong;         }
     474    template <> inline bool MultiType::MT_ValueBase::isType<unsigned long long>()   const { return this->type_ == Type::UnsignedLongLong; }
     475    template <> inline bool MultiType::MT_ValueBase::isType<float>()                const { return this->type_ == Type::Float;            }
     476    template <> inline bool MultiType::MT_ValueBase::isType<double>()               const { return this->type_ == Type::Double;           }
     477    template <> inline bool MultiType::MT_ValueBase::isType<long double>()          const { return this->type_ == Type::LongDouble;       }
     478    template <> inline bool MultiType::MT_ValueBase::isType<bool>()                 const { return this->type_ == Type::Bool;             }
     479    template <> inline bool MultiType::MT_ValueBase::isType<void*>()                const { return this->type_ == Type::VoidPointer;      }
     480    template <> inline bool MultiType::MT_ValueBase::isType<std::string>()          const { return this->type_ == Type::String;           }
     481    template <> inline bool MultiType::MT_ValueBase::isType<orxonox::Vector2>()     const { return this->type_ == Type::Vector2;          }
     482    template <> inline bool MultiType::MT_ValueBase::isType<orxonox::Vector3>()     const { return this->type_ == Type::Vector3;          }
     483    template <> inline bool MultiType::MT_ValueBase::isType<orxonox::Vector4>()     const { return this->type_ == Type::Vector4;          }
     484    template <> inline bool MultiType::MT_ValueBase::isType<orxonox::ColourValue>() const { return this->type_ == Type::ColourValue;      }
     485    template <> inline bool MultiType::MT_ValueBase::isType<orxonox::Quaternion>()  const { return this->type_ == Type::Quaternion;       }
     486    template <> inline bool MultiType::MT_ValueBase::isType<orxonox::Radian>()      const { return this->type_ == Type::Radian;           }
     487    template <> inline bool MultiType::MT_ValueBase::isType<orxonox::Degree>()      const { return this->type_ == Type::Degree;           }
     488
     489    template <> inline bool MultiType::set(const char* value)  { return this->set(std::string(value)); }
     490    template <> inline bool MultiType::set(const mbool& value) { return this->set((bool)value); }
     491
     492    // Spezializations for void
     493    template <> inline bool MultiType::isType<void>() const { return this->null(); }
     494    template <> inline bool MultiType::convert<void>() { this->reset(); return true; }
    549495
    550496    template <> _UtilExport void MultiType::createNewValueContainer(const char& value);
     
    571517    template <> _UtilExport void MultiType::createNewValueContainer(const orxonox::Radian& value);
    572518    template <> _UtilExport void MultiType::createNewValueContainer(const orxonox::Degree& value);
    573 
    574     inline bool MultiType::setValue(const char& value)                  { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
    575     inline bool MultiType::setValue(const unsigned char& value)         { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
    576     inline bool MultiType::setValue(const short& value)                 { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
    577     inline bool MultiType::setValue(const unsigned short& value)        { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
    578     inline bool MultiType::setValue(const int& value)                   { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
    579     inline bool MultiType::setValue(const unsigned int& value)          { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
    580     inline bool MultiType::setValue(const long& value)                  { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
    581     inline bool MultiType::setValue(const unsigned long& value)         { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
    582     inline bool MultiType::setValue(const long long& value)             { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
    583     inline bool MultiType::setValue(const unsigned long long& value)    { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
    584     inline bool MultiType::setValue(const float& value)                 { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
    585     inline bool MultiType::setValue(const double& value)                { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
    586     inline bool MultiType::setValue(const long double& value)           { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
    587     inline bool MultiType::setValue(const bool& value)                  { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
    588     inline bool MultiType::setValue(      void* const& value)           { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
    589     inline bool MultiType::setValue(const std::string& value)           { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
    590     inline bool MultiType::setValue(const orxonox::Vector2& value)      { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
    591     inline bool MultiType::setValue(const orxonox::Vector3& value)      { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
    592     inline bool MultiType::setValue(const orxonox::Vector4& value)      { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
    593     inline bool MultiType::setValue(const orxonox::ColourValue& value)  { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
    594     inline bool MultiType::setValue(const orxonox::Quaternion& value)   { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
    595     inline bool MultiType::setValue(const orxonox::Radian& value)       { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
    596     inline bool MultiType::setValue(const orxonox::Degree& value)       { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
    597 
    598     /// Assigns the given value and converts it to the current type.
    599     inline bool MultiType::setValue(const char* value)                  { if (this->value_) { return this->value_->setValue(std::string(value)); } else { return this->assignValue(std::string(value)); } }
    600519}
    601520
Note: See TracChangeset for help on using the changeset viewer.