Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

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

    r7401 r9550  
    3737namespace orxonox
    3838{
     39    const MultiType MultiType::Null;
     40
    3941    /**
    4042        @brief Converts the current value of the MultiType to a new type.
    4143        @param type The type
    4244    */
    43     bool MultiType::convert(MT_Type::Value type)
     45    bool MultiType::convert(Type::Enum type)
    4446    {
    4547        switch (type)
    4648        {
    47             case MT_Type::Null:
     49            case Type::Null:
    4850                this->reset(); return true;
    49             case MT_Type::Char:
     51            case Type::Char:
    5052                return this->convert<char>(); break;
    51             case MT_Type::UnsignedChar:
     53            case Type::UnsignedChar:
    5254                return this->convert<unsigned char>(); break;
    53             case MT_Type::Short:
     55            case Type::Short:
    5456                return this->convert<short>(); break;
    55             case MT_Type::UnsignedShort:
     57            case Type::UnsignedShort:
    5658                return this->convert<unsigned short>(); break;
    57             case MT_Type::Int:
     59            case Type::Int:
    5860                return this->convert<int>(); break;
    59             case MT_Type::UnsignedInt:
     61            case Type::UnsignedInt:
    6062                return this->convert<unsigned int>(); break;
    61             case MT_Type::Long:
     63            case Type::Long:
    6264                return this->convert<long>(); break;
    63             case MT_Type::UnsignedLong:
     65            case Type::UnsignedLong:
    6466                return this->convert<unsigned long>(); break;
    65             case MT_Type::LongLong:
     67            case Type::LongLong:
    6668                return this->convert<long long>(); break;
    67             case MT_Type::UnsignedLongLong:
     69            case Type::UnsignedLongLong:
    6870                return this->convert<unsigned long long>(); break;
    69             case MT_Type::Float:
     71            case Type::Float:
    7072                return this->convert<float>(); break;
    71             case MT_Type::Double:
     73            case Type::Double:
    7274                return this->convert<double>(); break;
    73             case MT_Type::LongDouble:
     75            case Type::LongDouble:
    7476                return this->convert<long double>(); break;
    75             case MT_Type::Bool:
     77            case Type::Bool:
    7678                return this->convert<bool>(); break;
    77             case MT_Type::VoidPointer:
     79            case Type::VoidPointer:
    7880                return this->convert<void*>(); break;
    79             case MT_Type::String:
     81            case Type::String:
    8082                return this->convert<std::string>(); break;
    81             case MT_Type::Vector2:
     83            case Type::Vector2:
    8284                return this->convert<orxonox::Vector2>(); break;
    83             case MT_Type::Vector3:
     85            case Type::Vector3:
    8486                return this->convert<orxonox::Vector3>(); break;
    85             case MT_Type::Vector4:
     87            case Type::Vector4:
    8688                return this->convert<orxonox::Vector4>(); break;
    87             case MT_Type::ColourValue:
     89            case Type::ColourValue:
    8890                return this->convert<orxonox::ColourValue>(); break;
    89             case MT_Type::Quaternion:
     91            case Type::Quaternion:
    9092                return this->convert<orxonox::Quaternion>(); break;
    91             case MT_Type::Radian:
     93            case Type::Radian:
    9294                return this->convert<orxonox::Radian>(); break;
    93             case MT_Type::Degree:
     95            case Type::Degree:
    9496                return this->convert<orxonox::Degree>(); break;
    9597            default:
     
    104106    std::string MultiType::getTypename() const
    105107    {
    106         MT_Type::Value type = (this->value_) ? this->value_->type_ : MT_Type::Null;
     108        Type::Enum type = (this->value_) ? this->value_->type_ : Type::Null;
    107109
    108110        switch (type)
    109111        {
    110             case MT_Type::Char:
     112            case Type::Char:
    111113                return "char"; break;
    112             case MT_Type::UnsignedChar:
     114            case Type::UnsignedChar:
    113115                return "unsigned char"; break;
    114             case MT_Type::Short:
     116            case Type::Short:
    115117                return "short"; break;
    116             case MT_Type::UnsignedShort:
     118            case Type::UnsignedShort:
    117119                return "unsigned short"; break;
    118             case MT_Type::Int:
     120            case Type::Int:
    119121                return "int"; break;
    120             case MT_Type::UnsignedInt:
     122            case Type::UnsignedInt:
    121123                return "unsigned int"; break;
    122             case MT_Type::Long:
     124            case Type::Long:
    123125                return "long"; break;
    124             case MT_Type::UnsignedLong:
     126            case Type::UnsignedLong:
    125127                return "unsigned long"; break;
    126             case MT_Type::LongLong:
     128            case Type::LongLong:
    127129                return "long long"; break;
    128             case MT_Type::UnsignedLongLong:
     130            case Type::UnsignedLongLong:
    129131                return "unsigned long long"; break;
    130             case MT_Type::Float:
     132            case Type::Float:
    131133                return "float"; break;
    132             case MT_Type::Double:
     134            case Type::Double:
    133135                return "double"; break;
    134             case MT_Type::LongDouble:
     136            case Type::LongDouble:
    135137                return "long double"; break;
    136             case MT_Type::Bool:
     138            case Type::Bool:
    137139                return "bool"; break;
    138             case MT_Type::VoidPointer:
     140            case Type::VoidPointer:
    139141                return "void*"; break;
    140             case MT_Type::String:
     142            case Type::String:
    141143                return "std::string"; break;
    142             case MT_Type::Vector2:
     144            case Type::Vector2:
    143145                return "orxonox::Vector2"; break;
    144             case MT_Type::Vector3:
     146            case Type::Vector3:
    145147                return "orxonox::Vector3"; break;
    146             case MT_Type::Vector4:
     148            case Type::Vector4:
    147149                return "orxonox::Vector4"; break;
    148             case MT_Type::ColourValue:
     150            case Type::ColourValue:
    149151                return "orxonox::ColourValue"; break;
    150             case MT_Type::Quaternion:
     152            case Type::Quaternion:
    151153                return "orxonox::Quaternion"; break;
    152             case MT_Type::Radian:
     154            case Type::Radian:
    153155                return "orxonox::Radian"; break;
    154             case MT_Type::Degree:
     156            case Type::Degree:
    155157                return "orxonox::Degree"; break;
    156158            default:
     
    159161    }
    160162
    161     MultiType::operator char()                 const { return (this->value_) ? ((this->value_->type_ == MT_Type::Char            ) ? (static_cast<MT_Value<char>                *>(this->value_))->value_ : (*this->value_)) : 0;                      } ///< Returns the current value, converted to the requested type.
    162     MultiType::operator unsigned char()        const { return (this->value_) ? ((this->value_->type_ == MT_Type::UnsignedChar    ) ? (static_cast<MT_Value<unsigned char>       *>(this->value_))->value_ : (*this->value_)) : 0;                      } ///< Returns the current value, converted to the requested type.
    163     MultiType::operator short()                const { return (this->value_) ? ((this->value_->type_ == MT_Type::Short           ) ? (static_cast<MT_Value<short>               *>(this->value_))->value_ : (*this->value_)) : 0;                      } ///< Returns the current value, converted to the requested type.
    164     MultiType::operator unsigned short()       const { return (this->value_) ? ((this->value_->type_ == MT_Type::UnsignedShort   ) ? (static_cast<MT_Value<unsigned short>      *>(this->value_))->value_ : (*this->value_)) : 0;                      } ///< Returns the current value, converted to the requested type.
    165     MultiType::operator int()                  const { return (this->value_) ? ((this->value_->type_ == MT_Type::Int             ) ? (static_cast<MT_Value<int>                 *>(this->value_))->value_ : (*this->value_)) : 0;                      } ///< Returns the current value, converted to the requested type.
    166     MultiType::operator unsigned int()         const { return (this->value_) ? ((this->value_->type_ == MT_Type::UnsignedInt     ) ? (static_cast<MT_Value<unsigned int>        *>(this->value_))->value_ : (*this->value_)) : 0;                      } ///< Returns the current value, converted to the requested type.
    167     MultiType::operator long()                 const { return (this->value_) ? ((this->value_->type_ == MT_Type::Long            ) ? (static_cast<MT_Value<long>                *>(this->value_))->value_ : (*this->value_)) : 0;                      } ///< Returns the current value, converted to the requested type.
    168     MultiType::operator unsigned long()        const { return (this->value_) ? ((this->value_->type_ == MT_Type::UnsignedLong    ) ? (static_cast<MT_Value<unsigned long>       *>(this->value_))->value_ : (*this->value_)) : 0;                      } ///< Returns the current value, converted to the requested type.
    169     MultiType::operator long long()            const { return (this->value_) ? ((this->value_->type_ == MT_Type::LongLong        ) ? (static_cast<MT_Value<long long>           *>(this->value_))->value_ : (*this->value_)) : 0;                      } ///< Returns the current value, converted to the requested type.
    170     MultiType::operator unsigned long long()   const { return (this->value_) ? ((this->value_->type_ == MT_Type::UnsignedLongLong) ? (static_cast<MT_Value<unsigned long long>  *>(this->value_))->value_ : (*this->value_)) : 0;                      } ///< Returns the current value, converted to the requested type.
    171     MultiType::operator float()                const { return (this->value_) ? ((this->value_->type_ == MT_Type::Float           ) ? (static_cast<MT_Value<float>               *>(this->value_))->value_ : (*this->value_)) : 0;                      } ///< Returns the current value, converted to the requested type.
    172     MultiType::operator double()               const { return (this->value_) ? ((this->value_->type_ == MT_Type::Double          ) ? (static_cast<MT_Value<double>              *>(this->value_))->value_ : (*this->value_)) : 0;                      } ///< Returns the current value, converted to the requested type.
    173     MultiType::operator long double()          const { return (this->value_) ? ((this->value_->type_ == MT_Type::LongDouble      ) ? (static_cast<MT_Value<long double>         *>(this->value_))->value_ : (*this->value_)) : 0;                      } ///< Returns the current value, converted to the requested type.
    174     MultiType::operator bool()                 const { return (this->value_) ? ((this->value_->type_ == MT_Type::Bool            ) ? (static_cast<MT_Value<bool>                *>(this->value_))->value_ : (*this->value_)) : 0;                      } ///< Returns the current value, converted to the requested type.
    175     MultiType::operator void*()                const { return (this->value_) ? ((this->value_->type_ == MT_Type::VoidPointer     ) ? (static_cast<MT_Value<void*>               *>(this->value_))->value_ : (*this->value_)) : 0;                      } ///< Returns the current value, converted to the requested type.
    176     MultiType::operator std::string()          const { return (this->value_) ? ((this->value_->type_ == MT_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.
    177     MultiType::operator orxonox::Vector2()     const { return (this->value_) ? ((this->value_->type_ == MT_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.
    178     MultiType::operator orxonox::Vector3()     const { return (this->value_) ? ((this->value_->type_ == MT_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.
    179     MultiType::operator orxonox::Vector4()     const { return (this->value_) ? ((this->value_->type_ == MT_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.
    180     MultiType::operator orxonox::ColourValue() const { return (this->value_) ? ((this->value_->type_ == MT_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.
    181     MultiType::operator orxonox::Quaternion()  const { return (this->value_) ? ((this->value_->type_ == MT_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.
    182     MultiType::operator orxonox::Radian()      const { return (this->value_) ? ((this->value_->type_ == MT_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.
    183     MultiType::operator orxonox::Degree()      const { return (this->value_) ? ((this->value_->type_ == MT_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.
    184 
    185     template <> void MultiType::createNewValueContainer(const char& value)                 { this->value_ = new MT_Value<char>                (value, MT_Type::Char            ); } ///< Creates a new value container for the given type.
    186     template <> void MultiType::createNewValueContainer(const unsigned char& value)        { this->value_ = new MT_Value<unsigned char>       (value, MT_Type::UnsignedChar    ); } ///< Creates a new value container for the given type.
    187     template <> void MultiType::createNewValueContainer(const short& value)                { this->value_ = new MT_Value<short>               (value, MT_Type::Short           ); } ///< Creates a new value container for the given type.
    188     template <> void MultiType::createNewValueContainer(const unsigned short& value)       { this->value_ = new MT_Value<unsigned short>      (value, MT_Type::UnsignedShort   ); } ///< Creates a new value container for the given type.
    189     template <> void MultiType::createNewValueContainer(const int& value)                  { this->value_ = new MT_Value<int>                 (value, MT_Type::Int             ); } ///< Creates a new value container for the given type.
    190     template <> void MultiType::createNewValueContainer(const unsigned int& value)         { this->value_ = new MT_Value<unsigned int>        (value, MT_Type::UnsignedInt     ); } ///< Creates a new value container for the given type.
    191     template <> void MultiType::createNewValueContainer(const long& value)                 { this->value_ = new MT_Value<long>                (value, MT_Type::Long            ); } ///< Creates a new value container for the given type.
    192     template <> void MultiType::createNewValueContainer(const unsigned long& value)        { this->value_ = new MT_Value<unsigned long>       (value, MT_Type::UnsignedLong    ); } ///< Creates a new value container for the given type.
    193     template <> void MultiType::createNewValueContainer(const long long& value)            { this->value_ = new MT_Value<long long>           (value, MT_Type::LongLong        ); } ///< Creates a new value container for the given type.
    194     template <> void MultiType::createNewValueContainer(const unsigned long long& value)   { this->value_ = new MT_Value<unsigned long long>  (value, MT_Type::UnsignedLongLong); } ///< Creates a new value container for the given type.
    195     template <> void MultiType::createNewValueContainer(const float& value)                { this->value_ = new MT_Value<float>               (value, MT_Type::Float           ); } ///< Creates a new value container for the given type.
    196     template <> void MultiType::createNewValueContainer(const double& value)               { this->value_ = new MT_Value<double>              (value, MT_Type::Double          ); } ///< Creates a new value container for the given type.
    197     template <> void MultiType::createNewValueContainer(const long double& value)          { this->value_ = new MT_Value<long double>         (value, MT_Type::LongDouble      ); } ///< Creates a new value container for the given type.
    198     template <> void MultiType::createNewValueContainer(const bool& value)                 { this->value_ = new MT_Value<bool>                (value, MT_Type::Bool            ); } ///< Creates a new value container for the given type.
    199     template <> void MultiType::createNewValueContainer(      void* const& value)          { this->value_ = new MT_Value<void*>               (value, MT_Type::VoidPointer     ); } ///< Creates a new value container for the given type.
    200     template <> void MultiType::createNewValueContainer(const std::string& value)          { this->value_ = new MT_Value<std::string>         (value, MT_Type::String          ); } ///< Creates a new value container for the given type.
    201     template <> void MultiType::createNewValueContainer(const orxonox::Vector2& value)     { this->value_ = new MT_Value<orxonox::Vector2>    (value, MT_Type::Vector2         ); } ///< Creates a new value container for the given type.
    202     template <> void MultiType::createNewValueContainer(const orxonox::Vector3& value)     { this->value_ = new MT_Value<orxonox::Vector3>    (value, MT_Type::Vector3         ); } ///< Creates a new value container for the given type.
    203     template <> void MultiType::createNewValueContainer(const orxonox::Vector4& value)     { this->value_ = new MT_Value<orxonox::Vector4>    (value, MT_Type::Vector4         ); } ///< Creates a new value container for the given type.
    204     template <> void MultiType::createNewValueContainer(const orxonox::ColourValue& value) { this->value_ = new MT_Value<orxonox::ColourValue>(value, MT_Type::ColourValue     ); } ///< Creates a new value container for the given type.
    205     template <> void MultiType::createNewValueContainer(const orxonox::Quaternion& value)  { this->value_ = new MT_Value<orxonox::Quaternion> (value, MT_Type::Quaternion      ); } ///< Creates a new value container for the given type.
    206     template <> void MultiType::createNewValueContainer(const orxonox::Radian& value)      { this->value_ = new MT_Value<orxonox::Radian>     (value, MT_Type::Radian          ); } ///< Creates a new value container for the given type.
    207     template <> void MultiType::createNewValueContainer(const orxonox::Degree& value)      { this->value_ = new MT_Value<orxonox::Degree>     (value, MT_Type::Degree          ); } ///< Creates a new value container for the given type.
     163    template <> void MultiType::createNewValueContainer(const char& value)                 { this->value_ = new MT_Value<char>                (value, Type::Char            ); }
     164    template <> void MultiType::createNewValueContainer(const unsigned char& value)        { this->value_ = new MT_Value<unsigned char>       (value, Type::UnsignedChar    ); }
     165    template <> void MultiType::createNewValueContainer(const short& value)                { this->value_ = new MT_Value<short>               (value, Type::Short           ); }
     166    template <> void MultiType::createNewValueContainer(const unsigned short& value)       { this->value_ = new MT_Value<unsigned short>      (value, Type::UnsignedShort   ); }
     167    template <> void MultiType::createNewValueContainer(const int& value)                  { this->value_ = new MT_Value<int>                 (value, Type::Int             ); }
     168    template <> void MultiType::createNewValueContainer(const unsigned int& value)         { this->value_ = new MT_Value<unsigned int>        (value, Type::UnsignedInt     ); }
     169    template <> void MultiType::createNewValueContainer(const long& value)                 { this->value_ = new MT_Value<long>                (value, Type::Long            ); }
     170    template <> void MultiType::createNewValueContainer(const unsigned long& value)        { this->value_ = new MT_Value<unsigned long>       (value, Type::UnsignedLong    ); }
     171    template <> void MultiType::createNewValueContainer(const long long& value)            { this->value_ = new MT_Value<long long>           (value, Type::LongLong        ); }
     172    template <> void MultiType::createNewValueContainer(const unsigned long long& value)   { this->value_ = new MT_Value<unsigned long long>  (value, Type::UnsignedLongLong); }
     173    template <> void MultiType::createNewValueContainer(const float& value)                { this->value_ = new MT_Value<float>               (value, Type::Float           ); }
     174    template <> void MultiType::createNewValueContainer(const double& value)               { this->value_ = new MT_Value<double>              (value, Type::Double          ); }
     175    template <> void MultiType::createNewValueContainer(const long double& value)          { this->value_ = new MT_Value<long double>         (value, Type::LongDouble      ); }
     176    template <> void MultiType::createNewValueContainer(const bool& value)                 { this->value_ = new MT_Value<bool>                (value, Type::Bool            ); }
     177    template <> void MultiType::createNewValueContainer(      void* const& value)          { this->value_ = new MT_Value<void*>               (value, Type::VoidPointer     ); }
     178    template <> void MultiType::createNewValueContainer(const std::string& value)          { this->value_ = new MT_Value<std::string>         (value, Type::String          ); }
     179    template <> void MultiType::createNewValueContainer(const orxonox::Vector2& value)     { this->value_ = new MT_Value<orxonox::Vector2>    (value, Type::Vector2         ); }
     180    template <> void MultiType::createNewValueContainer(const orxonox::Vector3& value)     { this->value_ = new MT_Value<orxonox::Vector3>    (value, Type::Vector3         ); }
     181    template <> void MultiType::createNewValueContainer(const orxonox::Vector4& value)     { this->value_ = new MT_Value<orxonox::Vector4>    (value, Type::Vector4         ); }
     182    template <> void MultiType::createNewValueContainer(const orxonox::ColourValue& value) { this->value_ = new MT_Value<orxonox::ColourValue>(value, Type::ColourValue     ); }
     183    template <> void MultiType::createNewValueContainer(const orxonox::Quaternion& value)  { this->value_ = new MT_Value<orxonox::Quaternion> (value, Type::Quaternion      ); }
     184    template <> void MultiType::createNewValueContainer(const orxonox::Radian& value)      { this->value_ = new MT_Value<orxonox::Radian>     (value, Type::Radian          ); }
     185    template <> void MultiType::createNewValueContainer(const orxonox::Degree& value)      { this->value_ = new MT_Value<orxonox::Degree>     (value, Type::Degree          ); }
    208186}
Note: See TracChangeset for help on using the changeset viewer.