Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 19, 2012, 11:24:18 PM (12 years ago)
Author:
landauf
Message:

a lot of refactoring in the internals of MultiType
renamed set<T>() to force<T>() (forces the MultiType to switch its type to T)

Location:
code/branches/testing/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/testing/src/libraries/core/command/Shell.cc

    r8858 r9225  
    170170        {
    171171            OutputLevel level = (value ? DefaultLogLevel::Dev : DefaultLogLevel::User);
    172             ModifyConfigValueExternal(this->configurableMaxLevel_, this->getConfigurableMaxLevelName(), tset, level);
     172            ModifyConfigValueExternal(this->configurableMaxLevel_, this->getConfigurableMaxLevelName(), tset, static_cast<int>(level));
    173173        }
    174174    }
  • code/branches/testing/src/libraries/util/MultiType.cc

    r9222 r9225  
    161161    }
    162162
    163     MultiType::operator char()                 const { return (this->value_) ? ((this->value_->type_ == Type::Char            ) ? (static_cast<MT_Value<char>                *>(this->value_))->value_ : (*this->value_)) : 0;                      } ///< Returns the current value, converted to the requested type.
    164     MultiType::operator unsigned char()        const { return (this->value_) ? ((this->value_->type_ == Type::UnsignedChar    ) ? (static_cast<MT_Value<unsigned char>       *>(this->value_))->value_ : (*this->value_)) : 0;                      } ///< Returns the current value, converted to the requested type.
    165     MultiType::operator short()                const { return (this->value_) ? ((this->value_->type_ == Type::Short           ) ? (static_cast<MT_Value<short>               *>(this->value_))->value_ : (*this->value_)) : 0;                      } ///< Returns the current value, converted to the requested type.
    166     MultiType::operator unsigned short()       const { return (this->value_) ? ((this->value_->type_ == Type::UnsignedShort   ) ? (static_cast<MT_Value<unsigned short>      *>(this->value_))->value_ : (*this->value_)) : 0;                      } ///< Returns the current value, converted to the requested type.
    167     MultiType::operator int()                  const { return (this->value_) ? ((this->value_->type_ == Type::Int             ) ? (static_cast<MT_Value<int>                 *>(this->value_))->value_ : (*this->value_)) : 0;                      } ///< Returns the current value, converted to the requested type.
    168     MultiType::operator unsigned int()         const { return (this->value_) ? ((this->value_->type_ == Type::UnsignedInt     ) ? (static_cast<MT_Value<unsigned int>        *>(this->value_))->value_ : (*this->value_)) : 0;                      } ///< Returns the current value, converted to the requested type.
    169     MultiType::operator long()                 const { return (this->value_) ? ((this->value_->type_ == Type::Long            ) ? (static_cast<MT_Value<long>                *>(this->value_))->value_ : (*this->value_)) : 0;                      } ///< Returns the current value, converted to the requested type.
    170     MultiType::operator unsigned long()        const { return (this->value_) ? ((this->value_->type_ == Type::UnsignedLong    ) ? (static_cast<MT_Value<unsigned long>       *>(this->value_))->value_ : (*this->value_)) : 0;                      } ///< Returns the current value, converted to the requested type.
    171     MultiType::operator long long()            const { return (this->value_) ? ((this->value_->type_ == Type::LongLong        ) ? (static_cast<MT_Value<long long>           *>(this->value_))->value_ : (*this->value_)) : 0;                      } ///< Returns the current value, converted to the requested type.
    172     MultiType::operator unsigned long long()   const { return (this->value_) ? ((this->value_->type_ == Type::UnsignedLongLong) ? (static_cast<MT_Value<unsigned long long>  *>(this->value_))->value_ : (*this->value_)) : 0;                      } ///< Returns the current value, converted to the requested type.
    173     MultiType::operator float()                const { return (this->value_) ? ((this->value_->type_ == Type::Float           ) ? (static_cast<MT_Value<float>               *>(this->value_))->value_ : (*this->value_)) : 0;                      } ///< Returns the current value, converted to the requested type.
    174     MultiType::operator double()               const { return (this->value_) ? ((this->value_->type_ == Type::Double          ) ? (static_cast<MT_Value<double>              *>(this->value_))->value_ : (*this->value_)) : 0;                      } ///< Returns the current value, converted to the requested type.
    175     MultiType::operator long double()          const { return (this->value_) ? ((this->value_->type_ == Type::LongDouble      ) ? (static_cast<MT_Value<long double>         *>(this->value_))->value_ : (*this->value_)) : 0;                      } ///< Returns the current value, converted to the requested type.
    176     MultiType::operator bool()                 const { return (this->value_) ? ((this->value_->type_ == Type::Bool            ) ? (static_cast<MT_Value<bool>                *>(this->value_))->value_ : (*this->value_)) : 0;                      } ///< Returns the current value, converted to the requested type.
    177     MultiType::operator void*()                const { return (this->value_) ? ((this->value_->type_ == Type::VoidPointer     ) ? (static_cast<MT_Value<void*>               *>(this->value_))->value_ : (*this->value_)) : 0;                      } ///< Returns the current value, converted to the requested type.
    178     MultiType::operator std::string()          const { return (this->value_) ? ((this->value_->type_ == Type::String          ) ? (static_cast<MT_Value<std::string>         *>(this->value_))->value_ : (*this->value_)) : NilValue<std::string>();          } ///< Returns the current value, converted to the requested type.
    179     MultiType::operator orxonox::Vector2()     const { return (this->value_) ? ((this->value_->type_ == Type::Vector2         ) ? (static_cast<MT_Value<orxonox::Vector2>    *>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::Vector2>();     } ///< Returns the current value, converted to the requested type.
    180     MultiType::operator orxonox::Vector3()     const { return (this->value_) ? ((this->value_->type_ == Type::Vector3         ) ? (static_cast<MT_Value<orxonox::Vector3>    *>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::Vector3>();     } ///< Returns the current value, converted to the requested type.
    181     MultiType::operator orxonox::Vector4()     const { return (this->value_) ? ((this->value_->type_ == Type::Vector4         ) ? (static_cast<MT_Value<orxonox::Vector4>    *>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::Vector4>();     } ///< Returns the current value, converted to the requested type.
    182     MultiType::operator orxonox::ColourValue() const { return (this->value_) ? ((this->value_->type_ == Type::ColourValue     ) ? (static_cast<MT_Value<orxonox::ColourValue>*>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::ColourValue>(); } ///< Returns the current value, converted to the requested type.
    183     MultiType::operator orxonox::Quaternion()  const { return (this->value_) ? ((this->value_->type_ == Type::Quaternion      ) ? (static_cast<MT_Value<orxonox::Quaternion> *>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::Quaternion>();  } ///< Returns the current value, converted to the requested type.
    184     MultiType::operator orxonox::Radian()      const { return (this->value_) ? ((this->value_->type_ == Type::Radian          ) ? (static_cast<MT_Value<orxonox::Radian>     *>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::Radian>();      } ///< Returns the current value, converted to the requested type.
    185     MultiType::operator orxonox::Degree()      const { return (this->value_) ? ((this->value_->type_ == Type::Degree          ) ? (static_cast<MT_Value<orxonox::Degree>     *>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::Degree>();      } ///< Returns the current value, converted to the requested type.
    186 
    187     template <> void MultiType::createNewValueContainer(const char& value)                 { this->value_ = new MT_Value<char>                (value, Type::Char            ); } ///< Creates a new value container for the given type.
    188     template <> void MultiType::createNewValueContainer(const unsigned char& value)        { this->value_ = new MT_Value<unsigned char>       (value, Type::UnsignedChar    ); } ///< Creates a new value container for the given type.
    189     template <> void MultiType::createNewValueContainer(const short& value)                { this->value_ = new MT_Value<short>               (value, Type::Short           ); } ///< Creates a new value container for the given type.
    190     template <> void MultiType::createNewValueContainer(const unsigned short& value)       { this->value_ = new MT_Value<unsigned short>      (value, Type::UnsignedShort   ); } ///< Creates a new value container for the given type.
    191     template <> void MultiType::createNewValueContainer(const int& value)                  { this->value_ = new MT_Value<int>                 (value, Type::Int             ); } ///< Creates a new value container for the given type.
    192     template <> void MultiType::createNewValueContainer(const unsigned int& value)         { this->value_ = new MT_Value<unsigned int>        (value, Type::UnsignedInt     ); } ///< Creates a new value container for the given type.
    193     template <> void MultiType::createNewValueContainer(const long& value)                 { this->value_ = new MT_Value<long>                (value, Type::Long            ); } ///< Creates a new value container for the given type.
    194     template <> void MultiType::createNewValueContainer(const unsigned long& value)        { this->value_ = new MT_Value<unsigned long>       (value, Type::UnsignedLong    ); } ///< Creates a new value container for the given type.
    195     template <> void MultiType::createNewValueContainer(const long long& value)            { this->value_ = new MT_Value<long long>           (value, Type::LongLong        ); } ///< Creates a new value container for the given type.
    196     template <> void MultiType::createNewValueContainer(const unsigned long long& value)   { this->value_ = new MT_Value<unsigned long long>  (value, Type::UnsignedLongLong); } ///< Creates a new value container for the given type.
    197     template <> void MultiType::createNewValueContainer(const float& value)                { this->value_ = new MT_Value<float>               (value, Type::Float           ); } ///< Creates a new value container for the given type.
    198     template <> void MultiType::createNewValueContainer(const double& value)               { this->value_ = new MT_Value<double>              (value, Type::Double          ); } ///< Creates a new value container for the given type.
    199     template <> void MultiType::createNewValueContainer(const long double& value)          { this->value_ = new MT_Value<long double>         (value, Type::LongDouble      ); } ///< Creates a new value container for the given type.
    200     template <> void MultiType::createNewValueContainer(const bool& value)                 { this->value_ = new MT_Value<bool>                (value, Type::Bool            ); } ///< Creates a new value container for the given type.
    201     template <> void MultiType::createNewValueContainer(      void* const& value)          { this->value_ = new MT_Value<void*>               (value, Type::VoidPointer     ); } ///< Creates a new value container for the given type.
    202     template <> void MultiType::createNewValueContainer(const std::string& value)          { this->value_ = new MT_Value<std::string>         (value, Type::String          ); } ///< Creates a new value container for the given type.
    203     template <> void MultiType::createNewValueContainer(const orxonox::Vector2& value)     { this->value_ = new MT_Value<orxonox::Vector2>    (value, Type::Vector2         ); } ///< Creates a new value container for the given type.
    204     template <> void MultiType::createNewValueContainer(const orxonox::Vector3& value)     { this->value_ = new MT_Value<orxonox::Vector3>    (value, Type::Vector3         ); } ///< Creates a new value container for the given type.
    205     template <> void MultiType::createNewValueContainer(const orxonox::Vector4& value)     { this->value_ = new MT_Value<orxonox::Vector4>    (value, Type::Vector4         ); } ///< Creates a new value container for the given type.
    206     template <> void MultiType::createNewValueContainer(const orxonox::ColourValue& value) { this->value_ = new MT_Value<orxonox::ColourValue>(value, Type::ColourValue     ); } ///< Creates a new value container for the given type.
    207     template <> void MultiType::createNewValueContainer(const orxonox::Quaternion& value)  { this->value_ = new MT_Value<orxonox::Quaternion> (value, Type::Quaternion      ); } ///< Creates a new value container for the given type.
    208     template <> void MultiType::createNewValueContainer(const orxonox::Radian& value)      { this->value_ = new MT_Value<orxonox::Radian>     (value, Type::Radian          ); } ///< Creates a new value container for the given type.
    209     template <> void MultiType::createNewValueContainer(const orxonox::Degree& value)      { this->value_ = new MT_Value<orxonox::Degree>     (value, Type::Degree          ); } ///< Creates a new value container for the given type.
     163    template <> void MultiType::createNewValueContainer(const char& value)                 { this->value_ = new MT_Value<char>                (value, Type::Char            ); }
     164    template <> void MultiType::createNewValueContainer(const unsigned char& value)        { this->value_ = new MT_Value<unsigned char>       (value, Type::UnsignedChar    ); }
     165    template <> void MultiType::createNewValueContainer(const short& value)                { this->value_ = new MT_Value<short>               (value, Type::Short           ); }
     166    template <> void MultiType::createNewValueContainer(const unsigned short& value)       { this->value_ = new MT_Value<unsigned short>      (value, Type::UnsignedShort   ); }
     167    template <> void MultiType::createNewValueContainer(const int& value)                  { this->value_ = new MT_Value<int>                 (value, Type::Int             ); }
     168    template <> void MultiType::createNewValueContainer(const unsigned int& value)         { this->value_ = new MT_Value<unsigned int>        (value, Type::UnsignedInt     ); }
     169    template <> void MultiType::createNewValueContainer(const long& value)                 { this->value_ = new MT_Value<long>                (value, Type::Long            ); }
     170    template <> void MultiType::createNewValueContainer(const unsigned long& value)        { this->value_ = new MT_Value<unsigned long>       (value, Type::UnsignedLong    ); }
     171    template <> void MultiType::createNewValueContainer(const long long& value)            { this->value_ = new MT_Value<long long>           (value, Type::LongLong        ); }
     172    template <> void MultiType::createNewValueContainer(const unsigned long long& value)   { this->value_ = new MT_Value<unsigned long long>  (value, Type::UnsignedLongLong); }
     173    template <> void MultiType::createNewValueContainer(const float& value)                { this->value_ = new MT_Value<float>               (value, Type::Float           ); }
     174    template <> void MultiType::createNewValueContainer(const double& value)               { this->value_ = new MT_Value<double>              (value, Type::Double          ); }
     175    template <> void MultiType::createNewValueContainer(const long double& value)          { this->value_ = new MT_Value<long double>         (value, Type::LongDouble      ); }
     176    template <> void MultiType::createNewValueContainer(const bool& value)                 { this->value_ = new MT_Value<bool>                (value, Type::Bool            ); }
     177    template <> void MultiType::createNewValueContainer(      void* const& value)          { this->value_ = new MT_Value<void*>               (value, Type::VoidPointer     ); }
     178    template <> void MultiType::createNewValueContainer(const std::string& value)          { this->value_ = new MT_Value<std::string>         (value, Type::String          ); }
     179    template <> void MultiType::createNewValueContainer(const orxonox::Vector2& value)     { this->value_ = new MT_Value<orxonox::Vector2>    (value, Type::Vector2         ); }
     180    template <> void MultiType::createNewValueContainer(const orxonox::Vector3& value)     { this->value_ = new MT_Value<orxonox::Vector3>    (value, Type::Vector3         ); }
     181    template <> void MultiType::createNewValueContainer(const orxonox::Vector4& value)     { this->value_ = new MT_Value<orxonox::Vector4>    (value, Type::Vector4         ); }
     182    template <> void MultiType::createNewValueContainer(const orxonox::ColourValue& value) { this->value_ = new MT_Value<orxonox::ColourValue>(value, Type::ColourValue     ); }
     183    template <> void MultiType::createNewValueContainer(const orxonox::Quaternion& value)  { this->value_ = new MT_Value<orxonox::Quaternion> (value, Type::Quaternion      ); }
     184    template <> void MultiType::createNewValueContainer(const orxonox::Radian& value)      { this->value_ = new MT_Value<orxonox::Radian>     (value, Type::Radian          ); }
     185    template <> void MultiType::createNewValueContainer(const orxonox::Degree& value)      { this->value_ = new MT_Value<orxonox::Degree>     (value, Type::Degree          ); }
    210186}
  • code/branches/testing/src/libraries/util/MultiType.h

    r9224 r9225  
    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
     
    5959     - @ref orxonox::MultiType::convert "convert<T>()" sets the type to T and converts the currently assigned value
    6060     - @ref orxonox::MultiType::reset "reset<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.
     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
     
    173174        {
    174175        public:
    175             MT_ValueBase(Type::Enum type) : type_(type), bHasDefaultValue_(false) {}
     176            MT_ValueBase(void* data, Type::Enum type) : type_(type), bHasDefaultValue_(false), data_(data) {}
    176177            virtual ~MT_ValueBase() {}
    177178
     
    179180
    180181            virtual void reset() = 0;
    181             virtual bool assimilate(const MultiType& other) = 0;
    182182
    183183            /// Returns the type of the current value.
    184184            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.
     
    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;
     
    267259            Type::Enum type_;       ///< The type of the current value
    268260            bool bHasDefaultValue_; ///< True if the last conversion wasn't successful
     261            void* data_;            ///< For direct access to the value if the type is known
    269262        };
    270263
     
    272265            static const MultiType Null;
    273266
    274             inline MultiType()                                  : value_(0) {}                                      ///< Default constructor: Assigns no value and no type. The type will be determined by the first assignment of a value.
    275             inline MultiType(const char& value)                 : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    276             inline MultiType(const unsigned char& value)        : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    277             inline MultiType(const short& value)                : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    278             inline MultiType(const unsigned short& value)       : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    279             inline MultiType(const int& value)                  : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    280             inline MultiType(const unsigned int& value)         : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    281             inline MultiType(const long& value)                 : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    282             inline MultiType(const unsigned long& value)        : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    283             inline MultiType(const long long& value)            : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    284             inline MultiType(const unsigned long long& value)   : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    285             inline MultiType(const float& value)                : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    286             inline MultiType(const double& value)               : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    287             inline MultiType(const long double& value)          : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    288             inline MultiType(const bool& value)                 : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    289             inline MultiType(      void* const& value)          : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    290             inline MultiType(const std::string& value)          : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    291             inline MultiType(const orxonox::Vector2& value)     : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    292             inline MultiType(const orxonox::Vector3& value)     : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    293             inline MultiType(const orxonox::Vector4& value)     : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    294             inline MultiType(const orxonox::ColourValue& value) : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    295             inline MultiType(const orxonox::Quaternion& value)  : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    296             inline MultiType(const orxonox::Radian& value)      : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    297             inline MultiType(const orxonox::Degree& value)      : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    298             inline MultiType(const orxonox::mbool& value)       : value_(0) { this->assignValue((bool)value); }     ///< Constructor: Assigns the given mbool and converts it to bool.
    299             inline MultiType(const char* value)                 : value_(0) { this->set(std::string(value)); }      ///< Constructor: Converts the char array to a std::string, assigns the value and sets the type.
    300             inline MultiType(const MultiType& other)            : value_(0) { this->set(other); }                   ///< Copyconstructor: Assigns value and type of the other MultiType.
     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); }
    301274
    302275            /// Destructor: Deletes the MT_Value.
    303276            inline ~MultiType() { if (this->value_) { delete this->value_; } }
    304277
    305             template <typename V> inline MultiType& operator=(const V& value)         { this->set(value); return (*this); } ///< Assigns a new value. The value will be converted to the current type of the MultiType.
    306             template <typename V> inline MultiType& operator=(V* value)               { this->set(value); return (*this); } ///< Assigns a pointer.
    307             inline                       MultiType& operator=(const MultiType& other) { this->set(other); return (*this); } ///< Assigns the value of the other MultiType and converts it to the current type of the MultiType.
    308 
    309             inline bool                                   set(const char& value);
    310             inline bool                                   set(const unsigned char& value);
    311             inline bool                                   set(const short& value);
    312             inline bool                                   set(const unsigned short& value);
    313             inline bool                                   set(const int& value);
    314             inline bool                                   set(const unsigned int& value);
    315             inline bool                                   set(const long& value);
    316             inline bool                                   set(const unsigned long& value);
    317             inline bool                                   set(const long long& value);
    318             inline bool                                   set(const unsigned long long& value);
    319             inline bool                                   set(const float& value);
    320             inline bool                                   set(const double& value);
    321             inline bool                                   set(const long double& value);
    322             inline bool                                   set(const bool& value);
    323             inline bool                                   set(      void* const& value);
    324             inline bool                                   set(const std::string& value);
    325             inline bool                                   set(const orxonox::Vector2& value);
    326             inline bool                                   set(const orxonox::Vector3& value);
    327             inline bool                                   set(const orxonox::Vector4& value);
    328             inline bool                                   set(const orxonox::ColourValue& value);
    329             inline bool                                   set(const orxonox::Quaternion& value);
    330             inline bool                                   set(const orxonox::Radian& value);
    331             inline bool                                   set(const orxonox::Degree& value);
    332             inline bool                                   set(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); }
     280            /// Assigns a pointer.
     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            }
    333294            /// Assigns a pointer.
    334295            template <typename V> inline bool set(V* value)
     
    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)));
    340             }
     299
     300                this->assignValue(static_cast<void*>(const_cast<typename Loki::TypeTraits<V>::UnqualifiedType*>(value)));
     301                return true;
     302            }
     303            /// Assigns the value of the other MultiType and converts it to the current type.
     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
    341313            /// Changes the type to T and assigns the new value (which might be of another type than T - it gets converted).
    342             template <typename T, typename V> inline bool set(const V& value) { this->reset<T>(); return this->set(value); }
    343             /// Assigns the value of the other MultiType and converts it to the current type.
    344             bool                                          set(const MultiType& other) { if (this->value_) { return this->value_->assimilate(other); } else { if (other.value_) { this->value_ = other.value_->clone(); } return true; } }
     314            template <typename T, typename V> inline bool force(const V& value)
     315            {
     316                this->reset<T>();
     317                return this->set(value);
     318            }
    345319
    346320            /// Copies the other MultiType by assigning value and type.
    347             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            }
    348329
    349330            /// Converts the current value to type T.
    350             template <typename T> inline bool convert()                    { return this->set<T>((typename Loki::TypeTraits<T>::UnqualifiedReferredType)(*this)); }
     331            template <typename T> inline bool convert() { return this->force<T>(this->get<typename Loki::TypeTraits<T>::UnqualifiedReferredType>()); }
    351332
    352333            /// Resets value and type. Type will be void afterwards and null() returns true.
    353             inline void                       reset()                      { if (this->value_) delete this->value_; this->value_ = 0; }
     334            inline void reset() { if (this->value_) delete this->value_; this->value_ = 0; }
    354335            /// Resets the value and changes the internal type to T.
    355             template <typename T> inline void reset()                      { this->assignValue(typename Loki::TypeTraits<T>::UnqualifiedReferredType()); }
     336            template <typename T> inline void reset() { this->assignValue(typename Loki::TypeTraits<T>::UnqualifiedReferredType()); }
    356337            /// Current value gets overridden with default zero value
    357             inline void                       resetValue()                 { if (this->value_) this->value_->reset(); }
    358 
    359             /// Returns true if the current type is T.
    360             template <typename T> inline bool isType()               const { return false; } // Only works for specialized values - see below
    361             std::string                       getTypename()          const;
    362 
    363             /// Saves the value of the MT to a bytestream (pointed at by mem) and increases mem pointer by size of MT
    364             inline void                       exportData(uint8_t*& mem) const { assert(sizeof(Type::Enum)<=8); *static_cast<uint8_t*>(mem) = this->getType(); mem+=sizeof(uint8_t); this->value_->exportData(mem); }
    365             /// Loads the value of the MT from a bytestream (pointed at by mem) and increases mem pointer by size of MT
    366             inline void                       importData(uint8_t*& mem) { assert(sizeof(Type::Enum)<=8); this->setType(static_cast<Type::Enum>(*static_cast<uint8_t*>(mem))); mem+=sizeof(uint8_t); this->value_->importData(mem); }
    367             /// Saves the value of the MT to a bytestream and increases pointer to bytestream by size of MT
    368             inline uint8_t*&                  operator << (uint8_t*& mem) { importData(mem); return mem; }
    369             /// Loads the value of the MT to a bytestream and increases pointer to bytestream by size of MT
    370             inline void                       operator >> (uint8_t*& mem) const { exportData(mem); }
    371             inline uint32_t                   getNetworkSize() const { assert(this->value_); return this->value_->getSize() + sizeof(uint8_t); }
     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;
    372343
    373344            /// Checks whether the value is a default one (assigned after a failed conversion)
    374             bool                              hasDefaultValue() const { return this->value_->hasDefaultValue(); }
     345            inline bool hasDefaultValue() const { return this->value_->hasDefaultValue(); }
    375346
    376347            /// Checks if the MT contains no value.
    377             bool                              null() const { return !this->value_; }
    378 
    379             operator char()                  const;
    380             operator unsigned char()         const;
    381             operator short()                 const;
    382             operator unsigned short()        const;
    383             operator int()                   const;
    384             operator unsigned int()          const;
    385             operator long()                  const;
    386             operator unsigned long()         const;
    387             operator long long()             const;
    388             operator unsigned long long()    const;
    389             operator float()                 const;
    390             operator double()                const;
    391             operator long double()           const;
    392             operator bool()                  const;
    393             operator void*()                 const;
    394             operator std::string()           const;
    395             operator orxonox::Vector2()      const;
    396             operator orxonox::Vector3()      const;
    397             operator orxonox::Vector4()      const;
    398             operator orxonox::ColourValue()  const;
    399             operator orxonox::Quaternion()   const;
    400             operator orxonox::Radian()       const;
    401             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>()); }
    402373            /// Returns the current value, converted to a T* pointer.
    403374            template <class T> operator T*() const { return (static_cast<T*>(this->operator void*())); }
    404375
    405             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.
    406             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.
    407             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.
    408             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.
    409             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.
    410             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.
    411             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.
    412             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.
    413             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.
    414             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.
    415             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.
    416             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.
    417             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.
    418             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.
    419             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.
    420             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.
    421             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.
    422             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.
    423             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.
    424             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.
    425             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.
    426             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.
    427             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.
     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; }
    428378
    429379            /// Returns the current value, converted to the requested type.
    430             template <typename T> inline T get() const { return T(); }
     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            }
    431418
    432419        private:
    433             inline bool assignValue(const char& value)                 { if (this->value_ && this->value_->type_ == 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.
    434             inline bool assignValue(const unsigned char& value)        { if (this->value_ && this->value_->type_ == 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.
    435             inline bool assignValue(const short& value)                { if (this->value_ && this->value_->type_ == 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.
    436             inline bool assignValue(const unsigned short& value)       { if (this->value_ && this->value_->type_ == 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.
    437             inline bool assignValue(const int& value)                  { if (this->value_ && this->value_->type_ == 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.
    438             inline bool assignValue(const unsigned int& value)         { if (this->value_ && this->value_->type_ == 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.
    439             inline bool assignValue(const long& value)                 { if (this->value_ && this->value_->type_ == 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.
    440             inline bool assignValue(const unsigned long& value)        { if (this->value_ && this->value_->type_ == 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.
    441             inline bool assignValue(const long long& value)            { if (this->value_ && this->value_->type_ == 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.
    442             inline bool assignValue(const unsigned long long& value)   { if (this->value_ && this->value_->type_ == 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.
    443             inline bool assignValue(const float& value)                { if (this->value_ && this->value_->type_ == 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.
    444             inline bool assignValue(const double& value)               { if (this->value_ && this->value_->type_ == 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.
    445             inline bool assignValue(const long double& value)          { if (this->value_ && this->value_->type_ == 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.
    446             inline bool assignValue(const bool& value)                 { if (this->value_ && this->value_->type_ == 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.
    447             inline bool assignValue(      void* const& value)          { if (this->value_ && this->value_->type_ == 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.
    448             inline bool assignValue(const std::string& value)          { if (this->value_ && this->value_->type_ == 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.
    449             inline bool assignValue(const orxonox::Vector2& value)     { if (this->value_ && this->value_->type_ == 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.
    450             inline bool assignValue(const orxonox::Vector3& value)     { if (this->value_ && this->value_->type_ == 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.
    451             inline bool assignValue(const orxonox::Vector4& value)     { if (this->value_ && this->value_->type_ == 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.
    452             inline bool assignValue(const orxonox::ColourValue& value) { if (this->value_ && this->value_->type_ == 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.
    453             inline bool assignValue(const orxonox::Quaternion& value)  { if (this->value_ && this->value_->type_ == 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.
    454             inline bool assignValue(const orxonox::Radian& value)      { if (this->value_ && this->value_->type_ == 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.
    455             inline bool assignValue(const orxonox::Degree& value)      { if (this->value_ && this->value_->type_ == 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            }
    456436
    457437            /// Resets the value and changes the internal type to the given type.
    458             inline void       setType(Type::Enum type) { this->reset(); this->convert(type); this->resetValue(); }
     438            inline void setType(Type::Enum type) { this->reset(); this->convert(type); this->resetValue(); }
    459439            /// Returns the current type.
    460             inline Type::Enum getType()          const { return (this->value_) ? this->value_->type_ : Type::Null; }
     440            inline Type::Enum getType() const { return (this->value_) ? this->value_->type_ : Type::Null; }
    461441            /// Converts the current value to the given type.
    462             bool              convert(Type::Enum type);
     442            bool convert(Type::Enum type);
    463443
    464444            /// Changes the value container.
    465             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            }
    466451            /// Creates a new value container (works only with specialized types).
    467             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; }
    468453
    469454            MT_ValueBase* value_; //!< A pointer to the value container
     
    471456
    472457    /// Puts the MultiType on a stream by using the native << operator of the current type.
    473     _UtilExport inline std::ostream& operator<<(std::ostream& outstream, const MultiType& mt) { if (mt.value_) { mt.value_->toString(outstream); } return outstream; }
    474 
    475     template <> inline bool MultiType::isType<void>()                 const { return this->null();                                                    } ///< Returns true if the current type equals the given type.
    476     template <> inline bool MultiType::isType<char>()                 const { return (this->value_ && this->value_->type_ == Type::Char);             } ///< Returns true if the current type equals the given type.
    477     template <> inline bool MultiType::isType<unsigned char>()        const { return (this->value_ && this->value_->type_ == Type::UnsignedChar);     } ///< Returns true if the current type equals the given type.
    478     template <> inline bool MultiType::isType<short>()                const { return (this->value_ && this->value_->type_ == Type::Short);            } ///< Returns true if the current type equals the given type.
    479     template <> inline bool MultiType::isType<unsigned short>()       const { return (this->value_ && this->value_->type_ == Type::UnsignedShort);    } ///< Returns true if the current type equals the given type.
    480     template <> inline bool MultiType::isType<int>()                  const { return (this->value_ && this->value_->type_ == Type::Int);              } ///< Returns true if the current type equals the given type.
    481     template <> inline bool MultiType::isType<unsigned int>()         const { return (this->value_ && this->value_->type_ == Type::UnsignedInt);      } ///< Returns true if the current type equals the given type.
    482     template <> inline bool MultiType::isType<long>()                 const { return (this->value_ && this->value_->type_ == Type::Long);             } ///< Returns true if the current type equals the given type.
    483     template <> inline bool MultiType::isType<unsigned long>()        const { return (this->value_ && this->value_->type_ == Type::UnsignedLong);     } ///< Returns true if the current type equals the given type.
    484     template <> inline bool MultiType::isType<long long>()            const { return (this->value_ && this->value_->type_ == Type::LongLong);         } ///< Returns true if the current type equals the given type.
    485     template <> inline bool MultiType::isType<unsigned long long>()   const { return (this->value_ && this->value_->type_ == Type::UnsignedLongLong); } ///< Returns true if the current type equals the given type.
    486     template <> inline bool MultiType::isType<float>()                const { return (this->value_ && this->value_->type_ == Type::Float);            } ///< Returns true if the current type equals the given type.
    487     template <> inline bool MultiType::isType<double>()               const { return (this->value_ && this->value_->type_ == Type::Double);           } ///< Returns true if the current type equals the given type.
    488     template <> inline bool MultiType::isType<long double>()          const { return (this->value_ && this->value_->type_ == Type::LongDouble);       } ///< Returns true if the current type equals the given type.
    489     template <> inline bool MultiType::isType<bool>()                 const { return (this->value_ && this->value_->type_ == Type::Bool);             } ///< Returns true if the current type equals the given type.
    490     template <> inline bool MultiType::isType<void*>()                const { return (this->value_ && this->value_->type_ == Type::VoidPointer);      } ///< Returns true if the current type equals the given type.
    491     template <> inline bool MultiType::isType<std::string>()          const { return (this->value_ && this->value_->type_ == Type::String);           } ///< Returns true if the current type equals the given type.
    492     template <> inline bool MultiType::isType<orxonox::Vector2>()     const { return (this->value_ && this->value_->type_ == Type::Vector2);          } ///< Returns true if the current type equals the given type.
    493     template <> inline bool MultiType::isType<orxonox::Vector3>()     const { return (this->value_ && this->value_->type_ == Type::Vector3);          } ///< Returns true if the current type equals the given type.
    494     template <> inline bool MultiType::isType<orxonox::Vector4>()     const { return (this->value_ && this->value_->type_ == Type::Vector4);          } ///< Returns true if the current type equals the given type.
    495     template <> inline bool MultiType::isType<orxonox::ColourValue>() const { return (this->value_ && this->value_->type_ == Type::ColourValue);      } ///< Returns true if the current type equals the given type.
    496     template <> inline bool MultiType::isType<orxonox::Quaternion>()  const { return (this->value_ && this->value_->type_ == Type::Quaternion);       } ///< Returns true if the current type equals the given type.
    497     template <> inline bool MultiType::isType<orxonox::Radian>()      const { return (this->value_ && this->value_->type_ == Type::Radian);           } ///< Returns true if the current type equals the given type.
    498     template <> inline bool MultiType::isType<orxonox::Degree>()      const { return (this->value_ && this->value_->type_ == Type::Degree);           } ///< Returns true if the current type equals the given type.
    499 
    500     /// Deletes the content, type becomes void.
    501     template <> inline bool MultiType::convert<void>()                 { this->reset(); return true; }
    502 
    503     // Specialization to avoid ambiguities with the conversion operator
    504     template <> inline bool MultiType::convert<std::string>()          { return this->set<std::string>         (this->operator std::string());          } ///< Converts the current value to the given type.
    505     template <> inline bool MultiType::convert<orxonox::Vector2>()     { return this->set<orxonox::Vector2>    (this->operator orxonox::Vector2());     } ///< Converts the current value to the given type.
    506     template <> inline bool MultiType::convert<orxonox::Vector3>()     { return this->set<orxonox::Vector3>    (this->operator orxonox::Vector3());     } ///< Converts the current value to the given type.
    507     template <> inline bool MultiType::convert<orxonox::Vector4>()     { return this->set<orxonox::Vector4>    (this->operator orxonox::Vector4());     } ///< Converts the current value to the given type.
    508     template <> inline bool MultiType::convert<orxonox::ColourValue>() { return this->set<orxonox::ColourValue>(this->operator orxonox::ColourValue()); } ///< Converts the current value to the given type.
    509     template <> inline bool MultiType::convert<orxonox::Quaternion>()  { return this->set<orxonox::Quaternion> (this->operator orxonox::Quaternion());  } ///< Converts the current value to the given type.
    510     template <> inline bool MultiType::convert<orxonox::Radian>()      { return this->set<orxonox::Radian>     (this->operator orxonox::Radian());      } ///< Converts the current value to the given type.
    511     template <> inline bool MultiType::convert<orxonox::Degree>()      { return this->set<orxonox::Degree>     (this->operator orxonox::Degree());      } ///< Converts the current value to the given type.
    512 
    513     // Specialization to avoid ambiguities with the conversion operator
    514     template <> inline bool MultiType::convert<const std::string&>()          { return this->convert<std::string>();          } ///< Converts the current value to the given type.
    515     template <> inline bool MultiType::convert<const orxonox::Vector2&>()     { return this->convert<orxonox::Vector2>();     } ///< Converts the current value to the given type.
    516     template <> inline bool MultiType::convert<const orxonox::Vector3&>()     { return this->convert<orxonox::Vector3>();     } ///< Converts the current value to the given type.
    517     template <> inline bool MultiType::convert<const orxonox::Vector4&>()     { return this->convert<orxonox::Vector4>();     } ///< Converts the current value to the given type.
    518     template <> inline bool MultiType::convert<const orxonox::ColourValue&>() { return this->convert<orxonox::ColourValue>(); } ///< Converts the current value to the given type.
    519     template <> inline bool MultiType::convert<const orxonox::Quaternion&>()  { return this->convert<orxonox::Quaternion>();  } ///< Converts the current value to the given type.
    520     template <> inline bool MultiType::convert<const orxonox::Radian&>()      { return this->convert<orxonox::Radian>();      } ///< Converts the current value to the given type.
    521     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; }
    522495
    523496    template <> _UtilExport void MultiType::createNewValueContainer(const char& value);
     
    544517    template <> _UtilExport void MultiType::createNewValueContainer(const orxonox::Radian& value);
    545518    template <> _UtilExport void MultiType::createNewValueContainer(const orxonox::Degree& value);
    546 
    547     inline bool MultiType::set(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.
    548     inline bool MultiType::set(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.
    549     inline bool MultiType::set(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.
    550     inline bool MultiType::set(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.
    551     inline bool MultiType::set(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.
    552     inline bool MultiType::set(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.
    553     inline bool MultiType::set(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.
    554     inline bool MultiType::set(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.
    555     inline bool MultiType::set(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.
    556     inline bool MultiType::set(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.
    557     inline bool MultiType::set(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.
    558     inline bool MultiType::set(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.
    559     inline bool MultiType::set(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.
    560     inline bool MultiType::set(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.
    561     inline bool MultiType::set(      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.
    562     inline bool MultiType::set(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.
    563     inline bool MultiType::set(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.
    564     inline bool MultiType::set(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.
    565     inline bool MultiType::set(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.
    566     inline bool MultiType::set(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.
    567     inline bool MultiType::set(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.
    568     inline bool MultiType::set(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.
    569     inline bool MultiType::set(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.
    570 
    571     template <> inline char                     MultiType::get() const { return this->operator char();                 }
    572     template <> inline unsigned char            MultiType::get() const { return this->operator unsigned char();        }
    573     template <> inline short                    MultiType::get() const { return this->operator short();                }
    574     template <> inline unsigned short           MultiType::get() const { return this->operator unsigned short();       }
    575     template <> inline int                      MultiType::get() const { return this->operator int();                  }
    576     template <> inline unsigned int             MultiType::get() const { return this->operator unsigned int();         }
    577     template <> inline long                     MultiType::get() const { return this->operator long();                 }
    578     template <> inline unsigned long            MultiType::get() const { return this->operator unsigned long();        }
    579     template <> inline long long                MultiType::get() const { return this->operator long long();            }
    580     template <> inline unsigned long long       MultiType::get() const { return this->operator unsigned long long();   }
    581     template <> inline float                    MultiType::get() const { return this->operator float();                }
    582     template <> inline double                   MultiType::get() const { return this->operator double();               }
    583     template <> inline long double              MultiType::get() const { return this->operator long double();          }
    584     template <> inline bool                     MultiType::get() const { return this->operator bool();                 }
    585     template <> inline void*                    MultiType::get() const { return this->operator void*();                }
    586     template <> inline std::string              MultiType::get() const { return this->operator std::string();          }
    587     template <> inline orxonox::Vector2         MultiType::get() const { return this->operator orxonox::Vector2();     }
    588     template <> inline orxonox::Vector3         MultiType::get() const { return this->operator orxonox::Vector3();     }
    589     template <> inline orxonox::Vector4         MultiType::get() const { return this->operator orxonox::Vector4();     }
    590     template <> inline orxonox::ColourValue     MultiType::get() const { return this->operator orxonox::ColourValue(); }
    591     template <> inline orxonox::Quaternion      MultiType::get() const { return this->operator orxonox::Quaternion();  }
    592     template <> inline orxonox::Radian          MultiType::get() const { return this->operator orxonox::Radian();      }
    593     template <> inline orxonox::Degree          MultiType::get() const { return this->operator orxonox::Degree();      }
    594 
    595     /// Assigns the given value and converts it to the current type.
    596     inline bool MultiType::set(const char* value)                  { if (this->value_) { return this->value_->setValue(std::string(value)); } else { return this->assignValue(std::string(value)); } }
    597519}
    598520
  • code/branches/testing/src/libraries/util/MultiTypeValue.h

    r9222 r9225  
    5555    public:
    5656        /// Constructor: Assigns the value and the type identifier.
    57         MT_Value(const T& value, MultiType::Type::Enum type) : MT_ValueBase(type), value_(value) {}
     57        MT_Value(const T& value, MultiType::Type::Enum type) : MT_ValueBase(&this->value_, type), value_(value) {}
    5858
    5959        /// Creates a copy of itself.
     
    6262        /// Resets the current value to the default.
    6363        inline void reset() { this->value_ = zeroise<T>(); bHasDefaultValue_ = true; }
    64 
    65         /**
    66             @brief Assigns the value of the other MultiType, converted to T.
    67             @param other The other MultiType
    68         */
    69         inline bool assimilate(const MultiType& other)
    70         {
    71             if (other.value_)
    72             {
    73                 return !(bHasDefaultValue_ = !other.value_->getValue(&value_));
    74             }
    75             else
    76             {
    77                 this->value_ = zeroise<T>();
    78                 return !(bHasDefaultValue_ = true);
    79             }
    80         }
    8164
    8265        inline bool getValue(char*                 value) const { return convertValue<T, char                >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     
    9578        inline bool getValue(bool*                 value) const { return convertValue<T, bool                >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    9679        inline bool getValue(void**                value) const { return convertValue<T, void*               >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    97         inline bool getValue(std::string*          value) const { return convertValue<T, std::string         >(value, value_, zeroise<std::string>         ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    98         inline bool getValue(orxonox::Vector2*     value) const { return convertValue<T, orxonox::Vector2    >(value, value_, zeroise<orxonox::Vector2>    ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    99         inline bool getValue(orxonox::Vector3*     value) const { return convertValue<T, orxonox::Vector3    >(value, value_, zeroise<orxonox::Vector3>    ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    100         inline bool getValue(orxonox::Vector4*     value) const { return convertValue<T, orxonox::Vector4    >(value, value_, zeroise<orxonox::Vector4>    ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    101         inline bool getValue(orxonox::ColourValue* value) const { return convertValue<T, orxonox::ColourValue>(value, value_, zeroise<orxonox::ColourValue>()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    102         inline bool getValue(orxonox::Quaternion*  value) const { return convertValue<T, orxonox::Quaternion >(value, value_, zeroise<orxonox::Quaternion> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    103         inline bool getValue(orxonox::Radian*      value) const { return convertValue<T, orxonox::Radian     >(value, value_, zeroise<orxonox::Radian>     ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    104         inline bool getValue(orxonox::Degree*      value) const { return convertValue<T, orxonox::Degree     >(value, value_, zeroise<orxonox::Degree>     ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    105 
    106         inline bool setValue(const char& value)                 { return !(bHasDefaultValue_ = !convertValue<char                , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
    107         inline bool setValue(const unsigned char& value)        { return !(bHasDefaultValue_ = !convertValue<unsigned char       , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
    108         inline bool setValue(const short& value)                { return !(bHasDefaultValue_ = !convertValue<short               , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
    109         inline bool setValue(const unsigned short& value)       { return !(bHasDefaultValue_ = !convertValue<unsigned short      , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
    110         inline bool setValue(const int& value)                  { return !(bHasDefaultValue_ = !convertValue<int                 , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
    111         inline bool setValue(const unsigned int& value)         { return !(bHasDefaultValue_ = !convertValue<unsigned int        , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
    112         inline bool setValue(const long& value)                 { return !(bHasDefaultValue_ = !convertValue<long                , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
    113         inline bool setValue(const unsigned long& value)        { return !(bHasDefaultValue_ = !convertValue<unsigned long       , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
    114         inline bool setValue(const long long& value)            { return !(bHasDefaultValue_ = !convertValue<long long           , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
    115         inline bool setValue(const unsigned long long& value)   { return !(bHasDefaultValue_ = !convertValue<unsigned long long  , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
    116         inline bool setValue(const float& value)                { return !(bHasDefaultValue_ = !convertValue<float               , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
    117         inline bool setValue(const double& value)               { return !(bHasDefaultValue_ = !convertValue<double              , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
    118         inline bool setValue(const long double& value)          { return !(bHasDefaultValue_ = !convertValue<long double         , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
    119         inline bool setValue(const bool& value)                 { return !(bHasDefaultValue_ = !convertValue<bool                , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
    120         inline bool setValue(      void* const& value)          { return !(bHasDefaultValue_ = !convertValue<void*               , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
    121         inline bool setValue(const std::string& value)          { return !(bHasDefaultValue_ = !convertValue<std::string         , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
    122         inline bool setValue(const orxonox::Vector2& value)     { return !(bHasDefaultValue_ = !convertValue<orxonox::Vector2    , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
    123         inline bool setValue(const orxonox::Vector3& value)     { return !(bHasDefaultValue_ = !convertValue<orxonox::Vector3    , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
    124         inline bool setValue(const orxonox::Vector4& value)     { return !(bHasDefaultValue_ = !convertValue<orxonox::Vector4    , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
    125         inline bool setValue(const orxonox::ColourValue& value) { return !(bHasDefaultValue_ = !convertValue<orxonox::ColourValue, T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
    126         inline bool setValue(const orxonox::Quaternion& value)  { return !(bHasDefaultValue_ = !convertValue<orxonox::Quaternion , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
    127         inline bool setValue(const orxonox::Radian& value)      { return !(bHasDefaultValue_ = !convertValue<orxonox::Radian     , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
    128         inline bool setValue(const orxonox::Degree& value)      { return !(bHasDefaultValue_ = !convertValue<orxonox::Degree     , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
    129 
    130         inline operator char()                 const { return getConvertedValue<T, char>                (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
    131         inline operator unsigned char()        const { return getConvertedValue<T, unsigned char>       (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
    132         inline operator short()                const { return getConvertedValue<T, short>               (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
    133         inline operator unsigned short()       const { return getConvertedValue<T, unsigned short>      (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
    134         inline operator int()                  const { return getConvertedValue<T, int>                 (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
    135         inline operator unsigned int()         const { return getConvertedValue<T, unsigned int>        (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
    136         inline operator long()                 const { return getConvertedValue<T, long>                (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
    137         inline operator unsigned long()        const { return getConvertedValue<T, unsigned long>       (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
    138         inline operator long long()            const { return getConvertedValue<T, long long>           (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
    139         inline operator unsigned long long()   const { return getConvertedValue<T, unsigned long long>  (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
    140         inline operator float()                const { return getConvertedValue<T, float>               (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
    141         inline operator double()               const { return getConvertedValue<T, double>              (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
    142         inline operator long double()          const { return getConvertedValue<T, long double>         (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
    143         inline operator bool()                 const { return getConvertedValue<T, bool>                (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
    144         inline operator void*()                const { return getConvertedValue<T, void*>               (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
    145         inline operator std::string()          const { return getConvertedValue<T, std::string>         (this->value_, NilValue<std::string         >()); } ///< Returns the current value, converted to the requested type.
    146         inline operator orxonox::Vector2()     const { return getConvertedValue<T, orxonox::Vector2>    (this->value_, NilValue<orxonox::Vector2    >()); } ///< Returns the current value, converted to the requested type.
    147         inline operator orxonox::Vector3()     const { return getConvertedValue<T, orxonox::Vector3>    (this->value_, NilValue<orxonox::Vector3    >()); } ///< Returns the current value, converted to the requested type.
    148         inline operator orxonox::Vector4()     const { return getConvertedValue<T, orxonox::Vector4>    (this->value_, NilValue<orxonox::Vector4    >()); } ///< Returns the current value, converted to the requested type.
    149         inline operator orxonox::ColourValue() const { return getConvertedValue<T, orxonox::ColourValue>(this->value_, NilValue<orxonox::ColourValue>()); } ///< Returns the current value, converted to the requested type.
    150         inline operator orxonox::Quaternion()  const { return getConvertedValue<T, orxonox::Quaternion> (this->value_, NilValue<orxonox::Quaternion >()); } ///< Returns the current value, converted to the requested type.
    151         inline operator orxonox::Radian()      const { return getConvertedValue<T, orxonox::Radian>     (this->value_, NilValue<orxonox::Radian     >()); } ///< Returns the current value, converted to the requested type.
    152         inline operator orxonox::Degree()      const { return getConvertedValue<T, orxonox::Degree>     (this->value_, NilValue<orxonox::Degree     >()); } ///< Returns the current value, converted to the requested type.
     80        inline bool getValue(std::string*          value) const { return convertValue<T, std::string         >(value, value_, NilValue<std::string>         ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     81        inline bool getValue(orxonox::Vector2*     value) const { return convertValue<T, orxonox::Vector2    >(value, value_, NilValue<orxonox::Vector2>    ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     82        inline bool getValue(orxonox::Vector3*     value) const { return convertValue<T, orxonox::Vector3    >(value, value_, NilValue<orxonox::Vector3>    ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     83        inline bool getValue(orxonox::Vector4*     value) const { return convertValue<T, orxonox::Vector4    >(value, value_, NilValue<orxonox::Vector4>    ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     84        inline bool getValue(orxonox::ColourValue* value) const { return convertValue<T, orxonox::ColourValue>(value, value_, NilValue<orxonox::ColourValue>()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     85        inline bool getValue(orxonox::Quaternion*  value) const { return convertValue<T, orxonox::Quaternion >(value, value_, NilValue<orxonox::Quaternion> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     86        inline bool getValue(orxonox::Radian*      value) const { return convertValue<T, orxonox::Radian     >(value, value_, NilValue<orxonox::Radian>     ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     87        inline bool getValue(orxonox::Degree*      value) const { return convertValue<T, orxonox::Degree     >(value, value_, NilValue<orxonox::Degree>     ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     88
     89        /**
     90            @brief Assigns the value of the other MultiType, converted to T.
     91            @param other The other MultiType
     92        */
     93        inline bool setValue(const MultiType& other)
     94        {
     95            if (other.value_)
     96            {
     97                return !(bHasDefaultValue_ = !other.value_->getValue(&value_));
     98            }
     99            else
     100            {
     101                this->value_ = zeroise<T>();
     102                return !(bHasDefaultValue_ = true);
     103            }
     104        }
     105
     106        inline bool setValue(const char& value)                 { return !(bHasDefaultValue_ = !convertValue<char                , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
     107        inline bool setValue(const unsigned char& value)        { return !(bHasDefaultValue_ = !convertValue<unsigned char       , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
     108        inline bool setValue(const short& value)                { return !(bHasDefaultValue_ = !convertValue<short               , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
     109        inline bool setValue(const unsigned short& value)       { return !(bHasDefaultValue_ = !convertValue<unsigned short      , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
     110        inline bool setValue(const int& value)                  { return !(bHasDefaultValue_ = !convertValue<int                 , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
     111        inline bool setValue(const unsigned int& value)         { return !(bHasDefaultValue_ = !convertValue<unsigned int        , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
     112        inline bool setValue(const long& value)                 { return !(bHasDefaultValue_ = !convertValue<long                , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
     113        inline bool setValue(const unsigned long& value)        { return !(bHasDefaultValue_ = !convertValue<unsigned long       , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
     114        inline bool setValue(const long long& value)            { return !(bHasDefaultValue_ = !convertValue<long long           , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
     115        inline bool setValue(const unsigned long long& value)   { return !(bHasDefaultValue_ = !convertValue<unsigned long long  , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
     116        inline bool setValue(const float& value)                { return !(bHasDefaultValue_ = !convertValue<float               , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
     117        inline bool setValue(const double& value)               { return !(bHasDefaultValue_ = !convertValue<double              , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
     118        inline bool setValue(const long double& value)          { return !(bHasDefaultValue_ = !convertValue<long double         , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
     119        inline bool setValue(const bool& value)                 { return !(bHasDefaultValue_ = !convertValue<bool                , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
     120        inline bool setValue(      void* const& value)          { return !(bHasDefaultValue_ = !convertValue<void*               , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
     121        inline bool setValue(const std::string& value)          { return !(bHasDefaultValue_ = !convertValue<std::string         , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
     122        inline bool setValue(const orxonox::Vector2& value)     { return !(bHasDefaultValue_ = !convertValue<orxonox::Vector2    , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
     123        inline bool setValue(const orxonox::Vector3& value)     { return !(bHasDefaultValue_ = !convertValue<orxonox::Vector3    , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
     124        inline bool setValue(const orxonox::Vector4& value)     { return !(bHasDefaultValue_ = !convertValue<orxonox::Vector4    , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
     125        inline bool setValue(const orxonox::ColourValue& value) { return !(bHasDefaultValue_ = !convertValue<orxonox::ColourValue, T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
     126        inline bool setValue(const orxonox::Quaternion& value)  { return !(bHasDefaultValue_ = !convertValue<orxonox::Quaternion , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
     127        inline bool setValue(const orxonox::Radian& value)      { return !(bHasDefaultValue_ = !convertValue<orxonox::Radian     , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
     128        inline bool setValue(const orxonox::Degree& value)      { return !(bHasDefaultValue_ = !convertValue<orxonox::Degree     , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
    153129
    154130        /// Puts the current value on the stream
  • code/branches/testing/src/orxonox/graphics/ParticleEmitter.cc

    r8858 r9225  
    7171        SUPER(ParticleEmitter, XMLPort, xmlelement, mode);
    7272
    73         XMLPortParam(ParticleEmitter, "lod",    setLODxml, getLODxml, xmlelement, mode).defaultValues(LODParticle::Normal);
     73        XMLPortParam(ParticleEmitter, "lod",    setLODxml, getLODxml, xmlelement, mode).defaultValues(static_cast<unsigned int>(LODParticle::Normal));
    7474        XMLPortParam(ParticleEmitter, "source", setSource, getSource, xmlelement, mode);
    7575    }
Note: See TracChangeset for help on using the changeset viewer.