Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1791 for code/trunk


Ignore:
Timestamp:
Sep 16, 2008, 3:46:25 AM (16 years ago)
Author:
landauf
Message:

added comments to all my classes in util

Location:
code/trunk/src
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/core/ConfigValueContainer.cc

    r1784 r1791  
    4545namespace orxonox
    4646{
    47     const int MAX_VECTOR_INDEX  = 255; // to avoid up to 4*10^9 vector entries in the config file after accidentally using a wrong argument
     47    const unsigned int MAX_VECTOR_INDEX  = 255; // to avoid up to 4*10^9 vector entries in the config file after accidentally using a wrong argument
    4848
    4949    /**
     
    304304            success = ConvertValue(&index, token[0]);
    305305
    306         if (!success || index < 0 || index > MAX_VECTOR_INDEX)
     306        if (!success || index < 0 || index > (signed int)MAX_VECTOR_INDEX)
    307307        {
    308308            if (!success)
  • code/trunk/src/util/CRC32.cc

    r1763 r1791  
    2121 *
    2222 *   Author:
    23  *      Fabian 'x3n' Landau
     23 *      ...
    2424 *   Co-authors:
    2525 *      ...
     
    3232void calcCRCBit(uint32_t &crc32, int bit){
    3333    int hbit;
    34  
     34
    3535    hbit=(crc32 & 0x80000000) ? 1 : 0;
    3636    if (hbit != bit)
  • code/trunk/src/util/CRC32.h

    r1784 r1791  
    2121 *
    2222 *   Author:
    23  *      Fabian 'x3n' Landau
     23 *      ...
    2424 *   Co-authors:
    2525 *      ...
  • code/trunk/src/util/Clipboard.cc

    r1505 r1791  
    2929 */
    3030
     31/**
     32    @file Clipboard.cc
     33    @brief OS-specific implementations of the clipboard functions.
     34*/
     35
    3136#include "Clipboard.h"
    3237
    3338#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32
     39    /////////////
     40    // Windows //
     41    /////////////
    3442    #include <windows.h>
     43    #include "Debug.h"
    3544
    36     bool toClipboard(std::string text)
     45    /**
     46        @brief Puts text into the windows-clipboard
     47        @param text The text
     48        @return True if the action was successful
     49    */
     50    bool toClipboard(const std::string& text)
    3751    {
    3852        try
     
    5367        catch (...)
    5468        {
     69            COUT(1) << "Error: Unable to copy the following text to the clipboard:" << std::endl;
     70            COUT(1) << "       \"" << text << "\"" << std::endl;
    5571        }
    5672        return false;
    5773    }
    5874
     75    /**
     76        @brief Gets text from the windows-clipboard if there is any text.
     77        @return The retrieved text
     78    */
    5979    std::string fromClipboard()
    6080    {
     
    7393        catch (...)
    7494        {
     95            COUT(1) << "Error: Unable to retrieve text from the clipboard." << std::endl;
    7596        }
    7697        return "";
    7798    }
    7899#else
    79     std::string clipboard = "";
     100    /////////////
     101    // Default //
     102    /////////////
    80103
    81     bool toClipboard(std::string text)
     104    std::string clipboard = ""; //!< Keeps the text of our internal clipboard
     105
     106    /**
     107        @brief Default implementation if there is no OS-specific implementation or no clipboard. Copies the text into an internal clipboard.
     108        @param text The text
     109        @return True
     110    */
     111    bool toClipboard(const std::string& text)
    82112    {
    83113        clipboard = text;
     
    85115    }
    86116
     117    /**
     118        @brief Default implementation if there is no OS-specific implementation or no clipboard. Gets the text from the internal clipboard.
     119        @return The text
     120    */
    87121    std::string fromClipboard()
    88122    {
  • code/trunk/src/util/Clipboard.h

    r1505 r1791  
    2727 */
    2828
     29/**
     30    @file Clipboard.h
     31    @brief Some functions to exchange text between the OS clipboard and Orxonox.
     32
     33    Use fromClipboard() to get text from the clipboard (if there is any text) and
     34    toClipboard(text) to put text into the clipboard.
     35
     36    Those functions can only work properly if there's an OS-specific implementation.
     37    If an OS isn't supported, the clipboard only works within Orxonox, but exchange
     38    with other programs isn't possible.
     39*/
     40
    2941#ifndef _Clipboard_H__
    3042#define _Clipboard_H__
     
    3547
    3648
    37 _UtilExport bool toClipboard(std::string text);
     49_UtilExport bool toClipboard(const std::string& text);
    3850_UtilExport std::string fromClipboard();
    3951
  • code/trunk/src/util/Convert.h

    r1755 r1791  
    2121 *
    2222 *   Author:
     23 *      Fabian 'x3n' Landau
    2324 *      Benjamin Grauer
    24  *      Fabian 'x3n' Landau
    2525 *   Co-authors:
    2626 *      ...
  • code/trunk/src/util/Debug.h

    r1747 r1791  
    2828
    2929/**
    30  * @file Debug.h
    31  * @brief Handles the output for different verbose-modes.
    32  *
    33  * There are two modes: HARD and SOFT. HARD is precessed during compiletime, while SOFT is for runtime.
     30    @file Debug.h
     31    @brief Handles different output-levels of errors, warnings, infos and debug informations.
     32
     33    The COUT(level) macro acts like std::cout, but the output is only performed if the given
     34    level is <= the soft debug level.
     35
     36    There are two used values in this file:
     37     - The hard debug level is used during compiletime. It describes the highest allowed output level.
     38     - The soft debug level is used during runtime and is the maximum of the three configurable
     39       output-levels for console, logfile and ingame shell.
     40
     41    The separation between the three devices is done by the OutputHandler.
     42
     43    Possible levels are:
     44     0: Very important output
     45     1: Errors
     46     2: Warnings
     47     3: Informations
     48     4: Debug information
     49     5: More debug information
     50     6: Crazy debug informations
     51
     52    @example
     53    COUT(0) << "Very important output" << std::endl;
     54    COUT(1) << "Error: Something went wrong!" << std::endl;
     55    COUT(2) << "Warning: There might be a problem." << std::endl;
     56    COUT(3) << "Info: It's monday" << std::endl;
     57    COUT(4) << "Debug: x is 1.23456" << std::endl;
    3458 */
    3559
  • code/trunk/src/util/Math.cc

    r1625 r1791  
    2727 */
    2828
     29/**
     30    @file Math.cc
     31    @brief Implementation of several math-functions.
     32*/
     33
    2934#include <OgrePlane.h>
    3035
     
    3338
    3439/**
    35     @brief Function for writing to a stream.
     40    @brief Function for writing a Radian to a stream.
    3641*/
    3742std::ostream& operator<<(std::ostream& out, const orxonox::Radian& radian)
     
    4247
    4348/**
    44     @brief Function for reading from a stream.
     49    @brief Function for reading a Radian from a stream.
    4550*/
    4651std::istream& operator>>(std::istream& in, orxonox::Radian& radian)
     
    5358
    5459/**
    55     @brief Function for writing to a stream.
     60    @brief Function for writing a Degree to a stream.
    5661*/
    5762std::ostream& operator<<(std::ostream& out, const orxonox::Degree& degree)
     
    6267
    6368/**
    64     @brief Function for reading from a stream.
     69    @brief Function for reading a Degree from a stream.
    6570*/
    6671std::istream& operator>>(std::istream& in, orxonox::Degree& degree)
     
    7378
    7479
     80/**
     81    @brief Gets the angle between my viewing direction and the direction to the position of the other object.
     82    @param myposition My position
     83    @param mydirection My viewing direction
     84    @param otherposition The position of the other object
     85    @return The angle
     86
     87    @example
     88    If the other object is exactly in front of me, the function returns 0.
     89    If the other object is exactly behind me, the function returns pi.
     90    If the other object is exactly right/left to me (or above/below), the function returns pi/2.
     91*/
    7592float getAngle(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& otherposition)
    7693{
     
    83100}
    84101
     102/**
     103    @brief Gets the 2D viewing direction (up/down, left/right) to the position of the other object.
     104    @param myposition My position
     105    @param mydirection My viewing direction
     106    @param myorthonormal My orthonormalvector (pointing upwards through my head)
     107    @param otherposition The position of the other object
     108    @return The viewing direction
     109
     110    @example
     111    If the other object is exactly in front of me, the function returns Vector2(0, 0).
     112    If the other object is exactly at my left, the function returns Vector2(-1, 0).
     113    If the other object is exactly at my right, the function returns Vector2(1, 0).
     114    If the other object is only a bit at my right, the function still returns Vector2(1, 0).
     115    If the other object is exactly above me, the function returns Vector2(0, 1).
     116*/
    85117orxonox::Vector2 get2DViewdirection(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition)
    86118{
     
    100132}
    101133
     134/**
     135    @brief Gets the 2D viewing direction (up/down, left/right) to the position of the other object, multiplied with the viewing distance to the object (0° = 0, 180° = 1).
     136    @param myposition My position
     137    @param mydirection My viewing direction
     138    @param myorthonormal My orthonormalvector (pointing upwards through my head)
     139    @param otherposition The position of the other object
     140    @return The viewing direction
     141
     142    @example
     143    If the other object is exactly in front of me, the function returns Vector2(0, 0).
     144    If the other object is exactly at my left, the function returns Vector2(-0.5, 0).
     145    If the other object is exactly at my right, the function returns Vector2(0.5, 0).
     146    If the other object is only a bit at my right, the function still returns Vector2(0.01, 0).
     147    If the other object is exactly above me, the function returns Vector2(0, 0.5).
     148*/
    102149orxonox::Vector2 get2DViewcoordinates(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition)
    103150{
     
    121168}
    122169
     170/**
     171    @brief Returns the predicted position I have to aim at, if I want to hit a moving target with a moving projectile.
     172    @param myposition My position
     173    @param projectilespeed The speed of my projectile
     174    @param targetposition The position of my target
     175    @param targetvelocity The velocity of my target
     176    @return The predicted position
     177
     178    The function predicts the position based on a linear velocity of the target. If the target changes speed or direction, the projectile will miss.
     179*/
    123180orxonox::Vector3 getPredictedPosition(const orxonox::Vector3& myposition, float projectilespeed, const orxonox::Vector3& targetposition, const orxonox::Vector3& targetvelocity)
    124181{
  • code/trunk/src/util/Math.h

    r1781 r1791  
    2626 *
    2727 */
     28
     29/**
     30    @file Math.h
     31    @brief Declaration and implementation of several math-functions, typedefs of some Ogre::Math classes to the orxonox namespace.
     32*/
    2833
    2934#ifndef _Util_Math_H__
     
    6873
    6974//Get around Windows hackery
    70 #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32 
     75#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32
    7176#  ifdef max
    7277#    undef max
     
    7782#endif
    7883
     84/**
     85    @brief Returns the sign of the given value.
     86    @param x The value
     87    @return 1 if the value is positive or zero, -1 if the value is negative
     88*/
    7989template <typename T>
    8090inline T sgn(T x)
     
    8393}
    8494
     95/**
     96    @brief Returns the smaller of two values.
     97*/
    8598template <typename T>
    8699inline T min(T a, T b)
     
    89102}
    90103
     104/**
     105    @brief Returns the greater of two values.
     106*/
    91107template <typename T>
    92108inline T max(T a, T b)
     
    95111}
    96112
     113/**
     114    @brief Keeps a value between a lower and an upper limit.
     115    @param x The value
     116    @param min The lower limit
     117    @param max The upper limit
     118*/
    97119template <typename T>
    98120inline T clamp(T x, T min, T max)
     
    107129}
    108130
     131/**
     132    @brief Returns the square value (x^2).
     133*/
    109134template <typename T>
    110135inline T square(T x)
     
    113138}
    114139
     140/**
     141    @brief Returns the cube value (x^3).
     142*/
    115143template <typename T>
    116144inline T cube(T x)
     
    119147}
    120148
     149/**
     150    @brief Rounds the value down.
     151*/
    121152template <typename T>
    122153inline int floor(T x)
     
    125156}
    126157
     158/**
     159    @brief Rounds the value up.
     160*/
    127161template <typename T>
    128162inline int ceil(T x)
     
    132166}
    133167
     168/**
     169    @brief Rounds the value.
     170*/
    134171template <typename T>
    135172inline int round(T x)
     
    138175}
    139176
     177/**
     178    @brief The modulo operation, enhanced to work properly with negative values.
     179    @param x The value
     180    @param max The operand
     181*/
    140182template <typename T>
    141183inline int mod(T x, int max)
     
    147189}
    148190
     191/**
     192    @brief Interpolates between two values for a time between 0 and 1.
     193    @param time The time is a value between 0 and 1 - the function returns start if time is 0 and end if time is 1 and interpolates if time is between 0 and 1.
     194    @param start The value at time = 0
     195    @param end The value at time = 1
     196    @return The interpolation at a given time
     197*/
    149198template <typename T>
    150199T interpolate(float time, const T& start, const T& end)
     
    153202}
    154203
     204/**
     205    @brief Interpolates smoothly between two values for a time between 0 and 1. The function starts slowly, increases faster and stops slowly again.
     206    @param time The time is a value between 0 and 1 - the function returns start if time is 0 and end if time is 1 and interpolates if time is between 0 and 1.
     207    @param start The value at time = 0
     208    @param end The value at time = 1
     209    @return The smoothed interpolation at a given time
     210*/
    155211template <typename T>
    156212T interpolateSmooth(float time, const T& start, const T& end)
     
    159215}
    160216
     217/**
     218    @brief Returns a random number between 0 and 1.
     219*/
    161220inline _UtilExport float rnd()
    162221{
     
    164223}
    165224
     225/**
     226    @brief Returns a random number between 0 and max.
     227    @param max The maximum
     228*/
    166229inline _UtilExport float rnd(float max)
    167230{
     
    169232}
    170233
     234/**
     235    @brief Returns a random number between min and max.
     236    @param min The minimum
     237    @param max The maximum
     238*/
    171239inline _UtilExport float rnd(float min, float max)
    172240{
  • code/trunk/src/util/MultiType.cc

    r1747 r1791  
    2727 */
    2828
     29/**
     30    @file MultiType.cc
     31    @brief Implementation of the MultiType.
     32*/
     33
    2934#include "MultiType.h"
    3035#include "MultiTypeValue.h"
    3136
     37/**
     38    @brief Converts the current value of the MultiType to a new type.
     39    @param type The type
     40*/
    3241void MultiType::convert(MT_Type type)
    3342{
     
    8594}
    8695
     96/**
     97    @brief Returns the name of the current type.
     98    @return The name
     99*/
    87100std::string MultiType::getTypename() const
    88101{
     
    142155}
    143156
    144 MultiType::operator char()                 const { return (this->value_) ? ((this->value_->type_ == MT_char       ) ? ((MT_Value<char>                *)this->value_)->value_ : (*this->value_)) : 0;                      }
    145 MultiType::operator unsigned char()        const { return (this->value_) ? ((this->value_->type_ == MT_uchar      ) ? ((MT_Value<unsigned char>       *)this->value_)->value_ : (*this->value_)) : 0;                      }
    146 MultiType::operator short()                const { return (this->value_) ? ((this->value_->type_ == MT_short      ) ? ((MT_Value<short>               *)this->value_)->value_ : (*this->value_)) : 0;                      }
    147 MultiType::operator unsigned short()       const { return (this->value_) ? ((this->value_->type_ == MT_ushort     ) ? ((MT_Value<unsigned short>      *)this->value_)->value_ : (*this->value_)) : 0;                      }
    148 MultiType::operator int()                  const { return (this->value_) ? ((this->value_->type_ == MT_int        ) ? ((MT_Value<int>                 *)this->value_)->value_ : (*this->value_)) : 0;                      }
    149 MultiType::operator unsigned int()         const { return (this->value_) ? ((this->value_->type_ == MT_uint       ) ? ((MT_Value<unsigned int>        *)this->value_)->value_ : (*this->value_)) : 0;                      }
    150 MultiType::operator long()                 const { return (this->value_) ? ((this->value_->type_ == MT_long       ) ? ((MT_Value<long>                *)this->value_)->value_ : (*this->value_)) : 0;                      }
    151 MultiType::operator unsigned long()        const { return (this->value_) ? ((this->value_->type_ == MT_ulong      ) ? ((MT_Value<unsigned long>       *)this->value_)->value_ : (*this->value_)) : 0;                      }
    152 MultiType::operator long long()            const { return (this->value_) ? ((this->value_->type_ == MT_longlong   ) ? ((MT_Value<long long>           *)this->value_)->value_ : (*this->value_)) : 0;                      }
    153 MultiType::operator unsigned long long()   const { return (this->value_) ? ((this->value_->type_ == MT_ulonglong  ) ? ((MT_Value<unsigned long long>  *)this->value_)->value_ : (*this->value_)) : 0;                      }
    154 MultiType::operator float()                const { return (this->value_) ? ((this->value_->type_ == MT_float      ) ? ((MT_Value<float>               *)this->value_)->value_ : (*this->value_)) : 0;                      }
    155 MultiType::operator double()               const { return (this->value_) ? ((this->value_->type_ == MT_double     ) ? ((MT_Value<double>              *)this->value_)->value_ : (*this->value_)) : 0;                      }
    156 MultiType::operator long double()          const { return (this->value_) ? ((this->value_->type_ == MT_longdouble ) ? ((MT_Value<long double>         *)this->value_)->value_ : (*this->value_)) : 0;                      }
    157 MultiType::operator bool()                 const { return (this->value_) ? ((this->value_->type_ == MT_bool       ) ? ((MT_Value<bool>                *)this->value_)->value_ : (*this->value_)) : false;                  }
    158 MultiType::operator void*()                const { return (this->value_) ? ((this->value_->type_ == MT_void       ) ? ((MT_Value<void*>               *)this->value_)->value_ : (*this->value_)) : (void*)0;               }
    159 MultiType::operator std::string()          const { return (this->value_) ? ((this->value_->type_ == MT_string     ) ? ((MT_Value<std::string>         *)this->value_)->value_ : (*this->value_)) : std::string();          }
    160 MultiType::operator orxonox::Vector2()     const { return (this->value_) ? ((this->value_->type_ == MT_vector2    ) ? ((MT_Value<orxonox::Vector2>    *)this->value_)->value_ : (*this->value_)) : orxonox::Vector2();     }
    161 MultiType::operator orxonox::Vector3()     const { return (this->value_) ? ((this->value_->type_ == MT_vector3    ) ? ((MT_Value<orxonox::Vector3>    *)this->value_)->value_ : (*this->value_)) : orxonox::Vector3();     }
    162 MultiType::operator orxonox::Vector4()     const { return (this->value_) ? ((this->value_->type_ == MT_vector4    ) ? ((MT_Value<orxonox::Vector4>    *)this->value_)->value_ : (*this->value_)) : orxonox::Vector4();     }
    163 MultiType::operator orxonox::ColourValue() const { return (this->value_) ? ((this->value_->type_ == MT_colourvalue) ? ((MT_Value<orxonox::ColourValue>*)this->value_)->value_ : (*this->value_)) : orxonox::ColourValue(); }
    164 MultiType::operator orxonox::Quaternion()  const { return (this->value_) ? ((this->value_->type_ == MT_quaternion ) ? ((MT_Value<orxonox::Quaternion> *)this->value_)->value_ : (*this->value_)) : orxonox::Quaternion();  }
    165 MultiType::operator orxonox::Radian()      const { return (this->value_) ? ((this->value_->type_ == MT_radian     ) ? ((MT_Value<orxonox::Radian>     *)this->value_)->value_ : (*this->value_)) : orxonox::Radian();      }
    166 MultiType::operator orxonox::Degree()      const { return (this->value_) ? ((this->value_->type_ == MT_degree     ) ? ((MT_Value<orxonox::Degree>     *)this->value_)->value_ : (*this->value_)) : orxonox::Degree();      }
    167 
    168 template <> void MultiType::createNewValueContainer(const char& value)                 { this->value_ = new MT_Value<char>                (value, MT_char       ); }
    169 template <> void MultiType::createNewValueContainer(const unsigned char& value)        { this->value_ = new MT_Value<unsigned char>       (value, MT_uchar      ); }
    170 template <> void MultiType::createNewValueContainer(const short& value)                { this->value_ = new MT_Value<short>               (value, MT_short      ); }
    171 template <> void MultiType::createNewValueContainer(const unsigned short& value)       { this->value_ = new MT_Value<unsigned short>      (value, MT_ushort     ); }
    172 template <> void MultiType::createNewValueContainer(const int& value)                  { this->value_ = new MT_Value<int>                 (value, MT_int        ); }
    173 template <> void MultiType::createNewValueContainer(const unsigned int& value)         { this->value_ = new MT_Value<unsigned int>        (value, MT_uint       ); }
    174 template <> void MultiType::createNewValueContainer(const long& value)                 { this->value_ = new MT_Value<long>                (value, MT_long       ); }
    175 template <> void MultiType::createNewValueContainer(const unsigned long& value)        { this->value_ = new MT_Value<unsigned long>       (value, MT_ulong      ); }
    176 template <> void MultiType::createNewValueContainer(const long long& value)            { this->value_ = new MT_Value<long long>           (value, MT_longlong   ); }
    177 template <> void MultiType::createNewValueContainer(const unsigned long long& value)   { this->value_ = new MT_Value<unsigned long long>  (value, MT_ulonglong  ); }
    178 template <> void MultiType::createNewValueContainer(const float& value)                { this->value_ = new MT_Value<float>               (value, MT_float      ); }
    179 template <> void MultiType::createNewValueContainer(const double& value)               { this->value_ = new MT_Value<double>              (value, MT_double     ); }
    180 template <> void MultiType::createNewValueContainer(const long double& value)          { this->value_ = new MT_Value<long double>         (value, MT_longdouble ); }
    181 template <> void MultiType::createNewValueContainer(const bool& value)                 { this->value_ = new MT_Value<bool>                (value, MT_bool       ); }
    182 template <> void MultiType::createNewValueContainer(      void* const& value)          { this->value_ = new MT_Value<void*>               (value, MT_void       ); }
    183 template <> void MultiType::createNewValueContainer(const std::string& value)          { this->value_ = new MT_Value<std::string>         (value, MT_string     ); }
    184 template <> void MultiType::createNewValueContainer(const orxonox::Vector2& value)     { this->value_ = new MT_Value<orxonox::Vector2>    (value, MT_vector2    ); }
    185 template <> void MultiType::createNewValueContainer(const orxonox::Vector3& value)     { this->value_ = new MT_Value<orxonox::Vector3>    (value, MT_vector3    ); }
    186 template <> void MultiType::createNewValueContainer(const orxonox::Vector4& value)     { this->value_ = new MT_Value<orxonox::Vector4>    (value, MT_vector4    ); }
    187 template <> void MultiType::createNewValueContainer(const orxonox::ColourValue& value) { this->value_ = new MT_Value<orxonox::ColourValue>(value, MT_colourvalue); }
    188 template <> void MultiType::createNewValueContainer(const orxonox::Quaternion& value)  { this->value_ = new MT_Value<orxonox::Quaternion> (value, MT_quaternion ); }
    189 template <> void MultiType::createNewValueContainer(const orxonox::Radian& value)      { this->value_ = new MT_Value<orxonox::Radian>     (value, MT_radian     ); }
    190 template <> void MultiType::createNewValueContainer(const orxonox::Degree& value)      { this->value_ = new MT_Value<orxonox::Degree>     (value, MT_degree     ); }
     157MultiType::operator char()                 const { return (this->value_) ? ((this->value_->type_ == MT_char       ) ? ((MT_Value<char>                *)this->value_)->value_ : (*this->value_)) : 0;                      } /** @brief Returns the current value, converted to the requested type. */
     158MultiType::operator unsigned char()        const { return (this->value_) ? ((this->value_->type_ == MT_uchar      ) ? ((MT_Value<unsigned char>       *)this->value_)->value_ : (*this->value_)) : 0;                      } /** @brief Returns the current value, converted to the requested type. */
     159MultiType::operator short()                const { return (this->value_) ? ((this->value_->type_ == MT_short      ) ? ((MT_Value<short>               *)this->value_)->value_ : (*this->value_)) : 0;                      } /** @brief Returns the current value, converted to the requested type. */
     160MultiType::operator unsigned short()       const { return (this->value_) ? ((this->value_->type_ == MT_ushort     ) ? ((MT_Value<unsigned short>      *)this->value_)->value_ : (*this->value_)) : 0;                      } /** @brief Returns the current value, converted to the requested type. */
     161MultiType::operator int()                  const { return (this->value_) ? ((this->value_->type_ == MT_int        ) ? ((MT_Value<int>                 *)this->value_)->value_ : (*this->value_)) : 0;                      } /** @brief Returns the current value, converted to the requested type. */
     162MultiType::operator unsigned int()         const { return (this->value_) ? ((this->value_->type_ == MT_uint       ) ? ((MT_Value<unsigned int>        *)this->value_)->value_ : (*this->value_)) : 0;                      } /** @brief Returns the current value, converted to the requested type. */
     163MultiType::operator long()                 const { return (this->value_) ? ((this->value_->type_ == MT_long       ) ? ((MT_Value<long>                *)this->value_)->value_ : (*this->value_)) : 0;                      } /** @brief Returns the current value, converted to the requested type. */
     164MultiType::operator unsigned long()        const { return (this->value_) ? ((this->value_->type_ == MT_ulong      ) ? ((MT_Value<unsigned long>       *)this->value_)->value_ : (*this->value_)) : 0;                      } /** @brief Returns the current value, converted to the requested type. */
     165MultiType::operator long long()            const { return (this->value_) ? ((this->value_->type_ == MT_longlong   ) ? ((MT_Value<long long>           *)this->value_)->value_ : (*this->value_)) : 0;                      } /** @brief Returns the current value, converted to the requested type. */
     166MultiType::operator unsigned long long()   const { return (this->value_) ? ((this->value_->type_ == MT_ulonglong  ) ? ((MT_Value<unsigned long long>  *)this->value_)->value_ : (*this->value_)) : 0;                      } /** @brief Returns the current value, converted to the requested type. */
     167MultiType::operator float()                const { return (this->value_) ? ((this->value_->type_ == MT_float      ) ? ((MT_Value<float>               *)this->value_)->value_ : (*this->value_)) : 0;                      } /** @brief Returns the current value, converted to the requested type. */
     168MultiType::operator double()               const { return (this->value_) ? ((this->value_->type_ == MT_double     ) ? ((MT_Value<double>              *)this->value_)->value_ : (*this->value_)) : 0;                      } /** @brief Returns the current value, converted to the requested type. */
     169MultiType::operator long double()          const { return (this->value_) ? ((this->value_->type_ == MT_longdouble ) ? ((MT_Value<long double>         *)this->value_)->value_ : (*this->value_)) : 0;                      } /** @brief Returns the current value, converted to the requested type. */
     170MultiType::operator bool()                 const { return (this->value_) ? ((this->value_->type_ == MT_bool       ) ? ((MT_Value<bool>                *)this->value_)->value_ : (*this->value_)) : false;                  } /** @brief Returns the current value, converted to the requested type. */
     171MultiType::operator void*()                const { return (this->value_) ? ((this->value_->type_ == MT_void       ) ? ((MT_Value<void*>               *)this->value_)->value_ : (*this->value_)) : (void*)0;               } /** @brief Returns the current value, converted to the requested type. */
     172MultiType::operator std::string()          const { return (this->value_) ? ((this->value_->type_ == MT_string     ) ? ((MT_Value<std::string>         *)this->value_)->value_ : (*this->value_)) : std::string();          } /** @brief Returns the current value, converted to the requested type. */
     173MultiType::operator orxonox::Vector2()     const { return (this->value_) ? ((this->value_->type_ == MT_vector2    ) ? ((MT_Value<orxonox::Vector2>    *)this->value_)->value_ : (*this->value_)) : orxonox::Vector2();     } /** @brief Returns the current value, converted to the requested type. */
     174MultiType::operator orxonox::Vector3()     const { return (this->value_) ? ((this->value_->type_ == MT_vector3    ) ? ((MT_Value<orxonox::Vector3>    *)this->value_)->value_ : (*this->value_)) : orxonox::Vector3();     } /** @brief Returns the current value, converted to the requested type. */
     175MultiType::operator orxonox::Vector4()     const { return (this->value_) ? ((this->value_->type_ == MT_vector4    ) ? ((MT_Value<orxonox::Vector4>    *)this->value_)->value_ : (*this->value_)) : orxonox::Vector4();     } /** @brief Returns the current value, converted to the requested type. */
     176MultiType::operator orxonox::ColourValue() const { return (this->value_) ? ((this->value_->type_ == MT_colourvalue) ? ((MT_Value<orxonox::ColourValue>*)this->value_)->value_ : (*this->value_)) : orxonox::ColourValue(); } /** @brief Returns the current value, converted to the requested type. */
     177MultiType::operator orxonox::Quaternion()  const { return (this->value_) ? ((this->value_->type_ == MT_quaternion ) ? ((MT_Value<orxonox::Quaternion> *)this->value_)->value_ : (*this->value_)) : orxonox::Quaternion();  } /** @brief Returns the current value, converted to the requested type. */
     178MultiType::operator orxonox::Radian()      const { return (this->value_) ? ((this->value_->type_ == MT_radian     ) ? ((MT_Value<orxonox::Radian>     *)this->value_)->value_ : (*this->value_)) : orxonox::Radian();      } /** @brief Returns the current value, converted to the requested type. */
     179MultiType::operator orxonox::Degree()      const { return (this->value_) ? ((this->value_->type_ == MT_degree     ) ? ((MT_Value<orxonox::Degree>     *)this->value_)->value_ : (*this->value_)) : orxonox::Degree();      } /** @brief Returns the current value, converted to the requested type. */
     180
     181template <> void MultiType::createNewValueContainer(const char& value)                 { this->value_ = new MT_Value<char>                (value, MT_char       ); } /** @brief Creates a new value container for the given type. */
     182template <> void MultiType::createNewValueContainer(const unsigned char& value)        { this->value_ = new MT_Value<unsigned char>       (value, MT_uchar      ); } /** @brief Creates a new value container for the given type. */
     183template <> void MultiType::createNewValueContainer(const short& value)                { this->value_ = new MT_Value<short>               (value, MT_short      ); } /** @brief Creates a new value container for the given type. */
     184template <> void MultiType::createNewValueContainer(const unsigned short& value)       { this->value_ = new MT_Value<unsigned short>      (value, MT_ushort     ); } /** @brief Creates a new value container for the given type. */
     185template <> void MultiType::createNewValueContainer(const int& value)                  { this->value_ = new MT_Value<int>                 (value, MT_int        ); } /** @brief Creates a new value container for the given type. */
     186template <> void MultiType::createNewValueContainer(const unsigned int& value)         { this->value_ = new MT_Value<unsigned int>        (value, MT_uint       ); } /** @brief Creates a new value container for the given type. */
     187template <> void MultiType::createNewValueContainer(const long& value)                 { this->value_ = new MT_Value<long>                (value, MT_long       ); } /** @brief Creates a new value container for the given type. */
     188template <> void MultiType::createNewValueContainer(const unsigned long& value)        { this->value_ = new MT_Value<unsigned long>       (value, MT_ulong      ); } /** @brief Creates a new value container for the given type. */
     189template <> void MultiType::createNewValueContainer(const long long& value)            { this->value_ = new MT_Value<long long>           (value, MT_longlong   ); } /** @brief Creates a new value container for the given type. */
     190template <> void MultiType::createNewValueContainer(const unsigned long long& value)   { this->value_ = new MT_Value<unsigned long long>  (value, MT_ulonglong  ); } /** @brief Creates a new value container for the given type. */
     191template <> void MultiType::createNewValueContainer(const float& value)                { this->value_ = new MT_Value<float>               (value, MT_float      ); } /** @brief Creates a new value container for the given type. */
     192template <> void MultiType::createNewValueContainer(const double& value)               { this->value_ = new MT_Value<double>              (value, MT_double     ); } /** @brief Creates a new value container for the given type. */
     193template <> void MultiType::createNewValueContainer(const long double& value)          { this->value_ = new MT_Value<long double>         (value, MT_longdouble ); } /** @brief Creates a new value container for the given type. */
     194template <> void MultiType::createNewValueContainer(const bool& value)                 { this->value_ = new MT_Value<bool>                (value, MT_bool       ); } /** @brief Creates a new value container for the given type. */
     195template <> void MultiType::createNewValueContainer(      void* const& value)          { this->value_ = new MT_Value<void*>               (value, MT_void       ); } /** @brief Creates a new value container for the given type. */
     196template <> void MultiType::createNewValueContainer(const std::string& value)          { this->value_ = new MT_Value<std::string>         (value, MT_string     ); } /** @brief Creates a new value container for the given type. */
     197template <> void MultiType::createNewValueContainer(const orxonox::Vector2& value)     { this->value_ = new MT_Value<orxonox::Vector2>    (value, MT_vector2    ); } /** @brief Creates a new value container for the given type. */
     198template <> void MultiType::createNewValueContainer(const orxonox::Vector3& value)     { this->value_ = new MT_Value<orxonox::Vector3>    (value, MT_vector3    ); } /** @brief Creates a new value container for the given type. */
     199template <> void MultiType::createNewValueContainer(const orxonox::Vector4& value)     { this->value_ = new MT_Value<orxonox::Vector4>    (value, MT_vector4    ); } /** @brief Creates a new value container for the given type. */
     200template <> void MultiType::createNewValueContainer(const orxonox::ColourValue& value) { this->value_ = new MT_Value<orxonox::ColourValue>(value, MT_colourvalue); } /** @brief Creates a new value container for the given type. */
     201template <> void MultiType::createNewValueContainer(const orxonox::Quaternion& value)  { this->value_ = new MT_Value<orxonox::Quaternion> (value, MT_quaternion ); } /** @brief Creates a new value container for the given type. */
     202template <> void MultiType::createNewValueContainer(const orxonox::Radian& value)      { this->value_ = new MT_Value<orxonox::Radian>     (value, MT_radian     ); } /** @brief Creates a new value container for the given type. */
     203template <> void MultiType::createNewValueContainer(const orxonox::Degree& value)      { this->value_ = new MT_Value<orxonox::Degree>     (value, MT_degree     ); } /** @brief Creates a new value container for the given type. */
  • code/trunk/src/util/MultiType.h

    r1757 r1791  
    2727 */
    2828
     29/**
     30    @file MultiType.h
     31    @brief Declaration of the MultiType and some helper constructs.
     32
     33    The MultiType can hold a value of one of the following types:
     34     - all primitives
     35     - all pointers
     36     - string
     37     - Vector2, Vector3, Vector4
     38     - Quaternion
     39     - ColourValue
     40     - Radian, Degree
     41
     42    The MultiType has a "type" determined by the first assigned value, either through
     43     - the constructor,
     44     - the assignment operator= or
     45     - setValue(value).
     46    If you assign another value of another type, the MultiType keeps "it's" type and
     47    converts the new value to this type.
     48
     49    If you want to change the type, there are three possibilities:
     50     - convert<T>() set's the type to T and converts the currently assigned value
     51     - setType<T>() set's the type to T and resets the value
     52     - setValue<T>(value) assigns a new value and changes the type to T.
     53
     54    @example
     55    MultiType a = 10;;         // a has now the type int and the value 10
     56    a.setValue("3.14");        // a has still the type int and "3.14" gets converted, therefore the value is now 3
     57    a.setValue<float>("3.14"); // a has now the type float and "3.14" gets converted to 3.14
     58    a.convert<bool>();         // converts 3.14 to bool, which is true
     59    a = false;                 // assigns false, this is equivalent to a.setValue(false)
     60*/
     61
    2962#ifndef _MultiType_H__
    3063#define _MultiType_H__
     
    3669#include "Math.h"
    3770
     71/**
     72    @brief Enum of all possible types of a MultiType.
     73*/
    3874enum MT_Type
    3975{
     
    64100};
    65101
     102/**
     103    @brief The MultiType can hold a value of many possible types and convert them to other types.
     104
     105    The following types are supported by the MultiType:
     106     - all primitves
     107     - all pointers
     108     - string
     109     - Vector2, Vector3, Vector4
     110     - Quaternion
     111     - ColourValue
     112     - Radian, Degree
     113
     114    The internal type of a MultiType is determined by the first assigned value, but can be
     115    changed by using setType<T>(), convert<T>() or setValue<T>(value). If a value gets assigned
     116    the normal way (operator=, setValue(value)), the value gets converted to the current internal
     117    type of the MultiType.
     118*/
    66119class _UtilExport MultiType
    67120{
     
    69122    template <typename T> friend struct MT_Value;
    70123
     124    /**
     125        @brief MT_ValueBase is an almost pure virtual baseclass of MT_Value<T>, which holds the value of the MultiType.
     126        This class is only used within the MultiType.
     127    */
    71128    struct _UtilExport MT_ValueBase
    72129    {
     
    78135        virtual void reset() = 0;
    79136        virtual void assimilate(const MultiType& other) = 0;
     137
     138        /** @brief Returns the type of the current value. */
    80139        const MT_Type& getType() const { return this->type_; }
    81140
     
    130189        virtual void toString(std::ostream& outstream) const = 0;
    131190
    132         MT_Type type_;
     191        MT_Type type_; //! The type of the current value
    133192    };
    134193
    135194    public:
    136         inline MultiType()                                  : value_(0) {}
    137         inline MultiType(const char& value)                 : value_(0) { this->assignValue(value); }
    138         inline MultiType(const unsigned char& value)        : value_(0) { this->assignValue(value); }
    139         inline MultiType(const short& value)                : value_(0) { this->assignValue(value); }
    140         inline MultiType(const unsigned short& value)       : value_(0) { this->assignValue(value); }
    141         inline MultiType(const int& value)                  : value_(0) { this->assignValue(value); }
    142         inline MultiType(const unsigned int& value)         : value_(0) { this->assignValue(value); }
    143         inline MultiType(const long& value)                 : value_(0) { this->assignValue(value); }
    144         inline MultiType(const unsigned long& value)        : value_(0) { this->assignValue(value); }
    145         inline MultiType(const long long& value)            : value_(0) { this->assignValue(value); }
    146         inline MultiType(const unsigned long long& value)   : value_(0) { this->assignValue(value); }
    147         inline MultiType(const float& value)                : value_(0) { this->assignValue(value); }
    148         inline MultiType(const double& value)               : value_(0) { this->assignValue(value); }
    149         inline MultiType(const long double& value)          : value_(0) { this->assignValue(value); }
    150         inline MultiType(const bool& value)                 : value_(0) { this->assignValue(value); }
    151         inline MultiType(      void* const& value)          : value_(0) { this->assignValue(value); }
    152         inline MultiType(const std::string& value)          : value_(0) { this->assignValue(value); }
    153         inline MultiType(const orxonox::Vector2& value)     : value_(0) { this->assignValue(value); }
    154         inline MultiType(const orxonox::Vector3& value)     : value_(0) { this->assignValue(value); }
    155         inline MultiType(const orxonox::Vector4& value)     : value_(0) { this->assignValue(value); }
    156         inline MultiType(const orxonox::ColourValue& value) : value_(0) { this->assignValue(value); }
    157         inline MultiType(const orxonox::Quaternion& value)  : value_(0) { this->assignValue(value); }
    158         inline MultiType(const orxonox::Radian& value)      : value_(0) { this->assignValue(value); }
    159         inline MultiType(const orxonox::Degree& value)      : value_(0) { this->assignValue(value); }
    160         inline MultiType(const char* value)                 : value_(0) { this->setValue(std::string(value)); }
    161         inline MultiType(const MultiType& other)            : value_(0) { this->setValue(other); }
    162         inline MultiType(MT_Type type)                      : value_(0) { this->setType(type); }
    163 
     195        inline MultiType()                                  : value_(0) {}                                      /** @brief Default constructor: Assigns no value and no type. The type will be determined by the first assignment of a value. */
     196        inline MultiType(const char& value)                 : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
     197        inline MultiType(const unsigned char& value)        : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
     198        inline MultiType(const short& value)                : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
     199        inline MultiType(const unsigned short& value)       : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
     200        inline MultiType(const int& value)                  : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
     201        inline MultiType(const unsigned int& value)         : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
     202        inline MultiType(const long& value)                 : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
     203        inline MultiType(const unsigned long& value)        : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
     204        inline MultiType(const long long& value)            : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
     205        inline MultiType(const unsigned long long& value)   : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
     206        inline MultiType(const float& value)                : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
     207        inline MultiType(const double& value)               : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
     208        inline MultiType(const long double& value)          : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
     209        inline MultiType(const bool& value)                 : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
     210        inline MultiType(      void* const& value)          : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
     211        inline MultiType(const std::string& value)          : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
     212        inline MultiType(const orxonox::Vector2& value)     : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
     213        inline MultiType(const orxonox::Vector3& value)     : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
     214        inline MultiType(const orxonox::Vector4& value)     : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
     215        inline MultiType(const orxonox::ColourValue& value) : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
     216        inline MultiType(const orxonox::Quaternion& value)  : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
     217        inline MultiType(const orxonox::Radian& value)      : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
     218        inline MultiType(const orxonox::Degree& value)      : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
     219        inline MultiType(const char* value)                 : value_(0) { this->setValue(std::string(value)); } /** @brief Constructor: Converts the char array to a std::string, assigns the value and sets the type. */
     220        inline MultiType(const MultiType& other)            : value_(0) { this->setValue(other); }              /** @brief Copyconstructor: Assigns value and type of the other MultiType. */
     221        inline MultiType(MT_Type type)                      : value_(0) { this->setType(type); }                /** @brief Constructor: Sets the type, the next assignment will determine the value. */
     222
     223        /** @brief Destructor: Deletes the MT_Value. */
    164224        inline ~MultiType() { if (this->value_) { delete this->value_; } }
    165225
    166         template <typename V> inline const MultiType& operator=(const V& value)         { this->setValue(value); return (*this); }
    167         inline                       const MultiType& operator=(const MultiType& other) { this->setValue(other); return (*this); }
    168         inline                       const MultiType& operator=(MT_Type type)           { this->setType(type);   return (*this); }
     226        template <typename V> inline const MultiType& operator=(const V& value)         { this->setValue(value); return (*this); } /** @brief Assigns a new value. The value will be converted to the current type of the MultiType. */
     227        template <typename V> inline const MultiType& operator=(V* value)               { this->setValue(value); return (*this); } /** @brief Assigns a pointer. */
     228        inline                       const MultiType& operator=(const MultiType& other) { this->setValue(other); return (*this); } /** @brief Assigns the value of the other MultiType and converts it to the current type of the MultiType. */
     229        inline                       const MultiType& operator=(MT_Type type)           { this->setType(type);   return (*this); } /** @brief Resets the value and changes the type. */
    169230
    170231        inline void                                   setValue(const char& value);
     
    191252        inline void                                   setValue(const orxonox::Radian& value);
    192253        inline void                                   setValue(const orxonox::Degree& value);
     254        inline void                                   setValue(const char* value);
     255        /** @brief Assigns a pointer. */
    193256        template <typename V> inline void             setValue(V* value)               { if (this->value_) { this->value_->setValue((void*)value); } else { this->assignValue((void*)value); } }
     257        /** @brief Assigns the value of the other MultiType and converts it to the current type. */
    194258        void                                          setValue(const MultiType& other) { if (this->value_) { this->value_->assimilate(other); } else { if (other.value_) { this->value_ = other.value_->clone(); } } }
     259        /** @brief Changes the type to T and assigns the new value (which might be of another type than T - it gets converted). */
    195260        template <typename T, typename V> inline void setValue(const V& value)         { this->setType<T>(); this->setValue(value); }
    196         inline void                                   setValue(const char* value);
    197 
     261
     262
     263        /** @brief Copies the other MultiType by assigning value and type. */
    198264        inline void                       copy(const MultiType& other)    { if (this == &other) { return; } if (this->value_) { delete this->value_; } this->value_ = (other.value_) ? other.value_->clone() : 0; }
    199265
    200         template <typename T> inline void convert()                       { this->setValue<T>((T)(*this));  }
    201         inline void                       convert(const MultiType& other) { this->convert(other.getType()); }
     266        template <typename T> inline void convert()                       { this->setValue<T>((T)(*this));  } /** @brief Converts the current value to type T. */
     267        inline void                       convert(const MultiType& other) { this->convert(other.getType()); } /** @brief Converts the current value to the type of the other MultiType. */
    202268        void                              convert(MT_Type type);
    203269
     270        /** @brief Resets the value to the defaultvalue of the current type. */
    204271        inline void                       reset()                         { if (this->value_) { delete this->value_; this->value_ = 0; } }
    205272
    206         template <typename T> inline void setType()                       { this->assignValue(T());             }
    207         inline void                       setType(const MultiType& other) { this->setType(other.getType());     }
    208         inline void                       setType(MT_Type type)           { this->reset(); this->convert(type); }
    209 
     273        template <typename T> inline void setType()                       { this->assignValue(T());                            } /** @brief Resets the value and changes the internal type to T. */
     274        inline void                       setType(const MultiType& other) { this->setType(other.getType());                    } /** @brief Resets the value and changes the internal type to the type of the other MultiType. */
     275        inline void                       setType(MT_Type type)           { this->reset(); this->convert(type); this->reset(); } /** @brief Resets the value and changes the internal type to the given type. */
     276
     277        /** @brief Returns the current type. */
    210278        inline MT_Type                    getType()                 const { return (this->value_) ? this->value_->type_ : MT_null; }
     279        /** @brief Returns true if the current type equals the given type. */
    211280        inline bool                       isType(MT_Type type)      const { return (this->value_) ? (this->value_->type_ == type) : (type == MT_null); }
    212         template <typename T> inline bool isType()                  const { return false; }
     281        /** @brief Returns true if the current type is T. */
     282        template <typename T> inline bool isType()                  const { return false; } // Only works for specialized values - see below
    213283        std::string                       getTypename()             const;
    214284
     
    236306        operator orxonox::Radian()       const;
    237307        operator orxonox::Degree()       const;
     308        /** @brief Returns the current value, converted to a T* pointer. */
    238309        template <class T> operator T*() const { return ((T*)this->operator void*()); }
    239310
    240         inline void getValue(char*                 value) const { if (this->value_) { (*value) = (*this->value_); } }
    241         inline void getValue(unsigned char*        value) const { if (this->value_) { (*value) = (*this->value_); } }
    242         inline void getValue(short*                value) const { if (this->value_) { (*value) = (*this->value_); } }
    243         inline void getValue(unsigned short*       value) const { if (this->value_) { (*value) = (*this->value_); } }
    244         inline void getValue(int*                  value) const { if (this->value_) { (*value) = (*this->value_); } }
    245         inline void getValue(unsigned int*         value) const { if (this->value_) { (*value) = (*this->value_); } }
    246         inline void getValue(long*                 value) const { if (this->value_) { (*value) = (*this->value_); } }
    247         inline void getValue(unsigned long*        value) const { if (this->value_) { (*value) = (*this->value_); } }
    248         inline void getValue(long long*            value) const { if (this->value_) { (*value) = (*this->value_); } }
    249         inline void getValue(unsigned long long*   value) const { if (this->value_) { (*value) = (*this->value_); } }
    250         inline void getValue(float*                value) const { if (this->value_) { (*value) = (*this->value_); } }
    251         inline void getValue(double*               value) const { if (this->value_) { (*value) = (*this->value_); } }
    252         inline void getValue(long double*          value) const { if (this->value_) { (*value) = (*this->value_); } }
    253         inline void getValue(bool*                 value) const { if (this->value_) { (*value) = (*this->value_); } }
    254         inline void getValue(void*                 value) const { if (this->value_) {   value  = (*this->value_); } }
    255         inline void getValue(std::string*          value) const { if (this->value_) { (*value) = this->value_->operator std::string();          } }
    256         inline void getValue(orxonox::Vector2*     value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Vector2();     } }
    257         inline void getValue(orxonox::Vector3*     value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Vector3();     } }
    258         inline void getValue(orxonox::Vector4*     value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Vector4();     } }
    259         inline void getValue(orxonox::ColourValue* value) const { if (this->value_) { (*value) = this->value_->operator orxonox::ColourValue(); } }
    260         inline void getValue(orxonox::Quaternion*  value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Quaternion();  } }
    261         inline void getValue(orxonox::Radian*      value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Radian();      } }
    262         inline void getValue(orxonox::Degree*      value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Degree();      } }
    263 
    264         inline char                     getChar()             const { return this->operator char();                 }
    265         inline unsigned char            getUnsignedChar()     const { return this->operator unsigned char();        }
    266         inline short                    getShort()            const { return this->operator short();                }
    267         inline unsigned short           getUnsignedShort()    const { return this->operator unsigned short();       }
    268         inline int                      getInt()              const { return this->operator int();                  }
    269         inline unsigned int             getUnsignedInt()      const { return this->operator unsigned int();         }
    270         inline long                     getLong()             const { return this->operator long();                 }
    271         inline unsigned long            getUnsignedLong()     const { return this->operator unsigned long();        }
    272         inline long long                getLongLong()         const { return this->operator long long();            }
    273         inline unsigned long long       getUnsignedLongLong() const { return this->operator unsigned long long();   }
    274         inline float                    getFloat()            const { return this->operator float();                }
    275         inline double                   getDouble()           const { return this->operator double();               }
    276         inline long double              getLongDouble()       const { return this->operator long double();          }
    277         inline bool                     getBool()             const { return this->operator bool();                 }
    278         inline void*                    getVoid()             const { return this->operator void*();                }
    279         inline std::string              getString()           const { return this->operator std::string();          }
    280         inline orxonox::Vector2         getVector2()          const { return this->operator orxonox::Vector2();     }
    281         inline orxonox::Vector3         getVector3()          const { return this->operator orxonox::Vector3();     }
    282         inline orxonox::Vector4         getVector4()          const { return this->operator orxonox::Vector4();     }
    283         inline orxonox::ColourValue     getColourValue()      const { return this->operator orxonox::ColourValue(); }
    284         inline orxonox::Quaternion      getQuaternion()       const { return this->operator orxonox::Quaternion();  }
    285         inline orxonox::Radian          getRadian()           const { return this->operator orxonox::Radian();      }
    286         inline orxonox::Degree          getDegree()           const { return this->operator orxonox::Degree();      }
    287         template <typename T> inline T* getPointer()          const { return ((T*)this->getVoid());                 }
     311        inline void getValue(char*                 value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     312        inline void getValue(unsigned char*        value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     313        inline void getValue(short*                value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     314        inline void getValue(unsigned short*       value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     315        inline void getValue(int*                  value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     316        inline void getValue(unsigned int*         value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     317        inline void getValue(long*                 value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     318        inline void getValue(unsigned long*        value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     319        inline void getValue(long long*            value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     320        inline void getValue(unsigned long long*   value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     321        inline void getValue(float*                value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     322        inline void getValue(double*               value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     323        inline void getValue(long double*          value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     324        inline void getValue(bool*                 value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     325        inline void getValue(void*                 value) const { if (this->value_) {   value  = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     326        inline void getValue(std::string*          value) const { if (this->value_) { (*value) = this->value_->operator std::string();          } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     327        inline void getValue(orxonox::Vector2*     value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Vector2();     } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     328        inline void getValue(orxonox::Vector3*     value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Vector3();     } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     329        inline void getValue(orxonox::Vector4*     value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Vector4();     } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     330        inline void getValue(orxonox::ColourValue* value) const { if (this->value_) { (*value) = this->value_->operator orxonox::ColourValue(); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     331        inline void getValue(orxonox::Quaternion*  value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Quaternion();  } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     332        inline void getValue(orxonox::Radian*      value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Radian();      } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     333        inline void getValue(orxonox::Degree*      value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Degree();      } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     334
     335        inline char                     getChar()             const { return this->operator char();                 } /** @brief Returns the current value, converted to the requested type. */
     336        inline unsigned char            getUnsignedChar()     const { return this->operator unsigned char();        } /** @brief Returns the current value, converted to the requested type. */
     337        inline short                    getShort()            const { return this->operator short();                } /** @brief Returns the current value, converted to the requested type. */
     338        inline unsigned short           getUnsignedShort()    const { return this->operator unsigned short();       } /** @brief Returns the current value, converted to the requested type. */
     339        inline int                      getInt()              const { return this->operator int();                  } /** @brief Returns the current value, converted to the requested type. */
     340        inline unsigned int             getUnsignedInt()      const { return this->operator unsigned int();         } /** @brief Returns the current value, converted to the requested type. */
     341        inline long                     getLong()             const { return this->operator long();                 } /** @brief Returns the current value, converted to the requested type. */
     342        inline unsigned long            getUnsignedLong()     const { return this->operator unsigned long();        } /** @brief Returns the current value, converted to the requested type. */
     343        inline long long                getLongLong()         const { return this->operator long long();            } /** @brief Returns the current value, converted to the requested type. */
     344        inline unsigned long long       getUnsignedLongLong() const { return this->operator unsigned long long();   } /** @brief Returns the current value, converted to the requested type. */
     345        inline float                    getFloat()            const { return this->operator float();                } /** @brief Returns the current value, converted to the requested type. */
     346        inline double                   getDouble()           const { return this->operator double();               } /** @brief Returns the current value, converted to the requested type. */
     347        inline long double              getLongDouble()       const { return this->operator long double();          } /** @brief Returns the current value, converted to the requested type. */
     348        inline bool                     getBool()             const { return this->operator bool();                 } /** @brief Returns the current value, converted to the requested type. */
     349        inline void*                    getVoid()             const { return this->operator void*();                } /** @brief Returns the current value, converted to the requested type. */
     350        inline std::string              getString()           const { return this->operator std::string();          } /** @brief Returns the current value, converted to the requested type. */
     351        inline orxonox::Vector2         getVector2()          const { return this->operator orxonox::Vector2();     } /** @brief Returns the current value, converted to the requested type. */
     352        inline orxonox::Vector3         getVector3()          const { return this->operator orxonox::Vector3();     } /** @brief Returns the current value, converted to the requested type. */
     353        inline orxonox::Vector4         getVector4()          const { return this->operator orxonox::Vector4();     } /** @brief Returns the current value, converted to the requested type. */
     354        inline orxonox::ColourValue     getColourValue()      const { return this->operator orxonox::ColourValue(); } /** @brief Returns the current value, converted to the requested type. */
     355        inline orxonox::Quaternion      getQuaternion()       const { return this->operator orxonox::Quaternion();  } /** @brief Returns the current value, converted to the requested type. */
     356        inline orxonox::Radian          getRadian()           const { return this->operator orxonox::Radian();      } /** @brief Returns the current value, converted to the requested type. */
     357        inline orxonox::Degree          getDegree()           const { return this->operator orxonox::Degree();      } /** @brief Returns the current value, converted to the requested type. */
     358        template <typename T> inline T* getPointer()          const { return ((T*)this->getVoid());                 } /** @brief Returns the current value, converted to a T* pointer. */
    288359
    289360    private:
    290         inline void assignValue(const char& value)                 { if (this->value_ && this->value_->type_ == MT_char)        { this->value_->setValue(value); } else { this->changeValueContainer<char>(value);                 } }
    291         inline void assignValue(const unsigned char& value)        { if (this->value_ && this->value_->type_ == MT_uchar)       { this->value_->setValue(value); } else { this->changeValueContainer<unsigned char>(value);        } }
    292         inline void assignValue(const short& value)                { if (this->value_ && this->value_->type_ == MT_short)       { this->value_->setValue(value); } else { this->changeValueContainer<short>(value);                } }
    293         inline void assignValue(const unsigned short& value)       { if (this->value_ && this->value_->type_ == MT_ushort)      { this->value_->setValue(value); } else { this->changeValueContainer<unsigned short>(value);       } }
    294         inline void assignValue(const int& value)                  { if (this->value_ && this->value_->type_ == MT_int)         { this->value_->setValue(value); } else { this->changeValueContainer<int>(value);                  } }
    295         inline void assignValue(const unsigned int& value)         { if (this->value_ && this->value_->type_ == MT_uint)        { this->value_->setValue(value); } else { this->changeValueContainer<unsigned int>(value);         } }
    296         inline void assignValue(const long& value)                 { if (this->value_ && this->value_->type_ == MT_long)        { this->value_->setValue(value); } else { this->changeValueContainer<long>(value);                 } }
    297         inline void assignValue(const unsigned long& value)        { if (this->value_ && this->value_->type_ == MT_ulong)       { this->value_->setValue(value); } else { this->changeValueContainer<unsigned long>(value);        } }
    298         inline void assignValue(const long long& value)            { if (this->value_ && this->value_->type_ == MT_longlong)    { this->value_->setValue(value); } else { this->changeValueContainer<long long>(value);            } }
    299         inline void assignValue(const unsigned long long& value)   { if (this->value_ && this->value_->type_ == MT_ulonglong)   { this->value_->setValue(value); } else { this->changeValueContainer<unsigned long long>(value);   } }
    300         inline void assignValue(const float& value)                { if (this->value_ && this->value_->type_ == MT_float)       { this->value_->setValue(value); } else { this->changeValueContainer<float>(value);                } }
    301         inline void assignValue(const double& value)               { if (this->value_ && this->value_->type_ == MT_double)      { this->value_->setValue(value); } else { this->changeValueContainer<double>(value);               } }
    302         inline void assignValue(const long double& value)          { if (this->value_ && this->value_->type_ == MT_longdouble)  { this->value_->setValue(value); } else { this->changeValueContainer<long double>(value);          } }
    303         inline void assignValue(const bool& value)                 { if (this->value_ && this->value_->type_ == MT_bool)        { this->value_->setValue(value); } else { this->changeValueContainer<bool>(value);                 } }
    304         inline void assignValue(      void* const& value)          { if (this->value_ && this->value_->type_ == MT_void)        { this->value_->setValue(value); } else { this->changeValueContainer<void*>(value);                } }
    305         inline void assignValue(const std::string& value)          { if (this->value_ && this->value_->type_ == MT_string)      { this->value_->setValue(value); } else { this->changeValueContainer<std::string>(value);          } }
    306         inline void assignValue(const orxonox::Vector2& value)     { if (this->value_ && this->value_->type_ == MT_vector2)     { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector2>(value);     } }
    307         inline void assignValue(const orxonox::Vector3& value)     { if (this->value_ && this->value_->type_ == MT_vector3)     { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector3>(value);     } }
    308         inline void assignValue(const orxonox::Vector4& value)     { if (this->value_ && this->value_->type_ == MT_vector4)     { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector4>(value);     } }
    309         inline void assignValue(const orxonox::ColourValue& value) { if (this->value_ && this->value_->type_ == MT_colourvalue) { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::ColourValue>(value); } }
    310         inline void assignValue(const orxonox::Quaternion& value)  { if (this->value_ && this->value_->type_ == MT_quaternion)  { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Quaternion>(value);  } }
    311         inline void assignValue(const orxonox::Radian& value)      { if (this->value_ && this->value_->type_ == MT_radian)      { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Radian>(value);      } }
    312         inline void assignValue(const orxonox::Degree& value)      { if (this->value_ && this->value_->type_ == MT_degree)      { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Degree>(value);      } }
    313 
     361        inline void assignValue(const char& value)                 { if (this->value_ && this->value_->type_ == MT_char)        { this->value_->setValue(value); } else { this->changeValueContainer<char>(value);                 } } /** @brief Assigns a new value by changing type and creating a new container. */
     362        inline void assignValue(const unsigned char& value)        { if (this->value_ && this->value_->type_ == MT_uchar)       { this->value_->setValue(value); } else { this->changeValueContainer<unsigned char>(value);        } } /** @brief Assigns a new value by changing type and creating a new container. */
     363        inline void assignValue(const short& value)                { if (this->value_ && this->value_->type_ == MT_short)       { this->value_->setValue(value); } else { this->changeValueContainer<short>(value);                } } /** @brief Assigns a new value by changing type and creating a new container. */
     364        inline void assignValue(const unsigned short& value)       { if (this->value_ && this->value_->type_ == MT_ushort)      { this->value_->setValue(value); } else { this->changeValueContainer<unsigned short>(value);       } } /** @brief Assigns a new value by changing type and creating a new container. */
     365        inline void assignValue(const int& value)                  { if (this->value_ && this->value_->type_ == MT_int)         { this->value_->setValue(value); } else { this->changeValueContainer<int>(value);                  } } /** @brief Assigns a new value by changing type and creating a new container. */
     366        inline void assignValue(const unsigned int& value)         { if (this->value_ && this->value_->type_ == MT_uint)        { this->value_->setValue(value); } else { this->changeValueContainer<unsigned int>(value);         } } /** @brief Assigns a new value by changing type and creating a new container. */
     367        inline void assignValue(const long& value)                 { if (this->value_ && this->value_->type_ == MT_long)        { this->value_->setValue(value); } else { this->changeValueContainer<long>(value);                 } } /** @brief Assigns a new value by changing type and creating a new container. */
     368        inline void assignValue(const unsigned long& value)        { if (this->value_ && this->value_->type_ == MT_ulong)       { this->value_->setValue(value); } else { this->changeValueContainer<unsigned long>(value);        } } /** @brief Assigns a new value by changing type and creating a new container. */
     369        inline void assignValue(const long long& value)            { if (this->value_ && this->value_->type_ == MT_longlong)    { this->value_->setValue(value); } else { this->changeValueContainer<long long>(value);            } } /** @brief Assigns a new value by changing type and creating a new container. */
     370        inline void assignValue(const unsigned long long& value)   { if (this->value_ && this->value_->type_ == MT_ulonglong)   { this->value_->setValue(value); } else { this->changeValueContainer<unsigned long long>(value);   } } /** @brief Assigns a new value by changing type and creating a new container. */
     371        inline void assignValue(const float& value)                { if (this->value_ && this->value_->type_ == MT_float)       { this->value_->setValue(value); } else { this->changeValueContainer<float>(value);                } } /** @brief Assigns a new value by changing type and creating a new container. */
     372        inline void assignValue(const double& value)               { if (this->value_ && this->value_->type_ == MT_double)      { this->value_->setValue(value); } else { this->changeValueContainer<double>(value);               } } /** @brief Assigns a new value by changing type and creating a new container. */
     373        inline void assignValue(const long double& value)          { if (this->value_ && this->value_->type_ == MT_longdouble)  { this->value_->setValue(value); } else { this->changeValueContainer<long double>(value);          } } /** @brief Assigns a new value by changing type and creating a new container. */
     374        inline void assignValue(const bool& value)                 { if (this->value_ && this->value_->type_ == MT_bool)        { this->value_->setValue(value); } else { this->changeValueContainer<bool>(value);                 } } /** @brief Assigns a new value by changing type and creating a new container. */
     375        inline void assignValue(      void* const& value)          { if (this->value_ && this->value_->type_ == MT_void)        { this->value_->setValue(value); } else { this->changeValueContainer<void*>(value);                } } /** @brief Assigns a new value by changing type and creating a new container. */
     376        inline void assignValue(const std::string& value)          { if (this->value_ && this->value_->type_ == MT_string)      { this->value_->setValue(value); } else { this->changeValueContainer<std::string>(value);          } } /** @brief Assigns a new value by changing type and creating a new container. */
     377        inline void assignValue(const orxonox::Vector2& value)     { if (this->value_ && this->value_->type_ == MT_vector2)     { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector2>(value);     } } /** @brief Assigns a new value by changing type and creating a new container. */
     378        inline void assignValue(const orxonox::Vector3& value)     { if (this->value_ && this->value_->type_ == MT_vector3)     { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector3>(value);     } } /** @brief Assigns a new value by changing type and creating a new container. */
     379        inline void assignValue(const orxonox::Vector4& value)     { if (this->value_ && this->value_->type_ == MT_vector4)     { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector4>(value);     } } /** @brief Assigns a new value by changing type and creating a new container. */
     380        inline void assignValue(const orxonox::ColourValue& value) { if (this->value_ && this->value_->type_ == MT_colourvalue) { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::ColourValue>(value); } } /** @brief Assigns a new value by changing type and creating a new container. */
     381        inline void assignValue(const orxonox::Quaternion& value)  { if (this->value_ && this->value_->type_ == MT_quaternion)  { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Quaternion>(value);  } } /** @brief Assigns a new value by changing type and creating a new container. */
     382        inline void assignValue(const orxonox::Radian& value)      { if (this->value_ && this->value_->type_ == MT_radian)      { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Radian>(value);      } } /** @brief Assigns a new value by changing type and creating a new container. */
     383        inline void assignValue(const orxonox::Degree& value)      { if (this->value_ && this->value_->type_ == MT_degree)      { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Degree>(value);      } } /** @brief Assigns a new value by changing type and creating a new container. */
     384
     385        /** @brief Changes the value container. */
    314386        template <typename T> inline void changeValueContainer(const T& value) { if (this->value_) { delete this->value_; } this->createNewValueContainer<T>(value); }
     387        /** @brief Creates a new value container (works only with specialized types). */
    315388        template <typename T>        void createNewValueContainer(const T& value) { BOOST_STATIC_ASSERT(sizeof(T) == 0); }
    316389
    317         MT_ValueBase* value_;
     390        MT_ValueBase* value_; //! A pointer to the value container
    318391};
    319392
     393/** @brief Puts the MultiType on a stream by using the native << operator of the current type. */
    320394_UtilExport inline std::ostream& operator<<(std::ostream& outstream, const MultiType& mt) { if (mt.value_) { mt.value_->toString(outstream); } return outstream; }
    321395
    322 template <> inline bool MultiType::isType<char>()                 const { return (this->value_ && this->value_->type_ == MT_char);        }
    323 template <> inline bool MultiType::isType<unsigned char>()        const { return (this->value_ && this->value_->type_ == MT_uchar);       }
    324 template <> inline bool MultiType::isType<short>()                const { return (this->value_ && this->value_->type_ == MT_short);       }
    325 template <> inline bool MultiType::isType<unsigned short>()       const { return (this->value_ && this->value_->type_ == MT_ushort);      }
    326 template <> inline bool MultiType::isType<int>()                  const { return (this->value_ && this->value_->type_ == MT_int);         }
    327 template <> inline bool MultiType::isType<unsigned int>()         const { return (this->value_ && this->value_->type_ == MT_uint);        }
    328 template <> inline bool MultiType::isType<long>()                 const { return (this->value_ && this->value_->type_ == MT_long);        }
    329 template <> inline bool MultiType::isType<unsigned long>()        const { return (this->value_ && this->value_->type_ == MT_ulong);       }
    330 template <> inline bool MultiType::isType<long long>()            const { return (this->value_ && this->value_->type_ == MT_longlong);    }
    331 template <> inline bool MultiType::isType<unsigned long long>()   const { return (this->value_ && this->value_->type_ == MT_ulonglong);   }
    332 template <> inline bool MultiType::isType<float>()                const { return (this->value_ && this->value_->type_ == MT_float);       }
    333 template <> inline bool MultiType::isType<double>()               const { return (this->value_ && this->value_->type_ == MT_double);      }
    334 template <> inline bool MultiType::isType<long double>()          const { return (this->value_ && this->value_->type_ == MT_longdouble);  }
    335 template <> inline bool MultiType::isType<bool>()                 const { return (this->value_ && this->value_->type_ == MT_bool);        }
    336 template <> inline bool MultiType::isType<void*>()                const { return (this->value_ && this->value_->type_ == MT_void);        }
    337 template <> inline bool MultiType::isType<std::string>()          const { return (this->value_ && this->value_->type_ == MT_string);      }
    338 template <> inline bool MultiType::isType<orxonox::Vector2>()     const { return (this->value_ && this->value_->type_ == MT_vector2);     }
    339 template <> inline bool MultiType::isType<orxonox::Vector3>()     const { return (this->value_ && this->value_->type_ == MT_vector3);     }
    340 template <> inline bool MultiType::isType<orxonox::Vector4>()     const { return (this->value_ && this->value_->type_ == MT_vector4);     }
    341 template <> inline bool MultiType::isType<orxonox::ColourValue>() const { return (this->value_ && this->value_->type_ == MT_colourvalue); }
    342 template <> inline bool MultiType::isType<orxonox::Quaternion>()  const { return (this->value_ && this->value_->type_ == MT_quaternion);  }
    343 template <> inline bool MultiType::isType<orxonox::Radian>()      const { return (this->value_ && this->value_->type_ == MT_radian);      }
    344 template <> inline bool MultiType::isType<orxonox::Degree>()      const { return (this->value_ && this->value_->type_ == MT_degree);      }
    345 
    346 template <> inline void MultiType::convert<std::string>()          { this->setValue<std::string>         (this->operator std::string());          }
    347 template <> inline void MultiType::convert<orxonox::Vector2>()     { this->setValue<orxonox::Vector2>    (this->operator orxonox::Vector2());     }
    348 template <> inline void MultiType::convert<orxonox::Vector3>()     { this->setValue<orxonox::Vector3>    (this->operator orxonox::Vector3());     }
    349 template <> inline void MultiType::convert<orxonox::Vector4>()     { this->setValue<orxonox::Vector4>    (this->operator orxonox::Vector4());     }
    350 template <> inline void MultiType::convert<orxonox::ColourValue>() { this->setValue<orxonox::ColourValue>(this->operator orxonox::ColourValue()); }
    351 template <> inline void MultiType::convert<orxonox::Quaternion>()  { this->setValue<orxonox::Quaternion> (this->operator orxonox::Quaternion());  }
    352 template <> inline void MultiType::convert<orxonox::Radian>()      { this->setValue<orxonox::Radian>     (this->operator orxonox::Radian());      }
    353 template <> inline void MultiType::convert<orxonox::Degree>()      { this->setValue<orxonox::Degree>     (this->operator orxonox::Degree());      }
    354 
    355 template <> inline void MultiType::convert<const std::string&>()          { this->convert<std::string>();          }
    356 template <> inline void MultiType::convert<const orxonox::Vector2&>()     { this->convert<orxonox::Vector2>();     }
    357 template <> inline void MultiType::convert<const orxonox::Vector3&>()     { this->convert<orxonox::Vector3>();     }
    358 template <> inline void MultiType::convert<const orxonox::Vector4&>()     { this->convert<orxonox::Vector4>();     }
    359 template <> inline void MultiType::convert<const orxonox::ColourValue&>() { this->convert<orxonox::ColourValue>(); }
    360 template <> inline void MultiType::convert<const orxonox::Quaternion&>()  { this->convert<orxonox::Quaternion>();  }
    361 template <> inline void MultiType::convert<const orxonox::Radian&>()      { this->convert<orxonox::Radian>();      }
    362 template <> inline void MultiType::convert<const orxonox::Degree&>()      { this->convert<orxonox::Degree>();      }
     396template <> inline bool MultiType::isType<char>()                 const { return (this->value_ && this->value_->type_ == MT_char);        } /** @brief Returns true if the current type equals the given type. */
     397template <> inline bool MultiType::isType<unsigned char>()        const { return (this->value_ && this->value_->type_ == MT_uchar);       } /** @brief Returns true if the current type equals the given type. */
     398template <> inline bool MultiType::isType<short>()                const { return (this->value_ && this->value_->type_ == MT_short);       } /** @brief Returns true if the current type equals the given type. */
     399template <> inline bool MultiType::isType<unsigned short>()       const { return (this->value_ && this->value_->type_ == MT_ushort);      } /** @brief Returns true if the current type equals the given type. */
     400template <> inline bool MultiType::isType<int>()                  const { return (this->value_ && this->value_->type_ == MT_int);         } /** @brief Returns true if the current type equals the given type. */
     401template <> inline bool MultiType::isType<unsigned int>()         const { return (this->value_ && this->value_->type_ == MT_uint);        } /** @brief Returns true if the current type equals the given type. */
     402template <> inline bool MultiType::isType<long>()                 const { return (this->value_ && this->value_->type_ == MT_long);        } /** @brief Returns true if the current type equals the given type. */
     403template <> inline bool MultiType::isType<unsigned long>()        const { return (this->value_ && this->value_->type_ == MT_ulong);       } /** @brief Returns true if the current type equals the given type. */
     404template <> inline bool MultiType::isType<long long>()            const { return (this->value_ && this->value_->type_ == MT_longlong);    } /** @brief Returns true if the current type equals the given type. */
     405template <> inline bool MultiType::isType<unsigned long long>()   const { return (this->value_ && this->value_->type_ == MT_ulonglong);   } /** @brief Returns true if the current type equals the given type. */
     406template <> inline bool MultiType::isType<float>()                const { return (this->value_ && this->value_->type_ == MT_float);       } /** @brief Returns true if the current type equals the given type. */
     407template <> inline bool MultiType::isType<double>()               const { return (this->value_ && this->value_->type_ == MT_double);      } /** @brief Returns true if the current type equals the given type. */
     408template <> inline bool MultiType::isType<long double>()          const { return (this->value_ && this->value_->type_ == MT_longdouble);  } /** @brief Returns true if the current type equals the given type. */
     409template <> inline bool MultiType::isType<bool>()                 const { return (this->value_ && this->value_->type_ == MT_bool);        } /** @brief Returns true if the current type equals the given type. */
     410template <> inline bool MultiType::isType<void*>()                const { return (this->value_ && this->value_->type_ == MT_void);        } /** @brief Returns true if the current type equals the given type. */
     411template <> inline bool MultiType::isType<std::string>()          const { return (this->value_ && this->value_->type_ == MT_string);      } /** @brief Returns true if the current type equals the given type. */
     412template <> inline bool MultiType::isType<orxonox::Vector2>()     const { return (this->value_ && this->value_->type_ == MT_vector2);     } /** @brief Returns true if the current type equals the given type. */
     413template <> inline bool MultiType::isType<orxonox::Vector3>()     const { return (this->value_ && this->value_->type_ == MT_vector3);     } /** @brief Returns true if the current type equals the given type. */
     414template <> inline bool MultiType::isType<orxonox::Vector4>()     const { return (this->value_ && this->value_->type_ == MT_vector4);     } /** @brief Returns true if the current type equals the given type. */
     415template <> inline bool MultiType::isType<orxonox::ColourValue>() const { return (this->value_ && this->value_->type_ == MT_colourvalue); } /** @brief Returns true if the current type equals the given type. */
     416template <> inline bool MultiType::isType<orxonox::Quaternion>()  const { return (this->value_ && this->value_->type_ == MT_quaternion);  } /** @brief Returns true if the current type equals the given type. */
     417template <> inline bool MultiType::isType<orxonox::Radian>()      const { return (this->value_ && this->value_->type_ == MT_radian);      } /** @brief Returns true if the current type equals the given type. */
     418template <> inline bool MultiType::isType<orxonox::Degree>()      const { return (this->value_ && this->value_->type_ == MT_degree);      } /** @brief Returns true if the current type equals the given type. */
     419
     420// Specialization to avoid ambiguities with the conversion operator
     421template <> inline void MultiType::convert<std::string>()          { this->setValue<std::string>         (this->operator std::string());          } /** @brief Converts the current value to the given type. */
     422template <> inline void MultiType::convert<orxonox::Vector2>()     { this->setValue<orxonox::Vector2>    (this->operator orxonox::Vector2());     } /** @brief Converts the current value to the given type. */
     423template <> inline void MultiType::convert<orxonox::Vector3>()     { this->setValue<orxonox::Vector3>    (this->operator orxonox::Vector3());     } /** @brief Converts the current value to the given type. */
     424template <> inline void MultiType::convert<orxonox::Vector4>()     { this->setValue<orxonox::Vector4>    (this->operator orxonox::Vector4());     } /** @brief Converts the current value to the given type. */
     425template <> inline void MultiType::convert<orxonox::ColourValue>() { this->setValue<orxonox::ColourValue>(this->operator orxonox::ColourValue()); } /** @brief Converts the current value to the given type. */
     426template <> inline void MultiType::convert<orxonox::Quaternion>()  { this->setValue<orxonox::Quaternion> (this->operator orxonox::Quaternion());  } /** @brief Converts the current value to the given type. */
     427template <> inline void MultiType::convert<orxonox::Radian>()      { this->setValue<orxonox::Radian>     (this->operator orxonox::Radian());      } /** @brief Converts the current value to the given type. */
     428template <> inline void MultiType::convert<orxonox::Degree>()      { this->setValue<orxonox::Degree>     (this->operator orxonox::Degree());      } /** @brief Converts the current value to the given type. */
     429
     430// Specialization to avoid ambiguities with the conversion operator
     431template <> inline void MultiType::convert<const std::string&>()          { this->convert<std::string>();          } /** @brief Converts the current value to the given type. */
     432template <> inline void MultiType::convert<const orxonox::Vector2&>()     { this->convert<orxonox::Vector2>();     } /** @brief Converts the current value to the given type. */
     433template <> inline void MultiType::convert<const orxonox::Vector3&>()     { this->convert<orxonox::Vector3>();     } /** @brief Converts the current value to the given type. */
     434template <> inline void MultiType::convert<const orxonox::Vector4&>()     { this->convert<orxonox::Vector4>();     } /** @brief Converts the current value to the given type. */
     435template <> inline void MultiType::convert<const orxonox::ColourValue&>() { this->convert<orxonox::ColourValue>(); } /** @brief Converts the current value to the given type. */
     436template <> inline void MultiType::convert<const orxonox::Quaternion&>()  { this->convert<orxonox::Quaternion>();  } /** @brief Converts the current value to the given type. */
     437template <> inline void MultiType::convert<const orxonox::Radian&>()      { this->convert<orxonox::Radian>();      } /** @brief Converts the current value to the given type. */
     438template <> inline void MultiType::convert<const orxonox::Degree&>()      { this->convert<orxonox::Degree>();      } /** @brief Converts the current value to the given type. */
    363439
    364440template <> void MultiType::createNewValueContainer(const char& value);
     
    386462template <> void MultiType::createNewValueContainer(const orxonox::Degree& value);
    387463
    388 inline void MultiType::setValue(const char& value)                  { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } }
    389 inline void MultiType::setValue(const unsigned char& value)         { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } }
    390 inline void MultiType::setValue(const short& value)                 { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } }
    391 inline void MultiType::setValue(const unsigned short& value)        { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } }
    392 inline void MultiType::setValue(const int& value)                   { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } }
    393 inline void MultiType::setValue(const unsigned int& value)          { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } }
    394 inline void MultiType::setValue(const long& value)                  { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } }
    395 inline void MultiType::setValue(const unsigned long& value)         { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } }
    396 inline void MultiType::setValue(const long long& value)             { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } }
    397 inline void MultiType::setValue(const unsigned long long& value)    { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } }
    398 inline void MultiType::setValue(const float& value)                 { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } }
    399 inline void MultiType::setValue(const double& value)                { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } }
    400 inline void MultiType::setValue(const long double& value)           { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } }
    401 inline void MultiType::setValue(const bool& value)                  { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } }
    402 inline void MultiType::setValue(      void* const& value)           { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } }
    403 inline void MultiType::setValue(const std::string& value)           { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } }
    404 inline void MultiType::setValue(const orxonox::Vector2& value)      { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } }
    405 inline void MultiType::setValue(const orxonox::Vector3& value)      { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } }
    406 inline void MultiType::setValue(const orxonox::Vector4& value)      { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } }
    407 inline void MultiType::setValue(const orxonox::ColourValue& value)  { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } }
    408 inline void MultiType::setValue(const orxonox::Quaternion& value)   { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } }
    409 inline void MultiType::setValue(const orxonox::Radian& value)       { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } }
    410 inline void MultiType::setValue(const orxonox::Degree& value)       { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } }
    411 
    412 inline void MultiType::setValue(const char* value)                  { if (this->value_) { this->value_->setValue(std::string(value)); } else { this->assignValue(std::string(value)); } }
     464inline void MultiType::setValue(const char& value)                  { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
     465inline void MultiType::setValue(const unsigned char& value)         { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
     466inline void MultiType::setValue(const short& value)                 { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
     467inline void MultiType::setValue(const unsigned short& value)        { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
     468inline void MultiType::setValue(const int& value)                   { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
     469inline void MultiType::setValue(const unsigned int& value)          { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
     470inline void MultiType::setValue(const long& value)                  { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
     471inline void MultiType::setValue(const unsigned long& value)         { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
     472inline void MultiType::setValue(const long long& value)             { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
     473inline void MultiType::setValue(const unsigned long long& value)    { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
     474inline void MultiType::setValue(const float& value)                 { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
     475inline void MultiType::setValue(const double& value)                { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
     476inline void MultiType::setValue(const long double& value)           { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
     477inline void MultiType::setValue(const bool& value)                  { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
     478inline void MultiType::setValue(      void* const& value)           { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
     479inline void MultiType::setValue(const std::string& value)           { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
     480inline void MultiType::setValue(const orxonox::Vector2& value)      { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
     481inline void MultiType::setValue(const orxonox::Vector3& value)      { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
     482inline void MultiType::setValue(const orxonox::Vector4& value)      { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
     483inline void MultiType::setValue(const orxonox::ColourValue& value)  { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
     484inline void MultiType::setValue(const orxonox::Quaternion& value)   { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
     485inline void MultiType::setValue(const orxonox::Radian& value)       { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
     486inline void MultiType::setValue(const orxonox::Degree& value)       { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
     487
     488inline void MultiType::setValue(const char* value)                  { if (this->value_) { this->value_->setValue(std::string(value)); } else { this->assignValue(std::string(value)); } }  /** @brief Assigns the given value and converts it to the current type. */
    413489
    414490#endif /* _MultiType_H__ */
  • code/trunk/src/util/MultiTypeValue.h

    r1747 r1791  
    2727 */
    2828
     29/**
     30    @file MultiTypeValue.h
     31    @brief Declaration and Implementation of the MT_Value<T> class.
     32
     33    The MT_Value<T> class is used to hold a value of type T within a MultiType.
     34*/
     35
    2936#ifndef _MultiTypeValue_H__
    3037#define _MultiTypeValue_H__
     
    3441#include "MultiType.h"
    3542
     43/**
     44    @brief The MT_Value<T> class is used to hold a value of type T within a MultiType.
     45*/
    3646template <typename T>
    3747struct MT_Value : public MultiType::MT_ValueBase
    3848{
     49    /** @brief Constructor: Assigns the value and the type identifier. */
    3950    MT_Value(const T& value, MT_Type type) : MT_ValueBase(type), value_(value) {}
    4051
     52    /** @brief Creates a copy of itself. */
    4153    inline MT_ValueBase* clone() const { return new MT_Value<T>(this->value_, this->type_); }
     54
     55    /** @brief Resets the current value to the default. */
    4256    inline void reset() { this->value_ = T(); }
     57
     58    /** @brief Assigns the value of the other MultiType, converted to T. @param other The other MultiType */
    4359    inline void assimilate(const MultiType& other) { if (other.value_) { T temp; other.getValue(&temp); this->value_ = temp; } else { this->value_ = T(); } }
    4460
    45     inline void setValue(const char& value)                 { this->value_ = getConvertedValue<char,                 T>(value); }
    46     inline void setValue(const unsigned char& value)        { this->value_ = getConvertedValue<unsigned char,        T>(value); }
    47     inline void setValue(const short& value)                { this->value_ = getConvertedValue<short,                T>(value); }
    48     inline void setValue(const unsigned short& value)       { this->value_ = getConvertedValue<unsigned short,       T>(value); }
    49     inline void setValue(const int& value)                  { this->value_ = getConvertedValue<int,                  T>(value); }
    50     inline void setValue(const unsigned int& value)         { this->value_ = getConvertedValue<unsigned int,         T>(value); }
    51     inline void setValue(const long& value)                 { this->value_ = getConvertedValue<long,                 T>(value); }
    52     inline void setValue(const unsigned long& value)        { this->value_ = getConvertedValue<unsigned long,        T>(value); }
    53     inline void setValue(const long long& value)            { this->value_ = getConvertedValue<long long,            T>(value); }
    54     inline void setValue(const unsigned long long& value)   { this->value_ = getConvertedValue<unsigned long long,   T>(value); }
    55     inline void setValue(const float& value)                { this->value_ = getConvertedValue<float,                T>(value); }
    56     inline void setValue(const double& value)               { this->value_ = getConvertedValue<double,               T>(value); }
    57     inline void setValue(const long double& value)          { this->value_ = getConvertedValue<long double,          T>(value); }
    58     inline void setValue(const bool& value)                 { this->value_ = getConvertedValue<bool,                 T>(value); }
    59     inline void setValue(      void* const& value)          { this->value_ = getConvertedValue<void*,                T>(value); }
    60     inline void setValue(const std::string& value)          { this->value_ = getConvertedValue<std::string,          T>(value); }
    61     inline void setValue(const orxonox::Vector2& value)     { this->value_ = getConvertedValue<orxonox::Vector2,     T>(value); }
    62     inline void setValue(const orxonox::Vector3& value)     { this->value_ = getConvertedValue<orxonox::Vector3,     T>(value); }
    63     inline void setValue(const orxonox::Vector4& value)     { this->value_ = getConvertedValue<orxonox::Vector4,     T>(value); }
    64     inline void setValue(const orxonox::ColourValue& value) { this->value_ = getConvertedValue<orxonox::ColourValue, T>(value); }
    65     inline void setValue(const orxonox::Quaternion& value)  { this->value_ = getConvertedValue<orxonox::Quaternion,  T>(value); }
    66     inline void setValue(const orxonox::Radian& value)      { this->value_ = getConvertedValue<orxonox::Radian,      T>(value); }
    67     inline void setValue(const orxonox::Degree& value)      { this->value_ = getConvertedValue<orxonox::Degree,      T>(value); }
     61    inline void setValue(const char& value)                 { this->value_ = getConvertedValue<char,                 T>(value); } /** @brief Assigns the value by converting it to T. */
     62    inline void setValue(const unsigned char& value)        { this->value_ = getConvertedValue<unsigned char,        T>(value); } /** @brief Assigns the value by converting it to T. */
     63    inline void setValue(const short& value)                { this->value_ = getConvertedValue<short,                T>(value); } /** @brief Assigns the value by converting it to T. */
     64    inline void setValue(const unsigned short& value)       { this->value_ = getConvertedValue<unsigned short,       T>(value); } /** @brief Assigns the value by converting it to T. */
     65    inline void setValue(const int& value)                  { this->value_ = getConvertedValue<int,                  T>(value); } /** @brief Assigns the value by converting it to T. */
     66    inline void setValue(const unsigned int& value)         { this->value_ = getConvertedValue<unsigned int,         T>(value); } /** @brief Assigns the value by converting it to T. */
     67    inline void setValue(const long& value)                 { this->value_ = getConvertedValue<long,                 T>(value); } /** @brief Assigns the value by converting it to T. */
     68    inline void setValue(const unsigned long& value)        { this->value_ = getConvertedValue<unsigned long,        T>(value); } /** @brief Assigns the value by converting it to T. */
     69    inline void setValue(const long long& value)            { this->value_ = getConvertedValue<long long,            T>(value); } /** @brief Assigns the value by converting it to T. */
     70    inline void setValue(const unsigned long long& value)   { this->value_ = getConvertedValue<unsigned long long,   T>(value); } /** @brief Assigns the value by converting it to T. */
     71    inline void setValue(const float& value)                { this->value_ = getConvertedValue<float,                T>(value); } /** @brief Assigns the value by converting it to T. */
     72    inline void setValue(const double& value)               { this->value_ = getConvertedValue<double,               T>(value); } /** @brief Assigns the value by converting it to T. */
     73    inline void setValue(const long double& value)          { this->value_ = getConvertedValue<long double,          T>(value); } /** @brief Assigns the value by converting it to T. */
     74    inline void setValue(const bool& value)                 { this->value_ = getConvertedValue<bool,                 T>(value); } /** @brief Assigns the value by converting it to T. */
     75    inline void setValue(      void* const& value)          { this->value_ = getConvertedValue<void*,                T>(value); } /** @brief Assigns the value by converting it to T. */
     76    inline void setValue(const std::string& value)          { this->value_ = getConvertedValue<std::string,          T>(value); } /** @brief Assigns the value by converting it to T. */
     77    inline void setValue(const orxonox::Vector2& value)     { this->value_ = getConvertedValue<orxonox::Vector2,     T>(value); } /** @brief Assigns the value by converting it to T. */
     78    inline void setValue(const orxonox::Vector3& value)     { this->value_ = getConvertedValue<orxonox::Vector3,     T>(value); } /** @brief Assigns the value by converting it to T. */
     79    inline void setValue(const orxonox::Vector4& value)     { this->value_ = getConvertedValue<orxonox::Vector4,     T>(value); } /** @brief Assigns the value by converting it to T. */
     80    inline void setValue(const orxonox::ColourValue& value) { this->value_ = getConvertedValue<orxonox::ColourValue, T>(value); } /** @brief Assigns the value by converting it to T. */
     81    inline void setValue(const orxonox::Quaternion& value)  { this->value_ = getConvertedValue<orxonox::Quaternion,  T>(value); } /** @brief Assigns the value by converting it to T. */
     82    inline void setValue(const orxonox::Radian& value)      { this->value_ = getConvertedValue<orxonox::Radian,      T>(value); } /** @brief Assigns the value by converting it to T. */
     83    inline void setValue(const orxonox::Degree& value)      { this->value_ = getConvertedValue<orxonox::Degree,      T>(value); } /** @brief Assigns the value by converting it to T. */
    6884
    69     inline operator char()                 const { return getConvertedValue<T, char>                (this->value_, 0); }
    70     inline operator unsigned char()        const { return getConvertedValue<T, unsigned char>       (this->value_, 0); }
    71     inline operator short()                const { return getConvertedValue<T, short>               (this->value_, 0); }
    72     inline operator unsigned short()       const { return getConvertedValue<T, unsigned short>      (this->value_, 0); }
    73     inline operator int()                  const { return getConvertedValue<T, int>                 (this->value_, 0); }
    74     inline operator unsigned int()         const { return getConvertedValue<T, unsigned int>        (this->value_, 0); }
    75     inline operator long()                 const { return getConvertedValue<T, long>                (this->value_, 0); }
    76     inline operator unsigned long()        const { return getConvertedValue<T, unsigned long>       (this->value_, 0); }
    77     inline operator long long()            const { return getConvertedValue<T, long long>           (this->value_, 0); }
    78     inline operator unsigned long long()   const { return getConvertedValue<T, unsigned long long>  (this->value_, 0); }
    79     inline operator float()                const { return getConvertedValue<T, float>               (this->value_, 0); }
    80     inline operator double()               const { return getConvertedValue<T, double>              (this->value_, 0); }
    81     inline operator long double()          const { return getConvertedValue<T, long double>         (this->value_, 0); }
    82     inline operator bool()                 const { return getConvertedValue<T, bool>                (this->value_, false); }
    83     inline operator void*()                const { return getConvertedValue<T, void*>               (this->value_, 0); }
    84     inline operator std::string()          const { return getConvertedValue<T, std::string>         (this->value_); }
    85     inline operator orxonox::Vector2()     const { return getConvertedValue<T, orxonox::Vector2>    (this->value_); }
    86     inline operator orxonox::Vector3()     const { return getConvertedValue<T, orxonox::Vector3>    (this->value_); }
    87     inline operator orxonox::Vector4()     const { return getConvertedValue<T, orxonox::Vector4>    (this->value_); }
    88     inline operator orxonox::ColourValue() const { return getConvertedValue<T, orxonox::ColourValue>(this->value_); }
    89     inline operator orxonox::Quaternion()  const { return getConvertedValue<T, orxonox::Quaternion> (this->value_); }
    90     inline operator orxonox::Radian()      const { return getConvertedValue<T, orxonox::Radian>     (this->value_); }
    91     inline operator orxonox::Degree()      const { return getConvertedValue<T, orxonox::Degree>     (this->value_); }
     85    inline operator char()                 const { return getConvertedValue<T, char>                (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
     86    inline operator unsigned char()        const { return getConvertedValue<T, unsigned char>       (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
     87    inline operator short()                const { return getConvertedValue<T, short>               (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
     88    inline operator unsigned short()       const { return getConvertedValue<T, unsigned short>      (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
     89    inline operator int()                  const { return getConvertedValue<T, int>                 (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
     90    inline operator unsigned int()         const { return getConvertedValue<T, unsigned int>        (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
     91    inline operator long()                 const { return getConvertedValue<T, long>                (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
     92    inline operator unsigned long()        const { return getConvertedValue<T, unsigned long>       (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
     93    inline operator long long()            const { return getConvertedValue<T, long long>           (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
     94    inline operator unsigned long long()   const { return getConvertedValue<T, unsigned long long>  (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
     95    inline operator float()                const { return getConvertedValue<T, float>               (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
     96    inline operator double()               const { return getConvertedValue<T, double>              (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
     97    inline operator long double()          const { return getConvertedValue<T, long double>         (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
     98    inline operator bool()                 const { return getConvertedValue<T, bool>                (this->value_, false); } /** @brief Returns the current value, converted to the requested type. */
     99    inline operator void*()                const { return getConvertedValue<T, void*>               (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
     100    inline operator std::string()          const { return getConvertedValue<T, std::string>         (this->value_); }        /** @brief Returns the current value, converted to the requested type. */
     101    inline operator orxonox::Vector2()     const { return getConvertedValue<T, orxonox::Vector2>    (this->value_); }        /** @brief Returns the current value, converted to the requested type. */
     102    inline operator orxonox::Vector3()     const { return getConvertedValue<T, orxonox::Vector3>    (this->value_); }        /** @brief Returns the current value, converted to the requested type. */
     103    inline operator orxonox::Vector4()     const { return getConvertedValue<T, orxonox::Vector4>    (this->value_); }        /** @brief Returns the current value, converted to the requested type. */
     104    inline operator orxonox::ColourValue() const { return getConvertedValue<T, orxonox::ColourValue>(this->value_); }        /** @brief Returns the current value, converted to the requested type. */
     105    inline operator orxonox::Quaternion()  const { return getConvertedValue<T, orxonox::Quaternion> (this->value_); }        /** @brief Returns the current value, converted to the requested type. */
     106    inline operator orxonox::Radian()      const { return getConvertedValue<T, orxonox::Radian>     (this->value_); }        /** @brief Returns the current value, converted to the requested type. */
     107    inline operator orxonox::Degree()      const { return getConvertedValue<T, orxonox::Degree>     (this->value_); }        /** @brief Returns the current value, converted to the requested type. */
    92108
     109    /** @brief Puts the current value on the stream */
    93110    inline void toString(std::ostream& outstream) const { outstream << this->value_; }
    94111
    95     T value_;
     112    T value_; //! The stored value
    96113};
    97114
  • code/trunk/src/util/OutputBuffer.cc

    r1784 r1791  
    2727 */
    2828
     29/**
     30    @file OutputBuffer.cc
     31    @brief Implementation of the OutputBuffer.
     32*/
     33
    2934#include "OutputBuffer.h"
    30 
    3135
    3236namespace orxonox
    3337{
    34     const int OUTPUTBUFFER_MAX_LINE_LENGTH = 16384;
     38    const int OUTPUTBUFFER_MAX_LINE_LENGTH = 16384; //! The maximal number of lines that can be stored within the OutputBuffer.
    3539
     40    /**
     41        @brief Adds a new listener to the list.
     42        @param listener The new listener
     43    */
    3644    void OutputBuffer::registerListener(OutputBufferListener* listener)
    3745    {
     
    3947    }
    4048
     49    /**
     50        @brief Removes a listener from the list.
     51        @param listener The listener
     52    */
    4153    void OutputBuffer::unregisterListener(OutputBufferListener* listener)
    4254    {
     
    5062    }
    5163
     64    /**
     65        @brief Puts a stream manipulator to the stream.
     66        @param manipulator The manipulator
     67    */
    5268    OutputBuffer& OutputBuffer::operator<<(std::ostream& (*manipulator)(std::ostream&))
    5369    {
     
    5773    }
    5874
     75    /**
     76        @brief Puts a stream manipulator to the stream.
     77        @param manipulator The manipulator
     78    */
    5979    OutputBuffer& OutputBuffer::operator<<(std::ios& (*manipulator)(std::ios&))
    6080    {
     
    6484    }
    6585
     86    /**
     87        @brief Puts a stream manipulator to the stream.
     88        @param manipulator The manipulator
     89    */
    6690    OutputBuffer& OutputBuffer::operator<<(std::ios_base& (*manipulator)(std::ios_base&))
    6791    {
     
    7195    }
    7296
     97    /**
     98        @brief Removes the first line from the stream and assigns it to a given string object.
     99        @param output The string object to assign the first line
     100        @return True if there was at least one line in the stream and this line was successfully assigned
     101
     102        It's important to know the returned line will be removed from the stream. If there are more than one
     103        listener, they have to cooperate to avoid conflicts.
     104    */
    73105    bool OutputBuffer::getLine(std::string* output)
    74106    {
     
    90122    }
    91123
     124    /**
     125        @brief Calls the outputChanged() function of all registered listeners.
     126    */
    92127    void OutputBuffer::callListeners()
    93128    {
  • code/trunk/src/util/OutputBuffer.h

    r1747 r1791  
    2727 */
    2828
     29/**
     30    @file OutputBuffer.h
     31    @brief Declaration of the OutputBuffer class.
     32
     33    The OutputBuffer acts almost like std::ostream. You can put text and other values to the
     34    OutputBuffer by using the << operator. The OutputBuffer stores the text and calls registerd
     35    listeners if new text gets assigned.
     36    The listeners are then able to retrieve the text line by line.
     37
     38    It's important to know that getLine actually removes the line from the OutputBuffer, so it's
     39    better to only have one "active" listener.
     40*/
     41
    2942#ifndef _OutputBuffer_H__
    3043#define _OutputBuffer_H__
     
    3851namespace orxonox
    3952{
     53    /**
     54        @brief A pure virtual baseclass for classes that want to register as listener to an OutputBuffer.
     55
     56        This class is pure virtual, so an inheriting class has to implement the function on it's own.
     57        The function get's called, if an instance of the inheriting class registers as a listener at
     58        an OutputBuffer and this buffer changes.
     59    */
    4060    class _UtilExport OutputBufferListener
    4161    {
     
    4969    };
    5070
     71    /**
     72        @brief The OutputBuffer acts almost like std::ostream and stores the assigned text.
     73
     74        If text gets assigned by using the << operator or another function, the OutputBuffer
     75        calls it's listeners, allowing them to retrieve the text line by line.
     76
     77        It's important to know that getLine actually removes the line from the OutputBuffer, so it's
     78        better to only have one "active" listener.
     79    */
    5180    class _UtilExport OutputBuffer
    5281    {
     
    5584            ~OutputBuffer() {}
    5685
     86            /**
     87                @brief Puts some object/value to the OutputBuffer. The text gets assigned and the OutputBuffer calls it's listeners.
     88                @param object The object/value to assign
     89            */
    5790            template <class T>
    5891            inline OutputBuffer& operator<<(T object)
     
    6396            }
    6497
     98            /**
     99                @brief Reads the stored text of the other OutputBuffer and calls the listeners.
     100                @param object The other OutputBuffer
     101            */
    65102            template <const OutputBuffer&>
    66103            inline OutputBuffer& operator<<(const OutputBuffer& object)
     
    75112            OutputBuffer& operator<<(std::ios_base& (*manipulator)(std::ios_base&));
    76113
     114            /**
     115                @brief Does the same like operator<<: Assigns the object to the stream and calls the listeners.
     116                @param object The object/value
     117            */
    77118            template <class T>
    78119            inline void add(T object)
     
    82123            }
    83124
     125            /**
     126                @brief Assigns an object/value and adds std::endl.
     127                @param object The object/value
     128            */
    84129            template <class T>
    85130            inline void addLine(T object)
     
    89134            }
    90135
     136            /**
     137                @brief Puts std::endl to the stream and calls the listeners.
     138            */
    91139            inline void newline()
    92140            {
     
    95143            }
    96144
     145            /**
     146                @brief Flushes the stored text (~empties the OutputBuffer).
     147            */
    97148            inline void flush()
    98149            {
     
    105156            void unregisterListener(OutputBufferListener* listener);
    106157
     158            /**
     159                @brief Returns the internal stringstream object.
     160            */
    107161            inline std::stringstream& getStream()
    108                 { return this->stream_; }
     162            {
     163                return this->stream_;
     164            }
    109165
    110166        private:
    111167            void callListeners();
    112168
    113             std::stringstream stream_;
    114             std::list<OutputBufferListener*> listeners_;
     169            std::stringstream stream_;                   //! The stringstream that stores the assigned text
     170            std::list<OutputBufferListener*> listeners_; //! A list of all listeners
    115171    };
    116172}
  • code/trunk/src/util/OutputHandler.cc

    r1747 r1791  
    4646        this->logfilename_ = logfilename;
    4747        this->logfile_.open(this->logfilename_.c_str(), std::fstream::out);
    48         this->logfile_ << "Started log at yyyy/mm/dd hh:mm:ss" << std::endl;
     48        this->logfile_ << "Started log at yyyy/mm/dd hh:mm:ss" << std::endl; // Todo: Get date and time
    4949        this->logfile_.flush();
    5050    }
     
    122122
    123123    /**
    124         @brief Overloaded << operator, redirects the output to the console and the logfile.
     124        @brief Overloaded << operator, redirects the output to the console, the logfile and the ingame shell.
    125125        @param manipulator A function, manipulating the outstream.
    126126        @return A reference to the OutputHandler itself
     
    144144
    145145    /**
    146         @brief Overloaded << operator, redirects the output to the console and the logfile.
     146        @brief Overloaded << operator, redirects the output to the console, the logfile and the ingame shell.
    147147        @param manipulator A function, manipulating the outstream.
    148148        @return A reference to the OutputHandler itself
     
    166166
    167167    /**
    168         @brief Overloaded << operator, redirects the output to the console and the logfile.
     168        @brief Overloaded << operator, redirects the output to the console, the logfile and the ingame shell.
    169169        @param manipulator A function, manipulating the outstream.
    170170        @return A reference to the OutputHandler itself
  • code/trunk/src/util/OutputHandler.h

    r1747 r1791  
    3232
    3333    The OutputHandler acts like std::cout, but output isn't only shown in the console,
    34     but also written to the logfile.
     34    but also written to the logfile and the ingame shell.
    3535*/
    3636
     
    4848namespace orxonox
    4949{
    50     //! The OutputHandler acts like std::cout, but redirects output to the console AND the logfile.
     50    //! The OutputHandler acts like std::cout, but redirects output to the console, the logfile and the ingame shell.
    5151    class _UtilExport OutputHandler
    5252    {
  • code/trunk/src/util/String.cc

    r1625 r1791  
    2727 */
    2828
     29/**
     30    @file String.cc
     31    @brief Implementation of several string manipulation functions.
     32*/
     33
    2934#include "String.h"
    3035
     
    3338
    3439/**
    35     @brief Blank string as variable so you can use const std::string& even
    36            if you have to return "".
     40    @brief Blank string as variable so you can use const std::string& even if you have to return "".
    3741*/
    3842std::string blankString = "";
     
    273277}
    274278
     279/**
     280    @brief Adds backslashes to the given string which makes special chars visible. Existing slashes will be doubled.
     281    @param str The string to manipulate
     282    @return The string with added slashes
     283*/
    275284std::string addSlashes(const std::string& str)
    276285{
     
    291300}
    292301
     302/**
     303    @brief Removes backslashes from the given string. Double backslashes are interpreted as one backslash.
     304    @param str The string to manipulate
     305    @return The string with removed slashes
     306*/
    293307std::string removeSlashes(const std::string& str)
    294308{
  • code/trunk/src/util/String.h

    r1625 r1791  
    2323 *      Fabian 'x3n' Landau
    2424 *   Co-authors:
    25  *      Benjamin Grauer
     25 *      ...
    2626 *
    2727 */
     28
     29/**
     30    @file String.h
     31    @brief Declaration of several string manipulation functions, used in many parts of the game.
     32*/
    2833
    2934#ifndef _Util_String_H__
  • code/trunk/src/util/SubString.cc

    r1505 r1791  
    2525 *      Benjamin Grauer
    2626 *
     27
    2728//
    2829//  splitLine
     
    3334//  Copyright (c) 2005 Clemens Wacha. All rights reserved.
    3435//
     36
     37 *   Extended by Fabian 'x3n' Landau by the SL_PARENTHESES mode.
    3538 */
    3639
  • code/trunk/src/util/SubString.h

    r1784 r1791  
    3434//  Copyright (c) 2005 Clemens Wacha. All rights reserved.
    3535
    36  * Extended by Fabian 'x3n' Landau with the SL_PARENTHESES mode.
     36 *   Extended by Fabian 'x3n' Landau by the SL_PARENTHESES mode.
    3737 */
    3838
  • code/trunk/src/util/XMLIncludes.h

    r1505 r1791  
    2121 *
    2222 *   Author:
    23  *      ...
     23 *      Fabian 'x3n' Landau
    2424 *   Co-authors:
    2525 *      ...
    2626 *
    2727 */
     28
     29/**
     30    @file XMLIncludes.h
     31    @brief Forward declarations of some XML classes.
     32*/
    2833
    2934#include "UtilPrereqs.h"
Note: See TracChangeset for help on using the changeset viewer.