[Orxonox-commit 4554] r9225 - in code/branches/testing: src/libraries/core/command src/libraries/util src/orxonox/graphics test/util

landauf at orxonox.net landauf at orxonox.net
Sat May 19 23:24:18 CEST 2012


Author: landauf
Date: 2012-05-19 23:24:18 +0200 (Sat, 19 May 2012)
New Revision: 9225

Modified:
   code/branches/testing/src/libraries/core/command/Shell.cc
   code/branches/testing/src/libraries/util/MultiType.cc
   code/branches/testing/src/libraries/util/MultiType.h
   code/branches/testing/src/libraries/util/MultiTypeValue.h
   code/branches/testing/src/orxonox/graphics/ParticleEmitter.cc
   code/branches/testing/test/util/MultiTypeTest.cc
Log:
a lot of refactoring in the internals of MultiType
renamed set<T>() to force<T>() (forces the MultiType to switch its type to T)

Modified: code/branches/testing/src/libraries/core/command/Shell.cc
===================================================================
--- code/branches/testing/src/libraries/core/command/Shell.cc	2012-05-19 13:03:02 UTC (rev 9224)
+++ code/branches/testing/src/libraries/core/command/Shell.cc	2012-05-19 21:24:18 UTC (rev 9225)
@@ -169,7 +169,7 @@
         else
         {
             OutputLevel level = (value ? DefaultLogLevel::Dev : DefaultLogLevel::User);
-            ModifyConfigValueExternal(this->configurableMaxLevel_, this->getConfigurableMaxLevelName(), tset, level);
+            ModifyConfigValueExternal(this->configurableMaxLevel_, this->getConfigurableMaxLevelName(), tset, static_cast<int>(level));
         }
     }
 

Modified: code/branches/testing/src/libraries/util/MultiType.cc
===================================================================
--- code/branches/testing/src/libraries/util/MultiType.cc	2012-05-19 13:03:02 UTC (rev 9224)
+++ code/branches/testing/src/libraries/util/MultiType.cc	2012-05-19 21:24:18 UTC (rev 9225)
@@ -160,51 +160,27 @@
         };
     }
 
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
+    template <> void MultiType::createNewValueContainer(const char& value)                 { this->value_ = new MT_Value<char>                (value, Type::Char            ); }
+    template <> void MultiType::createNewValueContainer(const unsigned char& value)        { this->value_ = new MT_Value<unsigned char>       (value, Type::UnsignedChar    ); }
+    template <> void MultiType::createNewValueContainer(const short& value)                { this->value_ = new MT_Value<short>               (value, Type::Short           ); }
+    template <> void MultiType::createNewValueContainer(const unsigned short& value)       { this->value_ = new MT_Value<unsigned short>      (value, Type::UnsignedShort   ); }
+    template <> void MultiType::createNewValueContainer(const int& value)                  { this->value_ = new MT_Value<int>                 (value, Type::Int             ); }
+    template <> void MultiType::createNewValueContainer(const unsigned int& value)         { this->value_ = new MT_Value<unsigned int>        (value, Type::UnsignedInt     ); }
+    template <> void MultiType::createNewValueContainer(const long& value)                 { this->value_ = new MT_Value<long>                (value, Type::Long            ); }
+    template <> void MultiType::createNewValueContainer(const unsigned long& value)        { this->value_ = new MT_Value<unsigned long>       (value, Type::UnsignedLong    ); }
+    template <> void MultiType::createNewValueContainer(const long long& value)            { this->value_ = new MT_Value<long long>           (value, Type::LongLong        ); }
+    template <> void MultiType::createNewValueContainer(const unsigned long long& value)   { this->value_ = new MT_Value<unsigned long long>  (value, Type::UnsignedLongLong); }
+    template <> void MultiType::createNewValueContainer(const float& value)                { this->value_ = new MT_Value<float>               (value, Type::Float           ); }
+    template <> void MultiType::createNewValueContainer(const double& value)               { this->value_ = new MT_Value<double>              (value, Type::Double          ); }
+    template <> void MultiType::createNewValueContainer(const long double& value)          { this->value_ = new MT_Value<long double>         (value, Type::LongDouble      ); }
+    template <> void MultiType::createNewValueContainer(const bool& value)                 { this->value_ = new MT_Value<bool>                (value, Type::Bool            ); }
+    template <> void MultiType::createNewValueContainer(      void* const& value)          { this->value_ = new MT_Value<void*>               (value, Type::VoidPointer     ); }
+    template <> void MultiType::createNewValueContainer(const std::string& value)          { this->value_ = new MT_Value<std::string>         (value, Type::String          ); }
+    template <> void MultiType::createNewValueContainer(const orxonox::Vector2& value)     { this->value_ = new MT_Value<orxonox::Vector2>    (value, Type::Vector2         ); }
+    template <> void MultiType::createNewValueContainer(const orxonox::Vector3& value)     { this->value_ = new MT_Value<orxonox::Vector3>    (value, Type::Vector3         ); }
+    template <> void MultiType::createNewValueContainer(const orxonox::Vector4& value)     { this->value_ = new MT_Value<orxonox::Vector4>    (value, Type::Vector4         ); }
+    template <> void MultiType::createNewValueContainer(const orxonox::ColourValue& value) { this->value_ = new MT_Value<orxonox::ColourValue>(value, Type::ColourValue     ); }
+    template <> void MultiType::createNewValueContainer(const orxonox::Quaternion& value)  { this->value_ = new MT_Value<orxonox::Quaternion> (value, Type::Quaternion      ); }
+    template <> void MultiType::createNewValueContainer(const orxonox::Radian& value)      { this->value_ = new MT_Value<orxonox::Radian>     (value, Type::Radian          ); }
+    template <> void MultiType::createNewValueContainer(const orxonox::Degree& value)      { this->value_ = new MT_Value<orxonox::Degree>     (value, Type::Degree          ); }
 }

Modified: code/branches/testing/src/libraries/util/MultiType.h
===================================================================
--- code/branches/testing/src/libraries/util/MultiType.h	2012-05-19 13:03:02 UTC (rev 9224)
+++ code/branches/testing/src/libraries/util/MultiType.h	2012-05-19 21:24:18 UTC (rev 9225)
@@ -50,7 +50,7 @@
     The MultiType has an internal "type" determined by the first assigned value, using one of these ways:
      - @ref orxonox::MultiType::MultiType "The constructor"
      - The assignment operator= (orxonox::MultiType::operator=())
-     - @ref orxonox::MultiType::setValue() "setValue(value)"
+     - @ref orxonox::MultiType::set() "set(value)"
 
     If you assign another value of another type, the MultiType keeps "its" type and
     converts the new value to the old type.
@@ -58,15 +58,15 @@
     If you want to change the type, there are three possibilities:
      - @ref orxonox::MultiType::convert "convert<T>()" sets the type to T and converts the currently assigned value
      - @ref orxonox::MultiType::reset "reset<T>()" sets the type to T and resets the value to zero using zeroise<T>()
-     - setValue<T>(value) assigns a new value and changes the type to T.
+     - force<T>(value) assigns a new value and changes the type to T.
 
     Examples:
     @code
-    MultiType a = 10;          // a has now the type int and the value 10
-    a.setValue("3.14");        // a has still the type int and "3.14" gets converted, therefore the value is now 3
-    a.setValue<float>("3.14"); // a has now the type float and "3.14" gets converted to 3.14f
-    a.convert<bool>();         // converts 3.14f to bool, which is true
-    a = false;                 // assigns false, this is equivalent to a.setValue(false)
+    MultiType a = 10;       // a has now the type int and the value 10
+    a.set("3.14");          // a has still the type int and "3.14" gets converted, therefore the value is now 3
+    a.force<float>("3.14"); // a has now the type float and "3.14" gets converted to 3.14f
+    a.convert<bool>();      // converts 3.14f to bool, which is true
+    a = false;              // assigns false, this is equivalent to a.setValue(false)
     @endcode
 
     You can pass a MultiType to a function as an argument, even if the argument is
@@ -105,6 +105,7 @@
 #include <OgreQuaternion.h>
 #include <OgreColourValue.h>
 #include <loki/TypeTraits.h>
+#include "Math.h"
 #include "mbool.h"
 
 namespace orxonox
@@ -172,16 +173,17 @@
         class _UtilExport MT_ValueBase
         {
         public:
-            MT_ValueBase(Type::Enum type) : type_(type), bHasDefaultValue_(false) {}
+            MT_ValueBase(void* data, Type::Enum type) : type_(type), bHasDefaultValue_(false), data_(data) {}
             virtual ~MT_ValueBase() {}
 
             virtual MT_ValueBase* clone() const = 0;
 
             virtual void reset() = 0;
-            virtual bool assimilate(const MultiType& other) = 0;
 
             /// Returns the type of the current value.
             const Type::Enum& getType() const { return this->type_; }
+            /// Returns true if the type of the stored value is T.
+            template <typename T> inline bool isType() const { return false; }
 
             /// Checks whether the value is a default one.
             bool hasDefaultValue()   const { return this->bHasDefaultValue_; }
@@ -210,6 +212,8 @@
             virtual bool setValue(const orxonox::Radian& value)      = 0;
             virtual bool setValue(const orxonox::Degree& value)      = 0;
 
+            virtual bool setValue(const MultiType& other)            = 0;
+
             virtual bool getValue(char*                 value) const = 0;
             virtual bool getValue(unsigned char*        value) const = 0;
             virtual bool getValue(short*                value) const = 0;
@@ -234,29 +238,17 @@
             virtual bool getValue(orxonox::Radian*      value) const = 0;
             virtual bool getValue(orxonox::Degree*      value) const = 0;
 
-            virtual operator char()                 const = 0;
-            virtual operator unsigned char()        const = 0;
-            virtual operator short()                const = 0;
-            virtual operator unsigned short()       const = 0;
-            virtual operator int()                  const = 0;
-            virtual operator unsigned int()         const = 0;
-            virtual operator long()                 const = 0;
-            virtual operator unsigned long()        const = 0;
-            virtual operator long long()            const = 0;
-            virtual operator unsigned long long()   const = 0;
-            virtual operator float()                const = 0;
-            virtual operator double()               const = 0;
-            virtual operator long double()          const = 0;
-            virtual operator bool()                 const = 0;
-            virtual operator void*()                const = 0;
-            virtual operator std::string()          const = 0;
-            virtual operator orxonox::Vector2()     const = 0;
-            virtual operator orxonox::Vector3()     const = 0;
-            virtual operator orxonox::Vector4()     const = 0;
-            virtual operator orxonox::ColourValue() const = 0;
-            virtual operator orxonox::Quaternion()  const = 0;
-            virtual operator orxonox::Radian()      const = 0;
-            virtual operator orxonox::Degree()      const = 0;
+            template <typename T> T get() const
+            {
+                if (this->isType<T>())
+                    return *reinterpret_cast<const T*>(this->data_);
+                else
+                {
+                    T value;
+                    this->getValue(&value);
+                    return value;
+                }
+            }
 
             virtual void toString(std::ostream& outstream) const = 0;
 
@@ -266,260 +258,241 @@
 
             Type::Enum type_;       ///< The type of the current value
             bool bHasDefaultValue_; ///< True if the last conversion wasn't successful
+            void* data_;            ///< For direct access to the value if the type is known
         };
 
         public:
             static const MultiType Null;
 
-            inline MultiType()                                  : value_(0) {}                                      ///< Default constructor: Assigns no value and no type. The type will be determined by the first assignment of a value.
-            inline MultiType(const char& value)                 : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
-            inline MultiType(const unsigned char& value)        : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
-            inline MultiType(const short& value)                : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
-            inline MultiType(const unsigned short& value)       : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
-            inline MultiType(const int& value)                  : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
-            inline MultiType(const unsigned int& value)         : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
-            inline MultiType(const long& value)                 : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
-            inline MultiType(const unsigned long& value)        : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
-            inline MultiType(const long long& value)            : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
-            inline MultiType(const unsigned long long& value)   : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
-            inline MultiType(const float& value)                : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
-            inline MultiType(const double& value)               : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
-            inline MultiType(const long double& value)          : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
-            inline MultiType(const bool& value)                 : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
-            inline MultiType(      void* const& value)          : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
-            inline MultiType(const std::string& value)          : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
-            inline MultiType(const orxonox::Vector2& value)     : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
-            inline MultiType(const orxonox::Vector3& value)     : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
-            inline MultiType(const orxonox::Vector4& value)     : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
-            inline MultiType(const orxonox::ColourValue& value) : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
-            inline MultiType(const orxonox::Quaternion& value)  : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
-            inline MultiType(const orxonox::Radian& value)      : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
-            inline MultiType(const orxonox::Degree& value)      : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
-            inline MultiType(const orxonox::mbool& value)       : value_(0) { this->assignValue((bool)value); }     ///< Constructor: Assigns the given mbool and converts it to bool.
-            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.
-            inline MultiType(const MultiType& other)            : value_(0) { this->set(other); }                   ///< Copyconstructor: Assigns value and type of the other MultiType.
+            /// Default constructor: Assigns no value and no type. The type will be determined by the first assignment of a value.
+            inline MultiType()                       : value_(0) { }
+            /// Constructor: Assigns the given value and sets the type.
+            template <typename V>
+            inline MultiType(const V& value)         : value_(0) { this->set(value); }
+            /// Copyconstructor: Assigns value and type of the other MultiType.
+            inline MultiType(const MultiType& other) : value_(0) { this->set(other); }
 
             /// Destructor: Deletes the MT_Value.
             inline ~MultiType() { if (this->value_) { delete this->value_; } }
 
-            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.
-            template <typename V> inline MultiType& operator=(V* value)               { this->set(value); return (*this); } ///< Assigns a pointer.
-            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.
+            /// Assigns a new value. The value will be converted to the current type of the MultiType.
+            template <typename V> inline MultiType& operator=(const V& value)         { this->set(value); return (*this); }
+            /// Assigns a pointer.
+            template <typename V> inline MultiType& operator=(V* value)               { this->set(value); return (*this); }
+            /// Assigns the value of the other MultiType and converts it to the current type of the MultiType.
+            inline                       MultiType& operator=(const MultiType& other) { this->set(other); return (*this); }
 
-            inline bool                                   set(const char& value);
-            inline bool                                   set(const unsigned char& value);
-            inline bool                                   set(const short& value);
-            inline bool                                   set(const unsigned short& value);
-            inline bool                                   set(const int& value);
-            inline bool                                   set(const unsigned int& value);
-            inline bool                                   set(const long& value);
-            inline bool                                   set(const unsigned long& value);
-            inline bool                                   set(const long long& value);
-            inline bool                                   set(const unsigned long long& value);
-            inline bool                                   set(const float& value);
-            inline bool                                   set(const double& value);
-            inline bool                                   set(const long double& value);
-            inline bool                                   set(const bool& value);
-            inline bool                                   set(      void* const& value);
-            inline bool                                   set(const std::string& value);
-            inline bool                                   set(const orxonox::Vector2& value);
-            inline bool                                   set(const orxonox::Vector3& value);
-            inline bool                                   set(const orxonox::Vector4& value);
-            inline bool                                   set(const orxonox::ColourValue& value);
-            inline bool                                   set(const orxonox::Quaternion& value);
-            inline bool                                   set(const orxonox::Radian& value);
-            inline bool                                   set(const orxonox::Degree& value);
-            inline bool                                   set(const char* value);
+            /// Assigns the given value and converts it to the current type.
+            template <typename V> inline bool set(const V& value)
+            {
+                if (this->value_)
+                    return this->value_->setValue(value);
+
+                this->assignValue(value);
+                return true;
+            }
             /// Assigns a pointer.
             template <typename V> inline bool set(V* value)
             {
                 if (this->value_)
                     return this->value_->setValue(static_cast<void*>(const_cast<typename Loki::TypeTraits<V>::UnqualifiedType*>(value)));
-                else
-                    return this->assignValue     (static_cast<void*>(const_cast<typename Loki::TypeTraits<V>::UnqualifiedType*>(value)));
+
+                this->assignValue(static_cast<void*>(const_cast<typename Loki::TypeTraits<V>::UnqualifiedType*>(value)));
+                return true;
             }
-            /// Changes the type to T and assigns the new value (which might be of another type than T - it gets converted).
-            template <typename T, typename V> inline bool set(const V& value) { this->reset<T>(); return this->set(value); }
             /// Assigns the value of the other MultiType and converts it to the current type.
-            bool                                          set(const MultiType& other) { if (this->value_) { return this->value_->assimilate(other); } else { if (other.value_) { this->value_ = other.value_->clone(); } return true; } }
+            inline bool set(const MultiType& other)
+            {
+                if (this->value_)
+                    return this->value_->setValue(other);
+                else if (other.value_)
+                    this->value_ = other.value_->clone();
+                return true;
+            }
 
+            /// Changes the type to T and assigns the new value (which might be of another type than T - it gets converted).
+            template <typename T, typename V> inline bool force(const V& value)
+            {
+                this->reset<T>();
+                return this->set(value);
+            }
+
             /// Copies the other MultiType by assigning value and type.
-            inline void                       copy(const MultiType& other) { if (this == &other) { return; } if (this->value_) { delete this->value_; } this->value_ = (other.value_) ? other.value_->clone() : 0; }
+            inline void copy(const MultiType& other)
+            {
+                if (this == &other)
+                    return;
+                if (this->value_)
+                    delete this->value_;
+                this->value_ = (other.value_) ? other.value_->clone() : 0;
+            }
 
             /// Converts the current value to type T.
-            template <typename T> inline bool convert()                    { return this->set<T>((typename Loki::TypeTraits<T>::UnqualifiedReferredType)(*this));  }
+            template <typename T> inline bool convert() { return this->force<T>(this->get<typename Loki::TypeTraits<T>::UnqualifiedReferredType>()); }
 
             /// Resets value and type. Type will be void afterwards and null() returns true.
-            inline void                       reset()                      { if (this->value_) delete this->value_; this->value_ = 0; }
+            inline void reset() { if (this->value_) delete this->value_; this->value_ = 0; }
             /// Resets the value and changes the internal type to T.
-            template <typename T> inline void reset()                      { this->assignValue(typename Loki::TypeTraits<T>::UnqualifiedReferredType()); }
+            template <typename T> inline void reset() { this->assignValue(typename Loki::TypeTraits<T>::UnqualifiedReferredType()); }
             /// Current value gets overridden with default zero value
-            inline void                       resetValue()                 { if (this->value_) this->value_->reset(); }
+            inline void resetValue() { if (this->value_) this->value_->reset(); }
 
-            /// Returns true if the current type is T.
-            template <typename T> inline bool isType()               const { return false; } // Only works for specialized values - see below
-            std::string                       getTypename()          const;
+            /// Returns true if the type of the current value is T.
+            template <typename T> inline bool isType() const { return (this->value_ ? this->value_->isType<T>() : false); }
+            std::string getTypename() const;
 
-            /// Saves the value of the MT to a bytestream (pointed at by mem) and increases mem pointer by size of MT
-            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); }
-            /// Loads the value of the MT from a bytestream (pointed at by mem) and increases mem pointer by size of MT
-            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); }
-            /// Saves the value of the MT to a bytestream and increases pointer to bytestream by size of MT
-            inline uint8_t*&                  operator << (uint8_t*& mem) { importData(mem); return mem; }
-            /// Loads the value of the MT to a bytestream and increases pointer to bytestream by size of MT
-            inline void                       operator >> (uint8_t*& mem) const { exportData(mem); }
-            inline uint32_t                   getNetworkSize() const { assert(this->value_); return this->value_->getSize() + sizeof(uint8_t); }
-
             /// Checks whether the value is a default one (assigned after a failed conversion)
-            bool                              hasDefaultValue() const { return this->value_->hasDefaultValue(); }
+            inline bool hasDefaultValue() const { return this->value_->hasDefaultValue(); }
 
             /// Checks if the MT contains no value.
-            bool                              null() const { return !this->value_; }
+            inline bool null() const { return !this->value_; }
 
-            operator char()                  const;
-            operator unsigned char()         const;
-            operator short()                 const;
-            operator unsigned short()        const;
-            operator int()                   const;
-            operator unsigned int()          const;
-            operator long()                  const;
-            operator unsigned long()         const;
-            operator long long()             const;
-            operator unsigned long long()    const;
-            operator float()                 const;
-            operator double()                const;
-            operator long double()           const;
-            operator bool()                  const;
-            operator void*()                 const;
-            operator std::string()           const;
-            operator orxonox::Vector2()      const;
-            operator orxonox::Vector3()      const;
-            operator orxonox::Vector4()      const;
-            operator orxonox::ColourValue()  const;
-            operator orxonox::Quaternion()   const;
-            operator orxonox::Radian()       const;
-            operator orxonox::Degree()       const;
+            inline operator char()                 const { return (this->value_ ? this->value_->get<char>()                 : 0); }
+            inline operator unsigned char()        const { return (this->value_ ? this->value_->get<unsigned char>()        : 0); }
+            inline operator short()                const { return (this->value_ ? this->value_->get<short>()                : 0); }
+            inline operator unsigned short()       const { return (this->value_ ? this->value_->get<unsigned short>()       : 0); }
+            inline operator int()                  const { return (this->value_ ? this->value_->get<int>()                  : 0); }
+            inline operator unsigned int()         const { return (this->value_ ? this->value_->get<unsigned int>()         : 0); }
+            inline operator long()                 const { return (this->value_ ? this->value_->get<long>()                 : 0); }
+            inline operator unsigned long()        const { return (this->value_ ? this->value_->get<unsigned long>()        : 0); }
+            inline operator long long()            const { return (this->value_ ? this->value_->get<long long>()            : 0); }
+            inline operator unsigned long long()   const { return (this->value_ ? this->value_->get<unsigned long long>()   : 0); }
+            inline operator float()                const { return (this->value_ ? this->value_->get<float>()                : 0); }
+            inline operator double()               const { return (this->value_ ? this->value_->get<double>()               : 0); }
+            inline operator long double()          const { return (this->value_ ? this->value_->get<long double>()          : 0); }
+            inline operator bool()                 const { return (this->value_ ? this->value_->get<bool>()                 : 0); }
+            inline operator void*()                const { return (this->value_ ? this->value_->get<void*>()                : 0); }
+            inline operator std::string()          const { return (this->value_ ? this->value_->get<std::string>()          : NilValue<std::string>()); }
+            inline operator orxonox::Vector2()     const { return (this->value_ ? this->value_->get<orxonox::Vector2>()     : NilValue<orxonox::Vector2>()); }
+            inline operator orxonox::Vector3()     const { return (this->value_ ? this->value_->get<orxonox::Vector3>()     : NilValue<orxonox::Vector3>()); }
+            inline operator orxonox::Vector4()     const { return (this->value_ ? this->value_->get<orxonox::Vector4>()     : NilValue<orxonox::Vector4>()); }
+            inline operator orxonox::ColourValue() const { return (this->value_ ? this->value_->get<orxonox::ColourValue>() : NilValue<orxonox::ColourValue>()); }
+            inline operator orxonox::Quaternion()  const { return (this->value_ ? this->value_->get<orxonox::Quaternion>()  : NilValue<orxonox::Quaternion>()); }
+            inline operator orxonox::Radian()      const { return (this->value_ ? this->value_->get<orxonox::Radian>()      : NilValue<orxonox::Radian>()); }
+            inline operator orxonox::Degree()      const { return (this->value_ ? this->value_->get<orxonox::Degree>()      : NilValue<orxonox::Degree>()); }
             /// Returns the current value, converted to a T* pointer.
             template <class T> operator T*() const { return (static_cast<T*>(this->operator void*())); }
 
-            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.
-            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.
-            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.
-            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.
-            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.
-            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.
-            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.
-            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.
-            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.
-            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.
-            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.
-            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.
-            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.
-            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.
-            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.
-            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.
-            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.
-            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.
-            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.
-            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.
-            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.
-            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.
-            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.
+            /// Assigns the value to the given pointer. The value gets converted if the types don't match.
+            template <typename T> inline bool getValue(T* value) const { if (this->value_) { return this->value_->getValue(value); } return false; }
 
             /// Returns the current value, converted to the requested type.
-            template <typename T> inline T get() const { return T(); }
+            template <typename T> inline T get() const { return *this; }
 
+
+            ///////////////////////////////
+            // network-related functions //
+            ///////////////////////////////
+            /// Saves the value of the MT to a bytestream (pointed at by mem) and increases mem pointer by size of MT
+            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);
+            }
+            /// Loads the value of the MT from a bytestream (pointed at by mem) and increases mem pointer by size of MT
+            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);
+            }
+            /// Saves the value of the MT to a bytestream and increases pointer to bytestream by size of MT
+            inline uint8_t*& operator<<(uint8_t*& mem)
+            {
+                importData(mem);
+                return mem;
+            }
+            /// Loads the value of the MT to a bytestream and increases pointer to bytestream by size of MT
+            inline void operator>>(uint8_t*& mem) const
+            {
+                exportData(mem);
+            }
+            inline uint32_t getNetworkSize() const
+            {
+                assert(this->value_);
+                return this->value_->getSize() + sizeof(uint8_t);
+            }
+
         private:
-            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.
-            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.
-            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.
-            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.
-            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.
-            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.
-            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.
-            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.
-            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.
-            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.
-            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.
-            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.
-            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.
-            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.
-            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.
-            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.
-            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.
-            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.
-            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.
-            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.
-            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.
-            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.
-            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.
+            /// Assigns a new value by changing type and creating a new container.
+            template <typename T> inline void assignValue(const T& value)
+            {
+                if (this->isType<T>())
+                    this->value_->setValue(value);
+                else
+                    this->changeValueContainer(value);
+            }
+            /// Assigns a new value by changing type and creating a new container (overload for pointers).
+            template <typename T> inline void assignValue(T* const& value)
+            {
+                if (this->isType<void*>())
+                    this->value_->setValue(static_cast<void*>(value));
+                else
+                    this->changeValueContainer<void*>(value);
+            }
 
             /// Resets the value and changes the internal type to the given type.
-            inline void       setType(Type::Enum type) { this->reset(); this->convert(type); this->resetValue(); }
+            inline void setType(Type::Enum type) { this->reset(); this->convert(type); this->resetValue(); }
             /// Returns the current type.
-            inline Type::Enum getType()          const { return (this->value_) ? this->value_->type_ : Type::Null; }
+            inline Type::Enum getType() const { return (this->value_) ? this->value_->type_ : Type::Null; }
             /// Converts the current value to the given type.
-            bool              convert(Type::Enum type);
+            bool convert(Type::Enum type);
 
             /// Changes the value container.
-            template <typename T> inline void changeValueContainer(const T& value) { if (this->value_) { delete this->value_; } this->createNewValueContainer<T>(value); }
+            template <typename T> inline void changeValueContainer(const T& value)
+            {
+                if (this->value_)
+                    delete this->value_;
+                this->createNewValueContainer(value);
+            }
             /// Creates a new value container (works only with specialized types).
-            template <typename T>        void createNewValueContainer(const T& value) { /* STATIC ASSERT */ *****value; return false; }
+            template <typename T> inline void createNewValueContainer(const T& value) { /* STATIC ASSERT */ *****value; return false; }
 
             MT_ValueBase* value_; //!< A pointer to the value container
     };
 
     /// Puts the MultiType on a stream by using the native << operator of the current type.
-    _UtilExport inline std::ostream& operator<<(std::ostream& outstream, const MultiType& mt) { if (mt.value_) { mt.value_->toString(outstream); } return outstream; }
+    _UtilExport inline std::ostream& operator<<(std::ostream& outstream, const MultiType& mt)
+    {
+        if (mt.value_)
+            mt.value_->toString(outstream);
+        return outstream;
+    }
 
-    template <> inline bool MultiType::isType<void>()                 const { return this->null();                                                    } ///< Returns true if the current type equals the given type.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
+    template <> inline bool MultiType::MT_ValueBase::isType<char>()                 const { return this->type_ == Type::Char;             }
+    template <> inline bool MultiType::MT_ValueBase::isType<unsigned char>()        const { return this->type_ == Type::UnsignedChar;     }
+    template <> inline bool MultiType::MT_ValueBase::isType<short>()                const { return this->type_ == Type::Short;            }
+    template <> inline bool MultiType::MT_ValueBase::isType<unsigned short>()       const { return this->type_ == Type::UnsignedShort;    }
+    template <> inline bool MultiType::MT_ValueBase::isType<int>()                  const { return this->type_ == Type::Int;              }
+    template <> inline bool MultiType::MT_ValueBase::isType<unsigned int>()         const { return this->type_ == Type::UnsignedInt;      }
+    template <> inline bool MultiType::MT_ValueBase::isType<long>()                 const { return this->type_ == Type::Long;             }
+    template <> inline bool MultiType::MT_ValueBase::isType<unsigned long>()        const { return this->type_ == Type::UnsignedLong;     }
+    template <> inline bool MultiType::MT_ValueBase::isType<long long>()            const { return this->type_ == Type::LongLong;         }
+    template <> inline bool MultiType::MT_ValueBase::isType<unsigned long long>()   const { return this->type_ == Type::UnsignedLongLong; }
+    template <> inline bool MultiType::MT_ValueBase::isType<float>()                const { return this->type_ == Type::Float;            }
+    template <> inline bool MultiType::MT_ValueBase::isType<double>()               const { return this->type_ == Type::Double;           }
+    template <> inline bool MultiType::MT_ValueBase::isType<long double>()          const { return this->type_ == Type::LongDouble;       }
+    template <> inline bool MultiType::MT_ValueBase::isType<bool>()                 const { return this->type_ == Type::Bool;             }
+    template <> inline bool MultiType::MT_ValueBase::isType<void*>()                const { return this->type_ == Type::VoidPointer;      }
+    template <> inline bool MultiType::MT_ValueBase::isType<std::string>()          const { return this->type_ == Type::String;           }
+    template <> inline bool MultiType::MT_ValueBase::isType<orxonox::Vector2>()     const { return this->type_ == Type::Vector2;          }
+    template <> inline bool MultiType::MT_ValueBase::isType<orxonox::Vector3>()     const { return this->type_ == Type::Vector3;          }
+    template <> inline bool MultiType::MT_ValueBase::isType<orxonox::Vector4>()     const { return this->type_ == Type::Vector4;          }
+    template <> inline bool MultiType::MT_ValueBase::isType<orxonox::ColourValue>() const { return this->type_ == Type::ColourValue;      }
+    template <> inline bool MultiType::MT_ValueBase::isType<orxonox::Quaternion>()  const { return this->type_ == Type::Quaternion;       }
+    template <> inline bool MultiType::MT_ValueBase::isType<orxonox::Radian>()      const { return this->type_ == Type::Radian;           }
+    template <> inline bool MultiType::MT_ValueBase::isType<orxonox::Degree>()      const { return this->type_ == Type::Degree;           }
 
-    /// Deletes the content, type becomes void.
-    template <> inline bool MultiType::convert<void>()                 { this->reset(); return true; }
+    template <> inline bool MultiType::set(const char* value)  { return this->set(std::string(value)); }
+    template <> inline bool MultiType::set(const mbool& value) { return this->set((bool)value); }
 
-    // Specialization to avoid ambiguities with the conversion operator
-    template <> inline bool MultiType::convert<std::string>()          { return this->set<std::string>         (this->operator std::string());          } ///< Converts the current value to the given type.
-    template <> inline bool MultiType::convert<orxonox::Vector2>()     { return this->set<orxonox::Vector2>    (this->operator orxonox::Vector2());     } ///< Converts the current value to the given type.
-    template <> inline bool MultiType::convert<orxonox::Vector3>()     { return this->set<orxonox::Vector3>    (this->operator orxonox::Vector3());     } ///< Converts the current value to the given type.
-    template <> inline bool MultiType::convert<orxonox::Vector4>()     { return this->set<orxonox::Vector4>    (this->operator orxonox::Vector4());     } ///< Converts the current value to the given type.
-    template <> inline bool MultiType::convert<orxonox::ColourValue>() { return this->set<orxonox::ColourValue>(this->operator orxonox::ColourValue()); } ///< Converts the current value to the given type.
-    template <> inline bool MultiType::convert<orxonox::Quaternion>()  { return this->set<orxonox::Quaternion> (this->operator orxonox::Quaternion());  } ///< Converts the current value to the given type.
-    template <> inline bool MultiType::convert<orxonox::Radian>()      { return this->set<orxonox::Radian>     (this->operator orxonox::Radian());      } ///< Converts the current value to the given type.
-    template <> inline bool MultiType::convert<orxonox::Degree>()      { return this->set<orxonox::Degree>     (this->operator orxonox::Degree());      } ///< Converts the current value to the given type.
+    // Spezializations for void
+    template <> inline bool MultiType::isType<void>() const { return this->null(); }
+    template <> inline bool MultiType::convert<void>() { this->reset(); return true; }
 
-    // Specialization to avoid ambiguities with the conversion operator
-    template <> inline bool MultiType::convert<const std::string&>()          { return this->convert<std::string>();          } ///< Converts the current value to the given type.
-    template <> inline bool MultiType::convert<const orxonox::Vector2&>()     { return this->convert<orxonox::Vector2>();     } ///< Converts the current value to the given type.
-    template <> inline bool MultiType::convert<const orxonox::Vector3&>()     { return this->convert<orxonox::Vector3>();     } ///< Converts the current value to the given type.
-    template <> inline bool MultiType::convert<const orxonox::Vector4&>()     { return this->convert<orxonox::Vector4>();     } ///< Converts the current value to the given type.
-    template <> inline bool MultiType::convert<const orxonox::ColourValue&>() { return this->convert<orxonox::ColourValue>(); } ///< Converts the current value to the given type.
-    template <> inline bool MultiType::convert<const orxonox::Quaternion&>()  { return this->convert<orxonox::Quaternion>();  } ///< Converts the current value to the given type.
-    template <> inline bool MultiType::convert<const orxonox::Radian&>()      { return this->convert<orxonox::Radian>();      } ///< Converts the current value to the given type.
-    template <> inline bool MultiType::convert<const orxonox::Degree&>()      { return this->convert<orxonox::Degree>();      } ///< Converts the current value to the given type.
-
     template <> _UtilExport void MultiType::createNewValueContainer(const char& value);
     template <> _UtilExport void MultiType::createNewValueContainer(const unsigned char& value);
     template <> _UtilExport void MultiType::createNewValueContainer(const short& value);
@@ -543,57 +516,6 @@
     template <> _UtilExport void MultiType::createNewValueContainer(const orxonox::Quaternion& value);
     template <> _UtilExport void MultiType::createNewValueContainer(const orxonox::Radian& value);
     template <> _UtilExport void MultiType::createNewValueContainer(const orxonox::Degree& value);
-
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-    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.
-
-    template <> inline char                     MultiType::get() const { return this->operator char();                 }
-    template <> inline unsigned char            MultiType::get() const { return this->operator unsigned char();        }
-    template <> inline short                    MultiType::get() const { return this->operator short();                }
-    template <> inline unsigned short           MultiType::get() const { return this->operator unsigned short();       }
-    template <> inline int                      MultiType::get() const { return this->operator int();                  }
-    template <> inline unsigned int             MultiType::get() const { return this->operator unsigned int();         }
-    template <> inline long                     MultiType::get() const { return this->operator long();                 }
-    template <> inline unsigned long            MultiType::get() const { return this->operator unsigned long();        }
-    template <> inline long long                MultiType::get() const { return this->operator long long();            }
-    template <> inline unsigned long long       MultiType::get() const { return this->operator unsigned long long();   }
-    template <> inline float                    MultiType::get() const { return this->operator float();                }
-    template <> inline double                   MultiType::get() const { return this->operator double();               }
-    template <> inline long double              MultiType::get() const { return this->operator long double();          }
-    template <> inline bool                     MultiType::get() const { return this->operator bool();                 }
-    template <> inline void*                    MultiType::get() const { return this->operator void*();                }
-    template <> inline std::string              MultiType::get() const { return this->operator std::string();          }
-    template <> inline orxonox::Vector2         MultiType::get() const { return this->operator orxonox::Vector2();     }
-    template <> inline orxonox::Vector3         MultiType::get() const { return this->operator orxonox::Vector3();     }
-    template <> inline orxonox::Vector4         MultiType::get() const { return this->operator orxonox::Vector4();     }
-    template <> inline orxonox::ColourValue     MultiType::get() const { return this->operator orxonox::ColourValue(); }
-    template <> inline orxonox::Quaternion      MultiType::get() const { return this->operator orxonox::Quaternion();  }
-    template <> inline orxonox::Radian          MultiType::get() const { return this->operator orxonox::Radian();      }
-    template <> inline orxonox::Degree          MultiType::get() const { return this->operator orxonox::Degree();      }
-
-    /// Assigns the given value and converts it to the current type.
-    inline bool MultiType::set(const char* value)                  { if (this->value_) { return this->value_->setValue(std::string(value)); } else { return this->assignValue(std::string(value)); } }
 }
 
 #endif /* _MultiType_H__ */

Modified: code/branches/testing/src/libraries/util/MultiTypeValue.h
===================================================================
--- code/branches/testing/src/libraries/util/MultiTypeValue.h	2012-05-19 13:03:02 UTC (rev 9224)
+++ code/branches/testing/src/libraries/util/MultiTypeValue.h	2012-05-19 21:24:18 UTC (rev 9225)
@@ -54,7 +54,7 @@
     {
     public:
         /// Constructor: Assigns the value and the type identifier.
-        MT_Value(const T& value, MultiType::Type::Enum type) : MT_ValueBase(type), value_(value) {}
+        MT_Value(const T& value, MultiType::Type::Enum type) : MT_ValueBase(&this->value_, type), value_(value) {}
 
         /// Creates a copy of itself.
         inline MT_ValueBase* clone() const { return new MT_Value<T>(this->value_, this->type_); }
@@ -62,23 +62,6 @@
         /// Resets the current value to the default.
         inline void reset() { this->value_ = zeroise<T>(); bHasDefaultValue_ = true; }
 
-        /**
-            @brief Assigns the value of the other MultiType, converted to T.
-            @param other The other MultiType
-        */
-        inline bool assimilate(const MultiType& other)
-        {
-            if (other.value_)
-            {
-                return !(bHasDefaultValue_ = !other.value_->getValue(&value_));
-            }
-            else
-            {
-                this->value_ = zeroise<T>();
-                return !(bHasDefaultValue_ = true);
-            }
-        }
-
         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.
         inline bool getValue(unsigned char*        value) const { return convertValue<T, unsigned char       >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
         inline bool getValue(short*                value) const { return convertValue<T, short               >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
@@ -94,62 +77,55 @@
         inline bool getValue(long double*          value) const { return convertValue<T, long double         >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
         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.
         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.
-        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.
-        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.
-        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.
-        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.
-        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.
-        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.
-        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.
-        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.
+        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.
+        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.
+        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.
+        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.
+        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.
+        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.
+        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.
+        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.
 
-        inline bool setValue(const char& value)                 { return !(bHasDefaultValue_ = !convertValue<char                , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
-        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.
-        inline bool setValue(const short& value)                { return !(bHasDefaultValue_ = !convertValue<short               , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
-        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.
-        inline bool setValue(const int& value)                  { return !(bHasDefaultValue_ = !convertValue<int                 , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
-        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.
-        inline bool setValue(const long& value)                 { return !(bHasDefaultValue_ = !convertValue<long                , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
-        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.
-        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.
-        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.
-        inline bool setValue(const float& value)                { return !(bHasDefaultValue_ = !convertValue<float               , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
-        inline bool setValue(const double& value)               { return !(bHasDefaultValue_ = !convertValue<double              , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
-        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.
-        inline bool setValue(const bool& value)                 { return !(bHasDefaultValue_ = !convertValue<bool                , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
-        inline bool setValue(      void* const& value)          { return !(bHasDefaultValue_ = !convertValue<void*               , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
-        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.
-        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.
-        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.
-        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.
-        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.
-        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.
-        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.
-        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.
+        /**
+            @brief Assigns the value of the other MultiType, converted to T.
+            @param other The other MultiType
+        */
+        inline bool setValue(const MultiType& other)
+        {
+            if (other.value_)
+            {
+                return !(bHasDefaultValue_ = !other.value_->getValue(&value_));
+            }
+            else
+            {
+                this->value_ = zeroise<T>();
+                return !(bHasDefaultValue_ = true);
+            }
+        }
 
-        inline operator char()                 const { return getConvertedValue<T, char>                (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
-        inline operator unsigned char()        const { return getConvertedValue<T, unsigned char>       (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
-        inline operator short()                const { return getConvertedValue<T, short>               (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
-        inline operator unsigned short()       const { return getConvertedValue<T, unsigned short>      (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
-        inline operator int()                  const { return getConvertedValue<T, int>                 (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
-        inline operator unsigned int()         const { return getConvertedValue<T, unsigned int>        (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
-        inline operator long()                 const { return getConvertedValue<T, long>                (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
-        inline operator unsigned long()        const { return getConvertedValue<T, unsigned long>       (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
-        inline operator long long()            const { return getConvertedValue<T, long long>           (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
-        inline operator unsigned long long()   const { return getConvertedValue<T, unsigned long long>  (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
-        inline operator float()                const { return getConvertedValue<T, float>               (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
-        inline operator double()               const { return getConvertedValue<T, double>              (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
-        inline operator long double()          const { return getConvertedValue<T, long double>         (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
-        inline operator bool()                 const { return getConvertedValue<T, bool>                (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
-        inline operator void*()                const { return getConvertedValue<T, void*>               (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
-        inline operator std::string()          const { return getConvertedValue<T, std::string>         (this->value_, NilValue<std::string         >()); } ///< Returns the current value, converted to the requested type.
-        inline operator orxonox::Vector2()     const { return getConvertedValue<T, orxonox::Vector2>    (this->value_, NilValue<orxonox::Vector2    >()); } ///< Returns the current value, converted to the requested type.
-        inline operator orxonox::Vector3()     const { return getConvertedValue<T, orxonox::Vector3>    (this->value_, NilValue<orxonox::Vector3    >()); } ///< Returns the current value, converted to the requested type.
-        inline operator orxonox::Vector4()     const { return getConvertedValue<T, orxonox::Vector4>    (this->value_, NilValue<orxonox::Vector4    >()); } ///< Returns the current value, converted to the requested type.
-        inline operator orxonox::ColourValue() const { return getConvertedValue<T, orxonox::ColourValue>(this->value_, NilValue<orxonox::ColourValue>()); } ///< Returns the current value, converted to the requested type.
-        inline operator orxonox::Quaternion()  const { return getConvertedValue<T, orxonox::Quaternion> (this->value_, NilValue<orxonox::Quaternion >()); } ///< Returns the current value, converted to the requested type.
-        inline operator orxonox::Radian()      const { return getConvertedValue<T, orxonox::Radian>     (this->value_, NilValue<orxonox::Radian     >()); } ///< Returns the current value, converted to the requested type.
-        inline operator orxonox::Degree()      const { return getConvertedValue<T, orxonox::Degree>     (this->value_, NilValue<orxonox::Degree     >()); } ///< Returns the current value, converted to the requested type.
+        inline bool setValue(const char& value)                 { return !(bHasDefaultValue_ = !convertValue<char                , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
+        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.
+        inline bool setValue(const short& value)                { return !(bHasDefaultValue_ = !convertValue<short               , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
+        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.
+        inline bool setValue(const int& value)                  { return !(bHasDefaultValue_ = !convertValue<int                 , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
+        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.
+        inline bool setValue(const long& value)                 { return !(bHasDefaultValue_ = !convertValue<long                , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
+        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.
+        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.
+        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.
+        inline bool setValue(const float& value)                { return !(bHasDefaultValue_ = !convertValue<float               , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
+        inline bool setValue(const double& value)               { return !(bHasDefaultValue_ = !convertValue<double              , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
+        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.
+        inline bool setValue(const bool& value)                 { return !(bHasDefaultValue_ = !convertValue<bool                , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
+        inline bool setValue(      void* const& value)          { return !(bHasDefaultValue_ = !convertValue<void*               , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
+        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.
+        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.
+        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.
+        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.
+        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.
+        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.
+        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.
+        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.
 
         /// Puts the current value on the stream
         inline void toString(std::ostream& outstream) const { outstream << this->value_; }

Modified: code/branches/testing/src/orxonox/graphics/ParticleEmitter.cc
===================================================================
--- code/branches/testing/src/orxonox/graphics/ParticleEmitter.cc	2012-05-19 13:03:02 UTC (rev 9224)
+++ code/branches/testing/src/orxonox/graphics/ParticleEmitter.cc	2012-05-19 21:24:18 UTC (rev 9225)
@@ -70,7 +70,7 @@
     {
         SUPER(ParticleEmitter, XMLPort, xmlelement, mode);
 
-        XMLPortParam(ParticleEmitter, "lod",    setLODxml, getLODxml, xmlelement, mode).defaultValues(LODParticle::Normal);
+        XMLPortParam(ParticleEmitter, "lod",    setLODxml, getLODxml, xmlelement, mode).defaultValues(static_cast<unsigned int>(LODParticle::Normal));
         XMLPortParam(ParticleEmitter, "source", setSource, getSource, xmlelement, mode);
     }
 

Modified: code/branches/testing/test/util/MultiTypeTest.cc
===================================================================
--- code/branches/testing/test/util/MultiTypeTest.cc	2012-05-19 13:03:02 UTC (rev 9224)
+++ code/branches/testing/test/util/MultiTypeTest.cc	2012-05-19 21:24:18 UTC (rev 9225)
@@ -13,7 +13,7 @@
 
     // x set(value)
     // ? set(pointer)
-    // x set<type>(value)
+    // x force<type>(value)
 
     // x convert<type>()
     // x reset
@@ -202,7 +202,7 @@
     }
 
     //////////////////////
-    // set<type>(value) //
+    // force<type>(value) //
     //////////////////////
     TEST(MultiType, SetValueWithTypeIntToString)
     {
@@ -211,7 +211,7 @@
         EXPECT_TRUE(mt.isType<std::string>());
         EXPECT_EQ("Hello", mt.get<std::string>());
 
-        mt.set<int>(1234);
+        mt.force<int>(1234);
 
         EXPECT_TRUE(mt.isType<int>());
         EXPECT_EQ(1234, mt.get<int>());
@@ -224,7 +224,7 @@
         EXPECT_TRUE(mt.isType<std::string>());
         EXPECT_EQ("Hello", mt.get<std::string>());
 
-        mt.set<int>("1234");
+        mt.force<int>("1234");
 
         EXPECT_TRUE(mt.isType<int>());
         EXPECT_EQ(1234, mt.get<int>());
@@ -237,7 +237,7 @@
         EXPECT_TRUE(mt.isType<int>());
         EXPECT_EQ(4321, mt.get<int>());
 
-        mt.set<int>(1234);
+        mt.force<int>(1234);
 
         EXPECT_TRUE(mt.isType<int>());
         EXPECT_EQ(1234, mt.get<int>());




More information about the Orxonox-commit mailing list