Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 11, 2010, 12:34:00 AM (14 years ago)
Author:
landauf
Message:

merged doc branch back to trunk

Location:
code/trunk
Files:
40 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

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

    r6417 r7401  
    5454
    5555    /**
    56         @brief Puts text into the windows-clipboard
    57         @param text The text
     56        @brief Puts text into the Windows-clipboard
    5857        @return True if the action was successful
    5958    */
     
    119118namespace orxonox
    120119{
    121     static std::string clipboard; //!< Keeps the text of our internal clipboard
     120    static std::string clipboard; ///< Keeps the text of our internal clipboard
    122121
    123122    /**
    124123        @brief Default implementation if there is no OS-specific implementation or no clipboard. Copies the text into an internal clipboard.
    125         @param text The text
    126         @return True
     124        @see fromClipboard()
    127125    */
    128126    bool toClipboard(const std::string& text)
     
    134132    /**
    135133        @brief Default implementation if there is no OS-specific implementation or no clipboard. Gets the text from the internal clipboard.
    136         @return The text
     134        @see toClipboard()
    137135    */
    138136    std::string fromClipboard()
  • code/trunk/src/libraries/util/Clipboard.h

    r5781 r7401  
    2929/**
    3030    @file
    31     @brief Some functions to exchange text between the OS clipboard and Orxonox.
     31    @ingroup Util Command
     32    @brief Some functions to exchange text between the OS clipboard and the Shell in Orxonox.
    3233
    3334    Use fromClipboard() to get text from the clipboard (if there is any text) and
    34     toClipboard(text) to put text into the clipboard.
     35    toClipboard() to put text into the clipboard.
    3536
    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.
     37    These functions can only work properly if there's an OS-specific implementation
     38    in Clipboard.cc. If a specific OS is not supported, the clipboard only works
     39    within Orxonox, but the exchange with other programs is not possible.
    3940*/
    4041
  • code/trunk/src/libraries/util/Clock.cc

    r6417 r7401  
    4545    }
    4646
    47     /**
    48     @remarks
    49         Mind the types! Ogre::Timer::getMicroseconds() will return an unsigned
    50         long, which will eventually overflow. But if you use the subtraction of
    51         the current time minus the last time the timer gave us and sum these up to
    52         a 64 bit integer, we get the desired result.
    53         Also mind that we don't have to store the last timer's time as unsigned long
    54         as well because (unsigned long)tickTime_ will do exactly that.
    55     */
    5647    void Clock::capture()
    5748    {
  • code/trunk/src/libraries/util/Clock.h

    r6417 r7401  
    2727 */
    2828
     29/**
     30    @file
     31    @ingroup Util
     32*/
     33
    2934#ifndef _Clock_H__
    3035#define _Clock_H__
     
    3540namespace orxonox
    3641{
     42    /** Simple real time clock based on Ogre::Timer
     43    @details
     44        The class can be used to both capture the current real time or to
     45        incrementally capture the time and then distribute that time information
     46        via Clock& references (for instance for the game tick). <br>
     47        Precision: <br>
     48    @par Precision
     49        The maximum precision is given by the Ogre::Timer and that is somewhere
     50        in the microsecond range for both Windows and UNIX.
     51    @par Remarks for Usage on Windows
     52        For proper functionality this class MUST be used in the same thread! <br>
     53        Furthermore it might be possible that the Ogre::Timer has a performance
     54        caveat because it will only capture the time on the same CPU core.
     55        Confining the main thread to one process could speed up the game.
     56        See \ref cmdargspage "Ccommandline Argument" 'limitToCPU' (only on Windows)
     57    */
    3758    class _UtilExport Clock
    3859    {
    3960    public:
     61        /// Starts the time at 0
    4062        Clock();
    4163        ~Clock();
    4264
     65        /** Internally captures the time and stays at that particular time
     66        @remarks
     67            Mind the types! Ogre::Timer::getMicroseconds() will return an unsigned
     68            long, which will eventually overflow. But if you use the subtraction of
     69            the current time minus the last time the timer gave us and sum these up to
     70            a 64 bit integer, we get the desired result. <br>
     71            Also mind that we don't have to store the last timer's time as unsigned long
     72            as well because (unsigned long)tickTime_ will do exactly that.
     73        */
    4374        void capture();
    4475
    45         unsigned long long getMicroseconds()   const { return tickTime_; }
    46         unsigned long long getMilliseconds()   const { return tickTime_ / 1000; }
    47         unsigned long      getSeconds()        const { return static_cast<long> (tickTime_ / 1000000); }
    48         float              getSecondsPrecise() const { return static_cast<float>(tickTime_ / 1000000.0f); }
     76        /// Returns the last captured absolute time in microseconds
     77        unsigned long long getMicroseconds() const
     78            { return tickTime_; }
     79        /// Returns the last captured absolute time in milliseconds
     80        unsigned long long getMilliseconds() const
     81            { return tickTime_ / 1000; }
     82        /// Returns the last captured absolute time in seconds
     83        unsigned long getSeconds() const
     84            { return static_cast<long> (tickTime_ / 1000000); }
     85        /// Returns the last captured absolute time in seconds as float
     86        float getSecondsPrecise() const
     87            { return static_cast<float>(tickTime_ / 1000000.0f); }
    4988
    50         float              getDeltaTime()      const { return tickDtFloat_; }
    51         long               getDeltaTimeMicroseconds() const { return tickDt_; }
     89        /// Returns the timespan in seconds between the last two calls to capture()
     90        float getDeltaTime() const
     91            { return tickDtFloat_; }
     92        /// Returns the timespan in microseconds between the last two calls to capture()
     93        long getDeltaTimeMicroseconds() const
     94            { return tickDt_; }
    5295
     96        /** Returns the current real time in microseconds
     97        @note
     98            This is especially useful to measure execution times because of the
     99            high precision.
     100        */
    53101        unsigned long long getRealMicroseconds() const;
    54102
    55103    private:
     104        /// Undefined
    56105        Clock(const Clock& instance);
    57106
    58         Ogre::Timer*       timer_;
    59         unsigned long long tickTime_;
    60         long               tickDt_;
    61         float              tickDtFloat_;
     107        Ogre::Timer*       timer_;       ///< Ogre timer object
     108        unsigned long long tickTime_;    ///< Currently captured time
     109        long               tickDt_;      ///< Delta time in microseconds (cache value)
     110        float              tickDtFloat_; ///< Delta time in seconds (cache value)
    62111    };
    63112}
  • code/trunk/src/libraries/util/Convert.cc

    r7163 r7401  
    3232namespace orxonox
    3333{
    34     //template <class FromType, class ToType>
    3534    bool ConverterExplicit<std::string, bool>::convert(bool* output, const std::string& input)
    3635    {
  • code/trunk/src/libraries/util/Convert.h

    r7305 r7401  
    2828 */
    2929
    30 /*!
    31     @file
    32     @brief Definition and Implementation of the Convert class.
     30/**
     31    @defgroup Convert Conversion functions
     32    @ingroup Util
     33*/
     34
     35/** Functions that convert values between different types.
     36@file
     37@ingroup Convert
     38@par Usage
     39    There are three ways to use the conversions depending on what you need. <br>
     40    - For simply converting values without having to know whether the conversion
     41      was successful (for instance float --> string), use orxonox::multi_cast
     42      which effectively works exactly like static_cast, etc.
     43      @code
     44        float input = 42.0;
     45        std::string output = multi_cast<std::string>(input);
     46      @endcode
     47    - If you care about whether the conversion was successful,
     48      use orxonox::convertValue.
     49      @code
     50        std::string input("3.4");
     51        float output;
     52        bool success = convertValue(&output, input);
     53      @endcode
     54    - If you care about success and if you can also feed a fallback value,
     55      use orxonox::convertValue.
     56      @code
     57        std::string input("3.4");
     58        float output;
     59        bool success = convertValue(&output, input, 0.0);
     60      @endcode
     61    - If success doesn't matter but you can feed a fallback value,
     62      use orxonox::getConvertedValue.
     63      @code
     64        std::string input("3.4");
     65        float output = getConvertedValue(input, 0.0);
     66      @endcode
     67@details
     68    The back end of these functions are the actual implementations for the
     69    specific conversions, for instance from Ogre::Vector3 to std::string and
     70    vice versa. Some of them also use the iostream operators. <br>
     71    The real deal is evaluating which function is needed for a conversion based
     72    on the input and output type. But there are lots of catches in conjunction
     73    with templates which explains why there are so many functions in this file.
     74    <br> <br>
     75@par Search Order
     76    Finding the right function is governed by priority rules: <br>
     77    -# (Partial) template specialisation of orxonox::ConverterExplicit::convert()
     78    -# An implicit conversion. This includes 'FooBar' to 'int' if FooBar
     79       defines operator int() or float().
     80    -# Global or member operators for iostream when converting from or
     81       to std::string (and FROM const char*)
     82    -# (Partial) template specialisation of orxonox::ConverterFallback::convert()
     83    -# Fallback function that displays "Could not convert value" with type
     84       information obtained from typeid().
     85@par Implementing conversion functions
     86    To do that you probably need to know a thing or two about the types
     87    involved. So, get ready with that. <br>
     88    Usually the best way to do it is specialising of the orxonox::ConverterFallback
     89    template, like this:
     90    @code
     91    template <>
     92    struct _UtilExport ConverterFallback<std::string, MyType>
     93    {
     94        static bool convert(MyType* output, const std::string& input)
     95        {
     96           ...
     97           return success;
     98        }
     99    };
     100    @endcode
     101    This piece of code converts an std::string to MyType and returns whether the
     102    conversion was successful. You can also use partial specialisation.<br>
     103    The advantage with orxonox::ConverterFallback is that it has a low priority
     104    meaning that when there is an implicit conversion or an iostream method, that
     105    comes first and you don't have to deal with it (and the accompanying
     106    function call ambiguity). <br>
     107    However sometimes you would like to explicitely replace such a conversion.
     108    That's where orxonox::ConverterExplicit comes in handy (for instance we
     109    replaced the operator << conversions for Ogre::VectorX with our own functions).
     110@note
     111    There has to be an exact type match when using template specialisations. <br>
     112    Template specialisations can be defined after including this file.
     113    But any implicit cast function or iostream operator has to be included
     114    in this file!
     115@par Understanding the Code
     116    In order to understand how the templates work, it is probably best to study
     117    the functions in order of calling. There are lots of comments explaining
     118    what happens, but you'll need to understand a deal about partial template
     119    specialisation and function headers are matched in C++.
    33120*/
    34121
     
    46133#include "ImplicitConversion.h"
    47134
    48 ////////////////////////////////////
    49 //// ACTUAL CONVERSION SEQUENCE ////
    50 ////////////////////////////////////
    51 /*
    52     There is a distinct priority when choosing the right conversion function:
    53     Overwrite:
    54     1. (Partial) template specialisation of ConverterExplicit::convert()
    55     Fallbacks:
    56     2. Any possible implicit conversion. This includes 'FooBar' --> 'int' if FooBar defines operator float().
    57     3. Global or member operators for stringstream when converting from or to std::string (or FROM const char*)
    58     4. (Partial) template specialisation of ConverterFallback::convert()
    59     5. Function that simply displays "Could not convert value" with type information obtained from typeid().
    60 
    61     Notes:
    62     There has to be an exact type match when using template specialisations.
    63     Template specialisations can be defined after including this file. Any implicit cast function or iostream
    64     operator has to be declared BEFORE this file gets parsed.
    65 
    66     Defining your own functions:
    67     There are obviously 4 ways to specify a user defined conversion. What should you use?
    68 
    69     Usually, ConverterFallback fits quite well. You won't have to deal with the conversion from
    70     'MyClass' to 'MyClass' by using another explicit template specialisation to avoid ambiguities.
    71 
    72     However if you want to overwrite an implicit conversion or an iostream operator, you really need to
    73     make use of ConverterExplicit. We have to do this for the Ogre classes for instance because they
    74     define stream operators we don't particulary like.
    75 */
    76 
    77135namespace orxonox
    78136{
     
    81139    ///////////////////
    82140
    83     // Default template. No conversion available at all.
     141    /// Default template. No conversion available at all.
    84142    template <class FromType, class ToType>
    85143    struct ConverterFallback
     
    93151    };
    94152
    95     // If all else fails, try a dynamic_cast for pointer types.
     153    /// If all else fails, try a dynamic_cast for pointer types.
    96154    template <class FromType, class ToType>
    97155    struct ConverterFallback<FromType*, ToType*>
     
    109167        }
    110168    };
    111 
    112     ////////////
    113     // upcast //
    114     ////////////
    115     namespace detail
    116     {
    117         // perform a static cast if ToType is a base of FromType
    118         template<class ToType, class FromType>
    119         FORCEINLINE ToType upcast(FromType input, Loki::Int2Type<true>)
    120         {
    121             return static_cast<ToType>(input);
    122         }
    123 
    124         // return zero if ToType is not a base of FromType
    125         template<class ToType, class FromType>
    126         FORCEINLINE ToType upcast(FromType input, Loki::Int2Type<false>)
    127         {
    128             return 0;
    129         }
    130     }
    131 
    132     // performs an upcast if ToType is a base of FromType, returns zero otherwise
    133     template <class ToType, class FromType>
    134     FORCEINLINE ToType upcast(FromType input)
    135     {
    136         enum { probe = ImplicitConversion<FromType, ToType>::exists };
    137         return detail::upcast<ToType, FromType>(input, Loki::Int2Type<probe>());
    138     }
    139169}
    140170
     
    144174///////////////////////
    145175
    146 // Default template for stringstream
     176/** Fallback template for stringstream
     177@details
     178    Neither FromType nor ToType was std::string, therefore
     179    delegate to orxonox::ConverterFallback
     180*/
    147181template <class FromType, class ToType>
    148182struct ConverterStringStream
     
    159193/////////////
    160194
     195/// Extra namespace to avoid exposing the iostream operators in it
    161196namespace fallbackTemplates
    162197{
     198    /// Fallback operator <<() (delegates to orxonox::ConverterFallback)
    163199    template <class FromType>
    164200    FORCEINLINE bool operator <<(std::ostream& outstream,  const FromType& input)
     
    175211}
    176212
    177 // template that evaluates whether we can convert to std::string via ostringstream
     213/// Template that evaluates whether we can convert to std::string via ostringstream
    178214template <class FromType>
    179215struct ConverterStringStream<FromType, std::string>
     
    182218    {
    183219        using namespace fallbackTemplates;
    184         // this operator call only chooses fallbackTemplates::operator<< if there's no other fitting function
     220        // this operator call only chooses fallbackTemplates::operator<<()
     221        // if there's no other fitting function
    185222        std::ostringstream oss;
     223        // Note: std::ostream has operator!() to tell whether any error flag was set
    186224        if (oss << input)
    187225        {
     
    201239namespace fallbackTemplates
    202240{
     241    /// Fallback operator >>() (delegates to orxonox::ConverterFallback)
    203242    template <class ToType>
    204243    FORCEINLINE bool operator >>(std::istream& instream, ToType& output)
    205244    {
    206         return orxonox::ConverterFallback<std::string, ToType>
    207             ::convert(&output, static_cast<std::istringstream&>(instream).str());
     245        std::string input(static_cast<std::istringstream&>(instream).str());
     246        return orxonox::ConverterFallback<std::string, ToType>::convert(&output, input);
    208247    }
    209248}
    210249
    211 // template that evaluates whether we can convert from std::string via ostringstream
     250/// Template that evaluates whether we can convert from std::string via istringstream
    212251template <class ToType>
    213252struct ConverterStringStream<std::string, ToType>
     
    216255    {
    217256        using namespace fallbackTemplates;
     257        // this operator call chooses fallbackTemplates::operator>>()
     258        // only if there's no other fitting function
    218259        std::istringstream iss(input);
    219         // this operator call only chooses fallbackTemplates::operator>> if there's no other fitting function
     260        // Note: std::istream has operator!() to tell whether any error flag was set
    220261        if (iss >> (*output))
    221262        {
     
    229270namespace orxonox
    230271{
    231 
    232272    ///////////////////
    233273    // Implicit Cast //
    234274    ///////////////////
    235275
    236     // implicit cast not possible, try stringstream conversion next
     276    /// %Template delegates to ::ConverterStringStream
    237277    template <class FromType, class ToType>
    238278    FORCEINLINE bool convertImplicitely(ToType* output, const FromType& input, Loki::Int2Type<false>)
     
    241281    }
    242282
    243     // We can cast implicitely
     283    /// Makes an implicit cast from \a FromType to \a ToType
    244284    template <class FromType, class ToType>
    245285    FORCEINLINE bool convertImplicitely(ToType* output, const FromType& input, Loki::Int2Type<true>)
     
    254294    ////////////////////////////////
    255295
    256     // Default template if no specialisation is available
     296    /** Default template if no orxonox::ConverterExplicit is available
     297    @details
     298        Evaluates whether \a FromType can be implicitly converted to \a ToType
     299        by the use the ImplicitConversion magic.
     300    */
    257301    template <class FromType, class ToType>
    258302    struct ConverterExplicit
     
    261305        FORCEINLINE static bool convert(ToType* output, const FromType& input)
    262306        {
    263             // Try implict cast and probe first. If a simple cast is not possible, it will not compile
    264             // We therefore have to out source it into another template function
     307            // Use the probe's value to delegate to the right function
    265308            return convertImplicitely(output, input, Loki::Int2Type<probe>());
    266309        }
     
    275318    @brief
    276319        Converts any value to any other as long as there exists a conversion.
     320    @details
    277321        Otherwise, the conversion will generate a runtime warning and return false.
    278         For information about the different conversion methods (user defined too), see the section
    279         'Actual conversion sequence' in this file above.
     322    @see Convert.h
     323    @param output
     324        A pointer to the variable where the converted value will be stored
     325    @param input
     326        The original value
    280327    */
    281328    template <class FromType, class ToType>
     
    291338        Converts any value to any other as long as there exists a conversion.
    292339        Otherwise, the conversion will generate a runtime warning and return false.
    293         For information about the different conversion methods (user defined too), see the section
    294         'Actual conversion sequence' in this file above.
    295         If the conversion doesn't succeed, 'fallback' is written to '*output'.
     340        If the conversion doesn't succeed, \a fallback is written to \a output.
     341    @see Convert.h
     342    @param output
     343        A pointer to the variable where the converted value will be stored
     344    @param input
     345        The original value
    296346    @param fallback
    297347        A default value that gets written to '*output' if there is no conversion.
     
    309359    }
    310360
    311     // Directly returns the converted value, even if the conversion was not successful.
     361    /// Directly returns the converted value, but uses the fallback on failure. @see convertValue
    312362    template<class FromType, class ToType>
    313     FORCEINLINE ToType getConvertedValue(const FromType& input)
     363    FORCEINLINE ToType getConvertedValue(const FromType& input, const ToType& fallback)
     364    {
     365        ToType output;
     366        convertValue(&output, input, fallback);
     367        return output;
     368    }
     369
     370    /**
     371    @brief
     372        Converts any value to any other as long as there exists a conversion.
     373    @details
     374        Use exactly the way you use static_cast, etc. <br>
     375        A failed conversion will return a default instance of \a ToType
     376        (possibly uninitialised)
     377    @see Convert.h
     378    @param input
     379        The original value
     380    */
     381    template<class ToType, class FromType>
     382    FORCEINLINE ToType multi_cast(const FromType& input)
    314383    {
    315384        ToType output;
     
    318387    }
    319388
    320     // Directly returns the converted value, but uses the fallback on failure.
    321     template<class FromType, class ToType>
    322     FORCEINLINE ToType getConvertedValue(const FromType& input, const ToType& fallback)
    323     {
    324         ToType output;
    325         convertValue(&output, input, fallback);
    326         return output;
    327     }
    328 
    329     // Like getConvertedValue, but the template argument order is in reverse.
    330     // That means you can call it exactly like static_cast<ToType>(fromTypeValue).
    331     template<class ToType, class FromType>
    332     FORCEINLINE ToType multi_cast(const FromType& input)
    333     {
    334         ToType output;
    335         convertValue(&output, input);
    336         return output;
    337     }
    338 
    339389    ////////////////////////////////
    340390    // Special string conversions //
    341391    ////////////////////////////////
    342392
    343     // Delegate conversion from const char* to std::string
     393    /// Delegates conversion from const char* to std::string
    344394    template <class ToType>
    345395    struct ConverterExplicit<const char*, ToType>
     
    351401    };
    352402
    353     // These conversions would exhibit ambiguous << or >> operators when using stringstream
     403    /// Conversion would exhibit ambiguous << or >> operators when using iostream
    354404    template <>
    355405    struct ConverterExplicit<char, std::string>
     
    361411        }
    362412    };
     413    /// Conversion would exhibit ambiguous << or >> operators when using iostream
    363414    template <>
    364415    struct ConverterExplicit<unsigned char, std::string>
     
    370421        }
    371422    };
     423    /// Conversion would exhibit ambiguous << or >> operators when using iostream
    372424    template <>
    373425    struct ConverterExplicit<std::string, char>
     
    382434        }
    383435    };
     436    /// Conversion would exhibit ambiguous << or >> operators when using iostream
    384437    template <>
    385438    struct ConverterExplicit<std::string, unsigned char>
     
    396449
    397450
    398     // bool to std::string
     451    /// Conversion from bool to std::string
    399452    template <>
    400453    struct ConverterExplicit<bool, std::string>
     
    410463    };
    411464
    412     // std::string to bool
     465    /// Conversion from std::string to bool
    413466    template <>
    414467    struct _UtilExport ConverterExplicit<std::string, bool>
  • code/trunk/src/libraries/util/Debug.h

    r6443 r7401  
    2929
    3030/**
     31    @defgroup COUT COUT(x) output macro
     32    @ingroup Util
     33*/
     34
     35/**
    3136@file
     37@ingroup COUT
    3238@brief
    33     Handles different output-levels of errors, warnings, infos and debug information.
     39    Handles different output-levels of errors, warnings, infos, and debug information.
    3440
    35     The COUT(level) macro acts like std::cout, but the output is only performed if the given
     41    The COUT(level) macro acts like @c std::cout, but the output is only performed if the given
    3642    level is <= the soft debug level.
    3743
     
    3945     - The hard debug level is used during compile time. It describes the highest allowed output level.
    4046     - The soft debug level is used during runtime and is the maximum of the three configurable
    41        output-levels for console, log file and in game shell.
     47       output-levels for console, log file, and in game shell.
    4248
    4349    The separation between the three devices is done by the OutputHandler.
    4450
     51    @anchor COUTlevels
    4552    Possible levels are:
    46      0: Very important output
    47      1: Errors
    48      2: Warnings
    49      3: Information
    50      4: Debug information
    51      5: More debug information
    52      6: Crazy debug information
     53     - 0: Very important output
     54     - 1: Errors
     55     - 2: Warnings
     56     - 3: Information
     57     - 4: Debug information
     58     - 5: More debug information
     59     - 6: Crazy debug information
    5360
    54 @example
     61    Example:
     62    @code
    5563    COUT(0) << "Very important output" << std::endl;
    5664    COUT(1) << "Error: Something went wrong!" << std::endl;
     
    5866    COUT(3) << "Info: It's Monday" << std::endl;
    5967    COUT(4) << "Debug: x is 1.23456" << std::endl;
     68    @endcode
    6069*/
    6170
     
    9099/**
    91100@brief
    92     Logs text output: use exactly like std::cout, but specify an output
    93     level as argument.
    94 @details
    95     (a > b ? 0 : c << "text") is equivalent to (a > b ? 0 : (c << "text"))
    96     where (a > b ? 0 : ) stands for COUT(x). This should explain how
     101    Logs text output: You can use COUT(level) exactly like @c std::cout, but you have to specify an output level as argument.
     102@param level
     103    The level of the following output (passed with <tt><< "text"</tt>). Lower levels are more important. See @ref COUTlevels "the description above" for a list of possible output levels.
     104
     105    Example:
     106    @code
     107    COUT(3) << "Some info" << std::endl; // Output with level 3
     108    @endcode
     109@note
     110    <tt>(a > b ? 0 : c << "text")</tt> is equivalent to <tt>(a > b ? 0 : (c << "text")</tt>
     111    where <tt>(a > b ? 0 : )</tt> stands for COUT(x). This should explain how
    97112    this macro magic can possibly even work ;)
    98 @example
    99     COUT(3) << "Some info" << std::endl;
    100 @note
    101     The ? : operator requires both possible results to have the type of
     113@remarks
     114    The <tt>? :</tt> operator requires both possible results to have the type of
    102115    the first. This is achieved by the int conversion operator dummy
    103     in the OutputHandler.
     116    in the @ref orxonox::OutputHandler.
    104117*/
    105118#define COUT(level)                                                    \
  • code/trunk/src/libraries/util/Exception.cc

    r7174 r7401  
    5353    { }
    5454
    55     /**
    56     @remarks
    57         The composed full description gets stored to fullDescription_. But for compliance
    58         with std::exception, this method has to be const. Hence fullDescription_ is declared
    59         as mutable.
    60     */
    6155    const std::string& Exception::getFullDescription() const
    6256    {
     
    8983    }
    9084
    91     //! Returns the error description
    9285    const char* Exception::what() const throw()
    9386    {
  • code/trunk/src/libraries/util/Exception.h

    r6417 r7401  
    2828
    2929/**
     30    @defgroup ExceptionAssertion Exceptions and assertions
     31    @ingroup Util
     32*/
     33
     34/**
    3035@file
     36@ingroup ExceptionAssertion
    3137@brief
    3238    Declaration of facilities to handle exceptions.
     39@details
     40    Any exception thrown should inherit from orxonox::Exception. There is a macro
     41    \ref CREATE_ORXONOX_EXCEPTION to create a new exception (you can find a list of
     42    available exceptions in the docs of this file). <br>
     43    Throwing exception is also very simple:
     44    @code
     45        ThrowException(General, "Something went wrong");
     46    @endcode
     47    (\c General is a type of exception, see docs of this file) <br>
     48    The exception will automatically contain information about file, line number
     49    and function name it occurred in. <br><br>
     50    There is also some magic you can do for numbers, etc.:
     51    @code
     52        ThrowException(General, "Error code: " << myInt << ". more info...");
     53    @endcode
     54    It works with an std::ostringstream, so you can feed it all sorts of values.
    3355*/
    3456
     
    4567namespace orxonox
    4668{
    47     /**
    48     @brief
    49         Base class for all exceptions (derived from std::exception).
     69    /** Base class for all exceptions (derived from std::exception).
    5070    @details
    5171        This class provides support for information about the file, the line
    52         and the function the error occured.
     72        and the function the error occurred.
     73    @see Exception.h
    5374    */
    5475    class _UtilExport Exception : public std::exception
     
    6081        @param description
    6182            Exception description as string. This message is supposed to help developers!
     83        @param lineNumber
     84            The number of the code-line in which the exception occurred
     85        @param filename
     86            The file in which the exception occurred
     87        @param functionName
     88            The function in which the exception occurred
    6289        */
    6390        Exception(const std::string& description, unsigned int lineNumber,
     
    6895        //! Needed for compatibility with std::exception
    6996        virtual ~Exception() throw() { }
     97        //! Returns the error description
    7098        const char* what() const throw();
    7199
    72         //! Returns a full description with type, line, file and function
     100        /** Returns a full description with type, line, file and function
     101        @remarks
     102            The composed full description gets stored to fullDescription_. But for compliance
     103            with std::exception, this method has to be const. Hence fullDescription_ is declared
     104            as mutable.
     105        */
    73106        virtual const std::string& getFullDescription() const;
    74107        //! Returns the string name of the exception type
     
    101134    };
    102135
    103 //! Creates a new type of exception that inherits from tracker::Exception
     136//! Creates a new type of exception that inherits from orxonox::Exception
    104137#define CREATE_ORXONOX_EXCEPTION(ExceptionName)                                     \
    105138    class ExceptionName##Exception : public Exception                               \
     
    123156    // Creates all possible exception types.
    124157    // If you want to add a new type, simply copy and adjust a new line here.
    125 #ifndef DOXYGEN_SHOULD_SKIP_THIS
    126158    CREATE_ORXONOX_EXCEPTION(General);
    127159    CREATE_ORXONOX_EXCEPTION(FileNotFound);
     
    136168    CREATE_ORXONOX_EXCEPTION(NoGraphics);
    137169    CREATE_ORXONOX_EXCEPTION(AbortLoading);
    138 #endif
    139170
    140     /**
    141     @brief
    142         Helper function that forwards an exception and displays the message.
     171    /** Helper function that forwards an exception and displays the message.
    143172    @details
    144173        This is necessary because only when using 'throw' the objects storage is managed.
     
    152181    }
    153182
    154 /**
    155 @brief
    156     Throws an exception and logs a message beforehand.
     183/** Throws an exception and logs a message beforehand.
    157184@param type
    158185    Type of the exception as literal (General, Initialisation, etc.)
    159186@param description
    160187    Exception description as string
     188@see Exception.h
    161189*/
    162190#define ThrowException(type, description) \
  • code/trunk/src/libraries/util/ExprParser.h

    r6417 r7401  
    2828
    2929/**
    30   @file
    31   @brief Declaration of FloatParser
     30@file
     31@ingroup Util
     32@brief Declaration of FloatParser
    3233*/
    3334
     
    4243namespace orxonox
    4344{
     45    /** Parser for expressions like \c "3 * cos(5 + 4) / a" where \a a is a predeclared
     46        variable.
     47    @par Usage
     48        Using it is rather simple:
     49        @code
     50        std::string str("3 + 4");
     51        ExprParser expr;
     52        expr.parse(str);
     53        if (expr.getSuccess())
     54        {
     55            if (!expr.getRemains().empty())
     56            {
     57                COUT(2) << "Warning: Expression could not be parsed to the end! Remains: '" << expr.getRemains() << '\'' << std::endl;
     58            }
     59            double result = expr.getResult();
     60        }
     61        else
     62            COUT(1) << "Error: Cannot calculate expression: Parse error." << std::endl;
     63        @endcode
     64        getRemains() returns the expression after what could be parsed. For instance
     65        \c "2*3 text" will return \c "text" as remains.
     66    @details
     67        The implementation of this class is really old and sort of a trial for
     68        a first C++ class by Reto. That explains why it looks more like C than
     69        C++... Also some of the variable names are in German. <br>
     70        Explaining how it works exactly is probably not possible anymore, but it
     71        is based on recursively parsing the expression character by character.
     72        That much I can remember.
     73    @par Functions, operators and variables supported
     74        - Variables:
     75            - e
     76            - pi
     77        - Functions:
     78            - sin, asin, sinh, asinh
     79            - cos, acos, cosh, acosh
     80            - tan, atan, tanh, atanh
     81            - int, floor, ceil, abs, sign
     82            - pow, sqrt, exp, ln, log
     83            - mod, div
     84            - min, max
     85            - radians, degrees
     86        - Operators:
     87            - +, -, ! (unary)
     88            - +, -, *, /, %, ^, |, &, !, <, >, !=, <=, >=, =
     89    @note
     90        Operators may not be very consistent with C++ rules, but using the class
     91        for plus and minus should be perfectly ok.
     92    */
    4493    class _UtilExport ExprParser
    4594    {
  • code/trunk/src/libraries/util/ImplicitConversion.h

    r7305 r7401  
    2929/**
    3030    @file
     31    @ingroup Util
    3132    @brief Declaration of various helper templates.
    3233*/
  • code/trunk/src/libraries/util/Math.cc

    r7284 r7401  
    9191        @param mydirection My viewing direction
    9292        @param otherposition The position of the other object
    93         @return The angle
    94 
    95         @example
    96         If the other object is exactly in front of me, the function returns 0.
    97         If the other object is exactly behind me, the function returns pi.
    98         If the other object is exactly right/left to me (or above/below), the function returns pi/2.
     93        @return The angle in radian
     94
     95        Examples:
     96         - If the other object is exactly in front of me, the function returns 0.
     97         - If the other object is exactly behind me, the function returns pi.
     98         - If the other object is exactly right/left to me (or above/below), the function returns pi/2.
    9999    */
    100100    float getAngle(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& otherposition)
     
    116116        @return The viewing direction
    117117
    118         @example
    119         If the other object is exactly in front of me, the function returns Vector2(0, 0).
    120         If the other object is exactly at my left, the function returns Vector2(-1, 0).
    121         If the other object is exactly at my right, the function returns Vector2(1, 0).
    122         If the other object is only a bit at my right, the function still returns Vector2(1, 0).
    123         If the other object is exactly above me, the function returns Vector2(0, 1).
     118        Examples:
     119         - If the other object is exactly in front of me, the function returns <tt>Vector2(0, 0)</tt>.
     120         - If the other object is exactly at my left, the function returns <tt>Vector2(-1, 0)</tt>.
     121         - If the other object is exactly at my right, the function returns <tt>Vector2(1, 0)</tt>.
     122         - If the other object is only a bit at my right, the function still returns <tt>Vector2(1, 0)</tt>.
     123         - If the other object is exactly above me, the function returns <tt>Vector2(0, 1)</tt>.
    124124    */
    125125    orxonox::Vector2 get2DViewdirection(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition)
     
    156156        @return The viewing direction
    157157
    158         @example
    159         If the other object is exactly in front of me, the function returns Vector2(0, 0).
    160         If the other object is exactly at my left, the function returns Vector2(-0.5, 0).
    161         If the other object is exactly at my right, the function returns Vector2(0.5, 0).
    162         If the other object is only a bit at my right, the function still returns Vector2(0.01, 0).
    163         If the other object is exactly above me, the function returns Vector2(0, 0.5).
     158        Examples:
     159         - If the other object is exactly in front of me, the function returns <tt>Vector2(0, 0)</tt>.
     160         - If the other object is exactly at my left, the function returns <tt>Vector2(-0.5, 0)</tt>.
     161         - If the other object is exactly at my right, the function returns <tt>Vector2(0.5, 0)</tt>.
     162         - If the other object is only a bit at my right, the function still returns <tt>Vector2(0.01, 0)</tt>.
     163         - If the other object is exactly above me, the function returns <tt>Vector2(0, 0.5)</tt>.
    164164    */
    165165    orxonox::Vector2 get2DViewcoordinates(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition)
     
    220220    }
    221221
     222    /**
     223        @brief Returns a unique number. This function will never return the same value twice.
     224    */
    222225    unsigned long getUniqueNumber()
    223226    {
  • code/trunk/src/libraries/util/Math.h

    r7184 r7401  
    2828
    2929/**
     30    @defgroup Math Mathematical functions
     31    @ingroup Util
     32*/
     33
     34/**
    3035    @file
     36    @ingroup Math
    3137    @brief Declaration and implementation of several math-functions, typedefs of some Ogre::Math classes to the orxonox namespace.
    3238*/
     
    6268    namespace math
    6369    {
    64         const float pi      = 3.14159265f;
    65         const float pi_2    = 1.57079633f;
    66         const float pi_4    = 7.85398163e-1f;
    67         const float e       = 2.71828183f;
    68         const float sqrt2   = 1.41421356f;
    69         const float sqrt2_2 = 7.07106781e-1f;
    70 
    71         const double pi_d      = 3.14159265358979324;
    72         const double pi_2_d    = 1.57079632679489662;
    73         const double pi_4_d    = 7.85398163397448310e-1;
    74         const double e_d       = 2.71828182845904524;
    75         const double sqrt2_d   = 1.41421356237309505;
    76         const double sqrt2_2_d = 7.07106781186547524e-1;
     70        const float pi      = 3.14159265f;      ///< PI
     71        const float pi_2    = 1.57079633f;      ///< PI / 2
     72        const float pi_4    = 7.85398163e-1f;   ///< PI / 4
     73        const float e       = 2.71828183f;      ///< e
     74        const float sqrt2   = 1.41421356f;      ///< sqrt(2)
     75        const float sqrt2_2 = 7.07106781e-1f;   ///< sqrt(2) / 2
     76
     77        const double pi_d      = 3.14159265358979324;       ///< PI (double)
     78        const double pi_2_d    = 1.57079632679489662;       ///< PI / 2 (double)
     79        const double pi_4_d    = 7.85398163397448310e-1;    ///< PI / 4 (double)
     80        const double e_d       = 2.71828182845904524;       ///< e (double)
     81        const double sqrt2_d   = 1.41421356237309505;       ///< sqrt(2) (double)
     82        const double sqrt2_2_d = 7.07106781186547524e-1;    ///< sqrt(2) / 2 (double)
    7783    }
    7884
     
    101107
    102108    /**
    103         @brief Keeps a value between a lower and an upper limit.
     109        @brief Keeps a value between a lower and an upper limit. Values beyond these limits are limited to either @a min or @a max.
    104110        @param x The value
    105111        @param min The lower limit
     
    119125
    120126    /**
    121         @brief Returns the square value (x^2).
     127        @brief Returns the squared value (x^2).
    122128    */
    123129    template <typename T>
     
    128134
    129135    /**
    130         @brief Returns the cube value (x^3).
     136        @brief Returns the cubed value (x^3).
    131137    */
    132138    template <typename T>
     
    137143
    138144    /**
    139         @brief Rounds the value.
     145        @brief Rounds the value to the nearest integer.
    140146    */
    141147    template <typename T>
     
    149155        @param x The value
    150156        @param max The operand
     157
     158        The built in modulo operator % yields a strange behavior with negative values.
     159        This function corrects this - the result is guaranteed to lie always between
     160        zero and (max-1).
     161
     162        Example:
     163        @code
     164        int var = 11 % 10;      //  1
     165        int var = -1 % 10;      // -1
     166
     167        int var = mod(11, 10);  //  1
     168        int var = mod(-1, 10);  //  9
     169        @endcode
    151170    */
    152171    template <typename T>
     
    159178    }
    160179
     180    /**
     181        @brief Returns a "zero" value for the given type.
     182        @note This is the default template of the zeroise() function. The template is spezialized for each supported type.
     183
     184        The exact return value of the function depends on the type. For @c int this is 0,
     185        for @c float it's 0.0f. For a @c std::string the function returns "" and for
     186        @c Vector3 you get <tt>Vector3(0, 0, 0)</tt>.
     187    */
    161188    template <typename T>
    162189    inline T zeroise()
     
    192219    template <> inline orxonox::Quaternion  zeroise<orxonox::Quaternion>()  { return orxonox::Quaternion (0, 0, 0, 0); }
    193220
    194     //! Provides zero value symbols that can be returned as reference
     221    /**
     222        @brief Provides zero value symbols that can be returned as reference
     223        @see zeroise()
     224    */
    195225    template <typename T>
    196226    struct NilValue
     
    207237    /**
    208238        @brief Interpolates between two values for a time between 0 and 1.
    209         @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.
    210         @param start The value at time = 0
    211         @param end The value at time = 1
    212         @return The interpolation at a given time
     239        @param time The time is a value between 0 and 1 - the function returns @a start if @a time is 0, @a end if @a time is 1, and interpolates if @a time is between 0 and 1.
     240        @param start The value at @a time = 0
     241        @param end The value at @a time = 1
     242        @return The interpolated value at a given time
    213243    */
    214244    template <typename T>
     
    220250    /**
    221251        @brief Interpolates smoothly between two values for a time between 0 and 1. The function starts slowly, increases faster and stops slowly again.
    222         @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.
    223         @param start The value at time = 0
    224         @param end The value at time = 1
    225         @return The smoothed interpolation at a given time
     252        @param time The time is a value between 0 and 1 - the function returns @a start if @a time is 0, @a end if @a time is 1, and interpolates if @a time is between 0 and 1.
     253        @param start The value at @a time = 0
     254        @param end The value at @a time = 1
     255        @return The interpolated value at a given time
    226256    */
    227257    template <typename T>
     
    232262
    233263    /**
    234         @brief Returns a random number between 0 and almost 1: 0 <= rnd < 1.
     264        @brief Returns a random number between 0 and almost 1: <tt>0 <= rnd < 1</tt>.
    235265    */
    236266    inline float rnd()
     
    240270
    241271    /**
    242         @brief Returns a random number between 0 and almost max: 0 <= rnd < max.
     272        @brief Returns a random number between 0 and almost @a max: <tt>0 <= rnd < max</tt>.
    243273        @param max The maximum
    244274    */
     
    249279
    250280    /**
    251         @brief Returns a random number between min and almost max: min <= rnd < max.
     281        @brief Returns a random number between @a min and almost @a max: <tt>min <= rnd < max</tt>.
    252282        @param min The minimum
    253283        @param max The maximum
     
    268298    _UtilExport unsigned long getUniqueNumber();
    269299
     300    /**
     301        @brief A Vector class containing two integers @a x and @a y.
     302    */
    270303    class IntVector2
    271304    {
     
    277310    };
    278311
     312    /**
     313        @brief A Vector class containing three integers @a x, @a y, and @a z.
     314    */
    279315    class IntVector3
    280316    {
  • code/trunk/src/libraries/util/MathConvert.h

    r6417 r7401  
    2828
    2929/**
    30     @file
    31     @brief
    32         Math conversion functions. Definitions are in Math.cc
     30@file
     31@ingroup Convert
     32@brief
     33    Conversion functions for Math types like Ogre::Vector3 (definitions are in Math.cc)
    3334*/
    3435
     
    4647    ////////////////////
    4748
    48     // Vector2 to std::string
     49    /// Ogre::Vector2 to std::string conversion
    4950    template <>
    5051    struct ConverterExplicit<orxonox::Vector2, std::string>
     
    6263    };
    6364
    64     // Vector3 to std::string
     65    /// Ogre::Vector3 to std::string conversion
    6566    template <>
    6667    struct ConverterExplicit<orxonox::Vector3, std::string>
     
    7879    };
    7980
    80     // Vector4 to std::string
     81    /// Ogre::Vector4 to std::string conversion
    8182    template <>
    8283    struct ConverterExplicit<orxonox::Vector4, std::string>
     
    9495    };
    9596
    96     // Quaternion to std::string
     97    /// Ogre::Quaternion to std::string conversion
    9798    template <>
    9899    struct ConverterExplicit<orxonox::Quaternion, std::string>
     
    110111    };
    111112
    112     // ColourValue to std::string
     113    /// Ogre::ColourValue to std::string conversion
    113114    template <>
    114115    struct ConverterExplicit<orxonox::ColourValue, std::string>
     
    131132    ////////////////////
    132133
    133     // std::string to Vector2
     134    /// std::string to Ogre::Vector2 conversion
    134135    template <> struct _UtilExport ConverterFallback<std::string, orxonox::Vector2>
    135136    { static bool convert(orxonox::Vector2*     output, const std::string& input); };
    136     // std::string to Vector3
     137    /// std::string to Ogre::Vector3 conversion
    137138    template <> struct _UtilExport ConverterFallback<std::string, orxonox::Vector3>
    138139    { static bool convert(orxonox::Vector3*     output, const std::string& input); };
    139     // std::string to Vector4
     140    /// std::string to Ogre::Vector4 conversion
    140141    template <> struct _UtilExport ConverterFallback<std::string, orxonox::Vector4>
    141142    { static bool convert(orxonox::Vector4*     output, const std::string& input); };
    142     // std::string to Quaternion
     143    /// std::string to Ogre::Quaternion conversion
    143144    template <> struct _UtilExport ConverterFallback<std::string, orxonox::Quaternion>
    144145    { static bool convert(orxonox::Quaternion*  output, const std::string& input); };
    145     // std::string to ColourValue
     146    /// std::string to Ogre::ColourValue conversion
    146147    template <> struct _UtilExport ConverterFallback<std::string, orxonox::ColourValue>
    147148    { static bool convert(orxonox::ColourValue* output, const std::string& input); };
     
    152153    ///////////////////////////////
    153154
    154     // From Radian
     155    /// Delegates conversions from Radian to conversions from float
    155156    template <class ToType>
    156157    struct ConverterFallback<orxonox::Radian, ToType>
     
    162163    };
    163164
    164     // From Degree
     165    /// Delegates conversions from Degree to conversions from float
    165166    template <class ToType>
    166167    struct ConverterFallback<orxonox::Degree, ToType>
     
    172173    };
    173174
    174     // To Radian
     175    /// Delegates conversions to Radian to conversions to float
    175176    template <class FromType>
    176177    struct ConverterFallback<FromType, orxonox::Radian>
     
    189190    };
    190191
    191     // To Degree
     192    /// Delegates conversions to Degree to conversions to float
    192193    template <class FromType>
    193194    struct ConverterFallback<FromType, orxonox::Degree>
  • code/trunk/src/libraries/util/MultiType.cc

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

    r7284 r7401  
    2828
    2929/**
     30    @defgroup MultiType MultiType
     31    @ingroup Util
     32*/
     33
     34/**
    3035    @file
     36    @ingroup MultiType
    3137    @brief Declaration of the MultiType and some helper constructs.
    3238
     39    @anchor MultiTypeExamples
     40
    3341    The MultiType can hold a value of one of the following types:
    34      - all primitives
    35      - all pointers
    36      - string
     42     - all primitives (int, float, bool, etc.)
     43     - all pointers (void* and T*)
     44     - std::string
    3745     - Vector2, Vector3, Vector4
    3846     - Quaternion
     
    4048     - Radian, Degree
    4149
    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.
     50    The MultiType has an internal "type" determined by the first assigned value, using one of these ways:
     51     - @ref orxonox::MultiType::MultiType "The constructor"
     52     - The assignment operator= (orxonox::MultiType::operator=())
     53     - @ref orxonox::MultiType::setValue() "setValue(value)"
     54
     55    If you assign another value of another type, the MultiType keeps "its" type and
     56    converts the new value to the old type.
    4857
    4958    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
     59     - @ref orxonox::MultiType::convert "convert<T>()" sets the type to T and converts the currently assigned value
     60     - @ref orxonox::MultiType::setType "setType<T>()" sets the type to T and resets the value to zero using zeroise<T>()
    5261     - setValue<T>(value) assigns a new value and changes the type to T.
    5362
    54     @example
    55     MultiType a = 10;;         // a has now the type int and the value 10
     63    Examples:
     64    @code
     65    MultiType a = 10;          // a has now the type int and the value 10
    5666    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
     67    a.setValue<float>("3.14"); // a has now the type float and "3.14" gets converted to 3.14f
     68    a.convert<bool>();         // converts 3.14f to bool, which is true
    5969    a = false;                 // assigns false, this is equivalent to a.setValue(false)
     70    @endcode
     71
     72    You can pass a MultiType to a function as an argument, even if the argument is
     73    not of type MultiType. This works, because the MultiType is automatically converted
     74    to the right type.
     75
     76    Example:
     77    @code
     78    void myfunction(int value)
     79    {
     80        COUT(0) << "doubled value is " << (2 * value) << std::endl;
     81    }
     82
     83    MultiType a = "50";        // Note: We assigned a string
     84    myfunction(a);             // a is converted to int and passed to the function, which prints "value is 100"
     85    @endcode
     86
     87    Note however that it is of course quite expensive to convert values, especially std::string <-> value.
     88    So if you can, always assign a value with the right type to avoid conversion.
    6089
    6190    @note
     
    127156         - Radian, Degree
    128157
    129         The internal type of a MultiType is determined by the first assigned value, but can be
    130         changed by using setType<T>(), convert<T>() or setValue<T>(value). If a value gets assigned
    131         the normal way (operator=, setValue(value)), the value gets converted to the current internal
    132         type of the MultiType.
     158        For more information and some examples see the description @ref MultiTypeExamples "here".
     159
     160        @see MultiType.h
    133161    */
    134162    class _UtilExport MultiType
     
    153181            virtual bool assimilate(const MultiType& other) = 0;
    154182
    155             /** @brief Returns the type of the current value. */
     183            /// Returns the type of the current value.
    156184            const MT_Type::Value& getType() const { return this->type_; }
    157185
    158             /** @brief Checks whether the value is a default one. */
     186            /// Checks whether the value is a default one.
    159187            bool hasDefaultValue()   const { return this->bHasDefaultValue_; }
    160188
     
    237265            virtual uint8_t getSize() const=0;
    238266
    239             MT_Type::Value type_;   //!< The type of the current value
    240             bool bHasDefaultValue_; //!< True if the last conversion wasn't successful
     267            MT_Type::Value type_;   ///< The type of the current value
     268            bool bHasDefaultValue_; ///< True if the last conversion wasn't successful
    241269        };
    242270
    243271        public:
    244             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. */
    245             inline MultiType(const char& value)                 : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
    246             inline MultiType(const unsigned char& value)        : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
    247             inline MultiType(const short& value)                : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
    248             inline MultiType(const unsigned short& value)       : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
    249             inline MultiType(const int& value)                  : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
    250             inline MultiType(const unsigned int& value)         : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
    251             inline MultiType(const long& value)                 : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
    252             inline MultiType(const unsigned long& value)        : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
    253             inline MultiType(const long long& value)            : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
    254             inline MultiType(const unsigned long long& value)   : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
    255             inline MultiType(const float& value)                : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
    256             inline MultiType(const double& value)               : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
    257             inline MultiType(const long double& value)          : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
    258             inline MultiType(const bool& value)                 : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
    259             inline MultiType(      void* const& value)          : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
    260             inline MultiType(const std::string& value)          : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
    261             inline MultiType(const orxonox::Vector2& value)     : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
    262             inline MultiType(const orxonox::Vector3& value)     : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
    263             inline MultiType(const orxonox::Vector4& value)     : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
    264             inline MultiType(const orxonox::ColourValue& value) : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
    265             inline MultiType(const orxonox::Quaternion& value)  : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
    266             inline MultiType(const orxonox::Radian& value)      : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
    267             inline MultiType(const orxonox::Degree& value)      : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
    268             inline MultiType(const orxonox::mbool& value)       : value_(0) { this->assignValue((bool)value); }     /** @brief Constructor: Assigns the given mbool and converts it to bool. */
    269             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. */
    270             inline MultiType(const MultiType& other)            : value_(0) { this->setValue(other); }              /** @brief Copyconstructor: Assigns value and type of the other MultiType. */
    271             inline MultiType(MT_Type::Value type)               : value_(0) { this->setType(type); }                /** @brief Constructor: Sets the type, the next assignment will determine the value. */
    272 
    273             /** @brief Destructor: Deletes the MT_Value. */
     272            inline MultiType()                                  : value_(0) {}                                      ///< Default constructor: Assigns no value and no type. The type will be determined by the first assignment of a value.
     273            inline MultiType(const char& value)                 : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
     274            inline MultiType(const unsigned char& value)        : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
     275            inline MultiType(const short& value)                : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
     276            inline MultiType(const unsigned short& value)       : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
     277            inline MultiType(const int& value)                  : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
     278            inline MultiType(const unsigned int& value)         : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
     279            inline MultiType(const long& value)                 : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
     280            inline MultiType(const unsigned long& value)        : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
     281            inline MultiType(const long long& value)            : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
     282            inline MultiType(const unsigned long long& value)   : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
     283            inline MultiType(const float& value)                : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
     284            inline MultiType(const double& value)               : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
     285            inline MultiType(const long double& value)          : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
     286            inline MultiType(const bool& value)                 : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
     287            inline MultiType(      void* const& value)          : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
     288            inline MultiType(const std::string& value)          : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
     289            inline MultiType(const orxonox::Vector2& value)     : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
     290            inline MultiType(const orxonox::Vector3& value)     : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
     291            inline MultiType(const orxonox::Vector4& value)     : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
     292            inline MultiType(const orxonox::ColourValue& value) : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
     293            inline MultiType(const orxonox::Quaternion& value)  : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
     294            inline MultiType(const orxonox::Radian& value)      : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
     295            inline MultiType(const orxonox::Degree& value)      : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
     296            inline MultiType(const orxonox::mbool& value)       : value_(0) { this->assignValue((bool)value); }     ///< Constructor: Assigns the given mbool and converts it to bool.
     297            inline MultiType(const char* value)                 : value_(0) { this->setValue(std::string(value)); } ///< Constructor: Converts the char array to a std::string, assigns the value and sets the type.
     298            inline MultiType(const MultiType& other)            : value_(0) { this->setValue(other); }              ///< Copyconstructor: Assigns value and type of the other MultiType.
     299            inline MultiType(MT_Type::Value type)               : value_(0) { this->setType(type); }                ///< Constructor: Sets the type, the next assignment will determine the value.
     300
     301            /// Destructor: Deletes the MT_Value.
    274302            inline ~MultiType() { if (this->value_) { delete this->value_; } }
    275303
    276             template <typename V> inline 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. */
    277             template <typename V> inline MultiType& operator=(V* value)               { this->setValue(value); return (*this); } /** @brief Assigns a pointer. */
    278             inline                       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. */
    279             inline                       MultiType& operator=(MT_Type::Value type)    { this->setType(type);   return (*this); } /** @brief Resets the value and changes the type. */
     304            template <typename V> inline MultiType& operator=(const V& value)         { this->setValue(value); return (*this); } ///< Assigns a new value. The value will be converted to the current type of the MultiType.
     305            template <typename V> inline MultiType& operator=(V* value)               { this->setValue(value); return (*this); } ///< Assigns a pointer.
     306            inline                       MultiType& operator=(const MultiType& other) { this->setValue(other); return (*this); } ///< Assigns the value of the other MultiType and converts it to the current type of the MultiType.
     307            inline                       MultiType& operator=(MT_Type::Value type)    { this->setType(type);   return (*this); } ///< Resets the value and changes the type.
    280308
    281309            inline bool                                   setValue(const char& value);
     
    303331            inline bool                                   setValue(const orxonox::Degree& value);
    304332            inline bool                                   setValue(const char* value);
    305             /** @brief Assigns a pointer. */
     333            /// Assigns a pointer.
    306334            template <typename V> inline bool setValue(V* value)
    307335            {
     
    311339                    return this->assignValue     (static_cast<void*>(const_cast<typename Loki::TypeTraits<V>::UnqualifiedType*>(value)));
    312340            }
    313             /** @brief Assigns the value of the other MultiType and converts it to the current type. */
     341            /// Assigns the value of the other MultiType and converts it to the current type.
    314342            bool                                          setValue(const MultiType& other) { if (this->value_) { return this->value_->assimilate(other); } else { if (other.value_) { this->value_ = other.value_->clone(); } return true; } }
    315             /** @brief Changes the type to T and assigns the new value (which might be of another type than T - it gets converted). */
     343            /// Changes the type to T and assigns the new value (which might be of another type than T - it gets converted).
    316344            template <typename T, typename V> inline bool setValue(const V& value) { this->setType<T>(); return this->setValue(value); }
    317345
    318346
    319             /** @brief Copies the other MultiType by assigning value and type. */
     347            /// Copies the other MultiType by assigning value and type.
    320348            inline void                       copy(const MultiType& other)    { if (this == &other) { return; } if (this->value_) { delete this->value_; } this->value_ = (other.value_) ? other.value_->clone() : 0; }
    321349
    322             template <typename T> inline bool convert()                       { return this->setValue<T>((typename Loki::TypeTraits<T>::UnqualifiedReferredType)(*this));  } /** @brief Converts the current value to type T. */
    323             inline bool                       convert(const MultiType& other) { return this->convert(other.getType()); } /** @brief Converts the current value to the type of the other MultiType. */
     350            /// Converts the current value to type T.
     351            template <typename T> inline bool convert()                       { return this->setValue<T>((typename Loki::TypeTraits<T>::UnqualifiedReferredType)(*this));  }
     352            /// Converts the current value to the type of the other MultiType.
     353            inline bool                       convert(const MultiType& other) { return this->convert(other.getType()); }
    324354            bool                              convert(MT_Type::Value type);
    325355
    326             /** @brief Current content gets deleted. New type is MT_Type::Null */
     356            /// Current content gets deleted. New type is MT_Type::Null
    327357            inline void                       reset()                         { if (this->value_) delete this->value_; this->value_ = 0; }
    328             /** @brief Current content gets overridden with default zero value */
     358            /// Current content gets overridden with default zero value
    329359            inline void                       resetValue()                    { if (this->value_) this->value_->reset(); }
    330360
    331             template <typename T> inline void setType()                       { this->assignValue(typename Loki::TypeTraits<T>::UnqualifiedReferredType()); } /** @brief Resets the value and changes the internal type to T. */
    332             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. */
    333             inline void                       setType(MT_Type::Value type)    { this->reset(); this->convert(type); this->resetValue();                     } /** @brief Resets the value and changes the internal type to the given type. */
    334 
    335             /** @brief Returns the current type. */
     361            /// Resets the value and changes the internal type to T.
     362            template <typename T> inline void setType()                       { this->assignValue(typename Loki::TypeTraits<T>::UnqualifiedReferredType()); }
     363            /// Resets the value and changes the internal type to the type of the other MultiType.
     364            inline void                       setType(const MultiType& other) { this->setType(other.getType());                                             }
     365            /// Resets the value and changes the internal type to the given type.
     366            inline void                       setType(MT_Type::Value type)    { this->reset(); this->convert(type); this->resetValue();                     }
     367
     368            /// Returns the current type.
    336369            inline MT_Type::Value             getType()                   const { return (this->value_) ? this->value_->type_ : MT_Type::Null; }
    337             /** @brief Returns true if the current type equals the given type. */
     370            /// Returns true if the current type equals the given type.
    338371            inline bool                       isType(MT_Type::Value type) const { return (this->value_) ? (this->value_->type_ == type) : (type == MT_Type::Null); }
    339             /** @brief Returns true if the current type is T. */
     372            /// Returns true if the current type is T.
    340373            template <typename T> inline bool isType()                    const { return false; } // Only works for specialized values - see below
    341374            std::string                       getTypename()               const;
    342375
    343             /** @brief Saves the value of the MT to a bytestream (pointed at by mem) and increases mem pointer by size of MT */
     376            /// Saves the value of the MT to a bytestream (pointed at by mem) and increases mem pointer by size of MT
    344377            inline void                       exportData(uint8_t*& mem) const { assert(sizeof(MT_Type::Value)<=8); *static_cast<uint8_t*>(mem) = this->getType(); mem+=sizeof(uint8_t); this->value_->exportData(mem); }
    345             /** @brief Loads the value of the MT from a bytestream (pointed at by mem) and increases mem pointer by size of MT */
     378            /// Loads the value of the MT from a bytestream (pointed at by mem) and increases mem pointer by size of MT
    346379            inline void                       importData(uint8_t*& mem) { assert(sizeof(MT_Type::Value)<=8); this->setType(static_cast<MT_Type::Value>(*static_cast<uint8_t*>(mem))); mem+=sizeof(uint8_t); this->value_->importData(mem); }
    347             /** @brief Saves the value of the MT to a bytestream and increases pointer to bytestream by size of MT */
     380            /// Saves the value of the MT to a bytestream and increases pointer to bytestream by size of MT
    348381            inline uint8_t*&                  operator << (uint8_t*& mem) { importData(mem); return mem; }
    349             /** @brief Loads the value of the MT to a bytestream and increases pointer to bytestream by size of MT */
     382            /// Loads the value of the MT to a bytestream and increases pointer to bytestream by size of MT
    350383            inline void                       operator >> (uint8_t*& mem) const { exportData(mem); }
    351384            inline uint32_t                   getNetworkSize() const { assert(this->value_); return this->value_->getSize() + sizeof(uint8_t); }
    352385
    353             /** @brief Checks whether the value is a default one. */
     386            /// Checks whether the value is a default one (assigned after a failed conversion)
    354387            bool                              hasDefaultValue() const { return this->value_->hasDefaultValue(); }
    355388
    356             /** @brief Checks if the MT contains no value. */
     389            /// Checks if the MT contains no value.
    357390            bool                              null() const { return (!this->value_); }
    358391
     
    380413            operator orxonox::Radian()       const;
    381414            operator orxonox::Degree()       const;
    382             /** @brief Returns the current value, converted to a T* pointer. */
     415            /// Returns the current value, converted to a T* pointer.
    383416            template <class T> operator T*() const { return (static_cast<T*>(this->operator void*())); }
    384417
    385             inline bool getValue(char*                 value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    386             inline bool getValue(unsigned char*        value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    387             inline bool getValue(short*                value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    388             inline bool getValue(unsigned short*       value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    389             inline bool getValue(int*                  value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    390             inline bool getValue(unsigned int*         value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    391             inline bool getValue(long*                 value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    392             inline bool getValue(unsigned long*        value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    393             inline bool getValue(long long*            value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    394             inline bool getValue(unsigned long long*   value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    395             inline bool getValue(float*                value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    396             inline bool getValue(double*               value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    397             inline bool getValue(long double*          value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    398             inline bool getValue(bool*                 value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    399             inline bool getValue(void**                value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    400             inline bool getValue(std::string*          value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    401             inline bool getValue(orxonox::Vector2*     value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    402             inline bool getValue(orxonox::Vector3*     value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    403             inline bool getValue(orxonox::Vector4*     value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    404             inline bool getValue(orxonox::ColourValue* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    405             inline bool getValue(orxonox::Quaternion*  value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    406             inline bool getValue(orxonox::Radian*      value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    407             inline bool getValue(orxonox::Degree*      value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    408 
    409             inline char                     getChar()             const { return this->operator char();                 } /** @brief Returns the current value, converted to the requested type. */
    410             inline unsigned char            getUnsignedChar()     const { return this->operator unsigned char();        } /** @brief Returns the current value, converted to the requested type. */
    411             inline short                    getShort()            const { return this->operator short();                } /** @brief Returns the current value, converted to the requested type. */
    412             inline unsigned short           getUnsignedShort()    const { return this->operator unsigned short();       } /** @brief Returns the current value, converted to the requested type. */
    413             inline int                      getInt()              const { return this->operator int();                  } /** @brief Returns the current value, converted to the requested type. */
    414             inline unsigned int             getUnsignedInt()      const { return this->operator unsigned int();         } /** @brief Returns the current value, converted to the requested type. */
    415             inline long                     getLong()             const { return this->operator long();                 } /** @brief Returns the current value, converted to the requested type. */
    416             inline unsigned long            getUnsignedLong()     const { return this->operator unsigned long();        } /** @brief Returns the current value, converted to the requested type. */
    417             inline long long                getLongLong()         const { return this->operator long long();            } /** @brief Returns the current value, converted to the requested type. */
    418             inline unsigned long long       getUnsignedLongLong() const { return this->operator unsigned long long();   } /** @brief Returns the current value, converted to the requested type. */
    419             inline float                    getFloat()            const { return this->operator float();                } /** @brief Returns the current value, converted to the requested type. */
    420             inline double                   getDouble()           const { return this->operator double();               } /** @brief Returns the current value, converted to the requested type. */
    421             inline long double              getLongDouble()       const { return this->operator long double();          } /** @brief Returns the current value, converted to the requested type. */
    422             inline bool                     getBool()             const { return this->operator bool();                 } /** @brief Returns the current value, converted to the requested type. */
    423             inline void*                    getVoid()             const { return this->operator void*();                } /** @brief Returns the current value, converted to the requested type. */
    424             inline std::string              getString()           const { return this->operator std::string();          } /** @brief Returns the current value, converted to the requested type. */
    425             inline orxonox::Vector2         getVector2()          const { return this->operator orxonox::Vector2();     } /** @brief Returns the current value, converted to the requested type. */
    426             inline orxonox::Vector3         getVector3()          const { return this->operator orxonox::Vector3();     } /** @brief Returns the current value, converted to the requested type. */
    427             inline orxonox::Vector4         getVector4()          const { return this->operator orxonox::Vector4();     } /** @brief Returns the current value, converted to the requested type. */
    428             inline orxonox::ColourValue     getColourValue()      const { return this->operator orxonox::ColourValue(); } /** @brief Returns the current value, converted to the requested type. */
    429             inline orxonox::Quaternion      getQuaternion()       const { return this->operator orxonox::Quaternion();  } /** @brief Returns the current value, converted to the requested type. */
    430             inline orxonox::Radian          getRadian()           const { return this->operator orxonox::Radian();      } /** @brief Returns the current value, converted to the requested type. */
    431             inline orxonox::Degree          getDegree()           const { return this->operator orxonox::Degree();      } /** @brief Returns the current value, converted to the requested type. */
    432             template <typename T> inline T* getPointer()          const { return static_cast<T*>(this->getVoid());      } /** @brief Returns the current value, converted to a T* pointer. */
     418            inline bool getValue(char*                 value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     419            inline bool getValue(unsigned char*        value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     420            inline bool getValue(short*                value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     421            inline bool getValue(unsigned short*       value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     422            inline bool getValue(int*                  value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     423            inline bool getValue(unsigned int*         value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     424            inline bool getValue(long*                 value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     425            inline bool getValue(unsigned long*        value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     426            inline bool getValue(long long*            value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     427            inline bool getValue(unsigned long long*   value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     428            inline bool getValue(float*                value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     429            inline bool getValue(double*               value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     430            inline bool getValue(long double*          value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     431            inline bool getValue(bool*                 value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     432            inline bool getValue(void**                value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     433            inline bool getValue(std::string*          value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     434            inline bool getValue(orxonox::Vector2*     value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     435            inline bool getValue(orxonox::Vector3*     value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     436            inline bool getValue(orxonox::Vector4*     value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     437            inline bool getValue(orxonox::ColourValue* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     438            inline bool getValue(orxonox::Quaternion*  value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     439            inline bool getValue(orxonox::Radian*      value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     440            inline bool getValue(orxonox::Degree*      value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     441
     442            inline char                     getChar()             const { return this->operator char();                 } ///< Returns the current value, converted to the requested type.
     443            inline unsigned char            getUnsignedChar()     const { return this->operator unsigned char();        } ///< Returns the current value, converted to the requested type.
     444            inline short                    getShort()            const { return this->operator short();                } ///< Returns the current value, converted to the requested type.
     445            inline unsigned short           getUnsignedShort()    const { return this->operator unsigned short();       } ///< Returns the current value, converted to the requested type.
     446            inline int                      getInt()              const { return this->operator int();                  } ///< Returns the current value, converted to the requested type.
     447            inline unsigned int             getUnsignedInt()      const { return this->operator unsigned int();         } ///< Returns the current value, converted to the requested type.
     448            inline long                     getLong()             const { return this->operator long();                 } ///< Returns the current value, converted to the requested type.
     449            inline unsigned long            getUnsignedLong()     const { return this->operator unsigned long();        } ///< Returns the current value, converted to the requested type.
     450            inline long long                getLongLong()         const { return this->operator long long();            } ///< Returns the current value, converted to the requested type.
     451            inline unsigned long long       getUnsignedLongLong() const { return this->operator unsigned long long();   } ///< Returns the current value, converted to the requested type.
     452            inline float                    getFloat()            const { return this->operator float();                } ///< Returns the current value, converted to the requested type.
     453            inline double                   getDouble()           const { return this->operator double();               } ///< Returns the current value, converted to the requested type.
     454            inline long double              getLongDouble()       const { return this->operator long double();          } ///< Returns the current value, converted to the requested type.
     455            inline bool                     getBool()             const { return this->operator bool();                 } ///< Returns the current value, converted to the requested type.
     456            inline void*                    getVoid()             const { return this->operator void*();                } ///< Returns the current value, converted to the requested type.
     457            inline std::string              getString()           const { return this->operator std::string();          } ///< Returns the current value, converted to the requested type.
     458            inline orxonox::Vector2         getVector2()          const { return this->operator orxonox::Vector2();     } ///< Returns the current value, converted to the requested type.
     459            inline orxonox::Vector3         getVector3()          const { return this->operator orxonox::Vector3();     } ///< Returns the current value, converted to the requested type.
     460            inline orxonox::Vector4         getVector4()          const { return this->operator orxonox::Vector4();     } ///< Returns the current value, converted to the requested type.
     461            inline orxonox::ColourValue     getColourValue()      const { return this->operator orxonox::ColourValue(); } ///< Returns the current value, converted to the requested type.
     462            inline orxonox::Quaternion      getQuaternion()       const { return this->operator orxonox::Quaternion();  } ///< Returns the current value, converted to the requested type.
     463            inline orxonox::Radian          getRadian()           const { return this->operator orxonox::Radian();      } ///< Returns the current value, converted to the requested type.
     464            inline orxonox::Degree          getDegree()           const { return this->operator orxonox::Degree();      } ///< Returns the current value, converted to the requested type.
     465            template <typename T> inline T* getPointer()          const { return static_cast<T*>(this->getVoid());      } ///< Returns the current value, converted to a T* pointer.
    433466
    434467        private:
    435             inline bool assignValue(const char& value)                 { if (this->value_ && this->value_->type_ == MT_Type::Char)             { return this->value_->setValue(value); } else { this->changeValueContainer<char>(value);                 return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
    436             inline bool assignValue(const unsigned char& value)        { if (this->value_ && this->value_->type_ == MT_Type::UnsignedChar)     { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned char>(value);        return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
    437             inline bool assignValue(const short& value)                { if (this->value_ && this->value_->type_ == MT_Type::Short)            { return this->value_->setValue(value); } else { this->changeValueContainer<short>(value);                return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
    438             inline bool assignValue(const unsigned short& value)       { if (this->value_ && this->value_->type_ == MT_Type::UnsignedShort)    { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned short>(value);       return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
    439             inline bool assignValue(const int& value)                  { if (this->value_ && this->value_->type_ == MT_Type::Int)              { return this->value_->setValue(value); } else { this->changeValueContainer<int>(value);                  return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
    440             inline bool assignValue(const unsigned int& value)         { if (this->value_ && this->value_->type_ == MT_Type::UnsignedInt)      { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned int>(value);         return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
    441             inline bool assignValue(const long& value)                 { if (this->value_ && this->value_->type_ == MT_Type::Long)             { return this->value_->setValue(value); } else { this->changeValueContainer<long>(value);                 return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
    442             inline bool assignValue(const unsigned long& value)        { if (this->value_ && this->value_->type_ == MT_Type::UnsignedLong)     { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned long>(value);        return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
    443             inline bool assignValue(const long long& value)            { if (this->value_ && this->value_->type_ == MT_Type::LongLong)         { return this->value_->setValue(value); } else { this->changeValueContainer<long long>(value);            return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
    444             inline bool assignValue(const unsigned long long& value)   { if (this->value_ && this->value_->type_ == MT_Type::UnsignedLongLong) { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned long long>(value);   return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
    445             inline bool assignValue(const float& value)                { if (this->value_ && this->value_->type_ == MT_Type::Float)            { return this->value_->setValue(value); } else { this->changeValueContainer<float>(value);                return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
    446             inline bool assignValue(const double& value)               { if (this->value_ && this->value_->type_ == MT_Type::Double)           { return this->value_->setValue(value); } else { this->changeValueContainer<double>(value);               return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
    447             inline bool assignValue(const long double& value)          { if (this->value_ && this->value_->type_ == MT_Type::LongDouble)       { return this->value_->setValue(value); } else { this->changeValueContainer<long double>(value);          return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
    448             inline bool assignValue(const bool& value)                 { if (this->value_ && this->value_->type_ == MT_Type::Bool)             { return this->value_->setValue(value); } else { this->changeValueContainer<bool>(value);                 return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
    449             inline bool assignValue(      void* const& value)          { if (this->value_ && this->value_->type_ == MT_Type::VoidPointer)      { return this->value_->setValue(value); } else { this->changeValueContainer<void*>(value);                return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
    450             inline bool assignValue(const std::string& value)          { if (this->value_ && this->value_->type_ == MT_Type::String)           { return this->value_->setValue(value); } else { this->changeValueContainer<std::string>(value);          return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
    451             inline bool assignValue(const orxonox::Vector2& value)     { if (this->value_ && this->value_->type_ == MT_Type::Vector2)          { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector2>(value);     return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
    452             inline bool assignValue(const orxonox::Vector3& value)     { if (this->value_ && this->value_->type_ == MT_Type::Vector3)          { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector3>(value);     return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
    453             inline bool assignValue(const orxonox::Vector4& value)     { if (this->value_ && this->value_->type_ == MT_Type::Vector4)          { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector4>(value);     return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
    454             inline bool assignValue(const orxonox::ColourValue& value) { if (this->value_ && this->value_->type_ == MT_Type::ColourValue)      { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::ColourValue>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
    455             inline bool assignValue(const orxonox::Quaternion& value)  { if (this->value_ && this->value_->type_ == MT_Type::Quaternion)       { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Quaternion>(value);  return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
    456             inline bool assignValue(const orxonox::Radian& value)      { if (this->value_ && this->value_->type_ == MT_Type::Radian)           { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Radian>(value);      return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
    457             inline bool assignValue(const orxonox::Degree& value)      { if (this->value_ && this->value_->type_ == MT_Type::Degree)           { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Degree>(value);      return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
    458 
    459             /** @brief Changes the value container. */
     468            inline bool assignValue(const char& value)                 { if (this->value_ && this->value_->type_ == MT_Type::Char)             { return this->value_->setValue(value); } else { this->changeValueContainer<char>(value);                 return true; } } ///< Assigns a new value by changing type and creating a new container.
     469            inline bool assignValue(const unsigned char& value)        { if (this->value_ && this->value_->type_ == MT_Type::UnsignedChar)     { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned char>(value);        return true; } } ///< Assigns a new value by changing type and creating a new container.
     470            inline bool assignValue(const short& value)                { if (this->value_ && this->value_->type_ == MT_Type::Short)            { return this->value_->setValue(value); } else { this->changeValueContainer<short>(value);                return true; } } ///< Assigns a new value by changing type and creating a new container.
     471            inline bool assignValue(const unsigned short& value)       { if (this->value_ && this->value_->type_ == MT_Type::UnsignedShort)    { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned short>(value);       return true; } } ///< Assigns a new value by changing type and creating a new container.
     472            inline bool assignValue(const int& value)                  { if (this->value_ && this->value_->type_ == MT_Type::Int)              { return this->value_->setValue(value); } else { this->changeValueContainer<int>(value);                  return true; } } ///< Assigns a new value by changing type and creating a new container.
     473            inline bool assignValue(const unsigned int& value)         { if (this->value_ && this->value_->type_ == MT_Type::UnsignedInt)      { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned int>(value);         return true; } } ///< Assigns a new value by changing type and creating a new container.
     474            inline bool assignValue(const long& value)                 { if (this->value_ && this->value_->type_ == MT_Type::Long)             { return this->value_->setValue(value); } else { this->changeValueContainer<long>(value);                 return true; } } ///< Assigns a new value by changing type and creating a new container.
     475            inline bool assignValue(const unsigned long& value)        { if (this->value_ && this->value_->type_ == MT_Type::UnsignedLong)     { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned long>(value);        return true; } } ///< Assigns a new value by changing type and creating a new container.
     476            inline bool assignValue(const long long& value)            { if (this->value_ && this->value_->type_ == MT_Type::LongLong)         { return this->value_->setValue(value); } else { this->changeValueContainer<long long>(value);            return true; } } ///< Assigns a new value by changing type and creating a new container.
     477            inline bool assignValue(const unsigned long long& value)   { if (this->value_ && this->value_->type_ == MT_Type::UnsignedLongLong) { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned long long>(value);   return true; } } ///< Assigns a new value by changing type and creating a new container.
     478            inline bool assignValue(const float& value)                { if (this->value_ && this->value_->type_ == MT_Type::Float)            { return this->value_->setValue(value); } else { this->changeValueContainer<float>(value);                return true; } } ///< Assigns a new value by changing type and creating a new container.
     479            inline bool assignValue(const double& value)               { if (this->value_ && this->value_->type_ == MT_Type::Double)           { return this->value_->setValue(value); } else { this->changeValueContainer<double>(value);               return true; } } ///< Assigns a new value by changing type and creating a new container.
     480            inline bool assignValue(const long double& value)          { if (this->value_ && this->value_->type_ == MT_Type::LongDouble)       { return this->value_->setValue(value); } else { this->changeValueContainer<long double>(value);          return true; } } ///< Assigns a new value by changing type and creating a new container.
     481            inline bool assignValue(const bool& value)                 { if (this->value_ && this->value_->type_ == MT_Type::Bool)             { return this->value_->setValue(value); } else { this->changeValueContainer<bool>(value);                 return true; } } ///< Assigns a new value by changing type and creating a new container.
     482            inline bool assignValue(      void* const& value)          { if (this->value_ && this->value_->type_ == MT_Type::VoidPointer)      { return this->value_->setValue(value); } else { this->changeValueContainer<void*>(value);                return true; } } ///< Assigns a new value by changing type and creating a new container.
     483            inline bool assignValue(const std::string& value)          { if (this->value_ && this->value_->type_ == MT_Type::String)           { return this->value_->setValue(value); } else { this->changeValueContainer<std::string>(value);          return true; } } ///< Assigns a new value by changing type and creating a new container.
     484            inline bool assignValue(const orxonox::Vector2& value)     { if (this->value_ && this->value_->type_ == MT_Type::Vector2)          { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector2>(value);     return true; } } ///< Assigns a new value by changing type and creating a new container.
     485            inline bool assignValue(const orxonox::Vector3& value)     { if (this->value_ && this->value_->type_ == MT_Type::Vector3)          { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector3>(value);     return true; } } ///< Assigns a new value by changing type and creating a new container.
     486            inline bool assignValue(const orxonox::Vector4& value)     { if (this->value_ && this->value_->type_ == MT_Type::Vector4)          { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector4>(value);     return true; } } ///< Assigns a new value by changing type and creating a new container.
     487            inline bool assignValue(const orxonox::ColourValue& value) { if (this->value_ && this->value_->type_ == MT_Type::ColourValue)      { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::ColourValue>(value); return true; } } ///< Assigns a new value by changing type and creating a new container.
     488            inline bool assignValue(const orxonox::Quaternion& value)  { if (this->value_ && this->value_->type_ == MT_Type::Quaternion)       { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Quaternion>(value);  return true; } } ///< Assigns a new value by changing type and creating a new container.
     489            inline bool assignValue(const orxonox::Radian& value)      { if (this->value_ && this->value_->type_ == MT_Type::Radian)           { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Radian>(value);      return true; } } ///< Assigns a new value by changing type and creating a new container.
     490            inline bool assignValue(const orxonox::Degree& value)      { if (this->value_ && this->value_->type_ == MT_Type::Degree)           { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Degree>(value);      return true; } } ///< Assigns a new value by changing type and creating a new container.
     491
     492            /// Changes the value container.
    460493            template <typename T> inline void changeValueContainer(const T& value) { if (this->value_) { delete this->value_; } this->createNewValueContainer<T>(value); }
    461             /** @brief Creates a new value container (works only with specialized types). */
     494            /// Creates a new value container (works only with specialized types).
    462495            template <typename T>        void createNewValueContainer(const T& value) { /* STATIC ASSERT */ *****value; return false; }
    463496
     
    465498    };
    466499
    467     /** @brief Puts the MultiType on a stream by using the native << operator of the current type. */
     500    /// Puts the MultiType on a stream by using the native << operator of the current type.
    468501    _UtilExport inline std::ostream& operator<<(std::ostream& outstream, const MultiType& mt) { if (mt.value_) { mt.value_->toString(outstream); } return outstream; }
    469502
    470     template <> inline bool MultiType::isType<char>()                 const { return (this->value_ && this->value_->type_ == MT_Type::Char);             } /** @brief Returns true if the current type equals the given type. */
    471     template <> inline bool MultiType::isType<unsigned char>()        const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedChar);     } /** @brief Returns true if the current type equals the given type. */
    472     template <> inline bool MultiType::isType<short>()                const { return (this->value_ && this->value_->type_ == MT_Type::Short);            } /** @brief Returns true if the current type equals the given type. */
    473     template <> inline bool MultiType::isType<unsigned short>()       const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedShort);    } /** @brief Returns true if the current type equals the given type. */
    474     template <> inline bool MultiType::isType<int>()                  const { return (this->value_ && this->value_->type_ == MT_Type::Int);              } /** @brief Returns true if the current type equals the given type. */
    475     template <> inline bool MultiType::isType<unsigned int>()         const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedInt);      } /** @brief Returns true if the current type equals the given type. */
    476     template <> inline bool MultiType::isType<long>()                 const { return (this->value_ && this->value_->type_ == MT_Type::Long);             } /** @brief Returns true if the current type equals the given type. */
    477     template <> inline bool MultiType::isType<unsigned long>()        const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedLong);     } /** @brief Returns true if the current type equals the given type. */
    478     template <> inline bool MultiType::isType<long long>()            const { return (this->value_ && this->value_->type_ == MT_Type::LongLong);         } /** @brief Returns true if the current type equals the given type. */
    479     template <> inline bool MultiType::isType<unsigned long long>()   const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedLongLong); } /** @brief Returns true if the current type equals the given type. */
    480     template <> inline bool MultiType::isType<float>()                const { return (this->value_ && this->value_->type_ == MT_Type::Float);            } /** @brief Returns true if the current type equals the given type. */
    481     template <> inline bool MultiType::isType<double>()               const { return (this->value_ && this->value_->type_ == MT_Type::Double);           } /** @brief Returns true if the current type equals the given type. */
    482     template <> inline bool MultiType::isType<long double>()          const { return (this->value_ && this->value_->type_ == MT_Type::LongDouble);       } /** @brief Returns true if the current type equals the given type. */
    483     template <> inline bool MultiType::isType<bool>()                 const { return (this->value_ && this->value_->type_ == MT_Type::Bool);             } /** @brief Returns true if the current type equals the given type. */
    484     template <> inline bool MultiType::isType<void*>()                const { return (this->value_ && this->value_->type_ == MT_Type::VoidPointer);      } /** @brief Returns true if the current type equals the given type. */
    485     template <> inline bool MultiType::isType<std::string>()          const { return (this->value_ && this->value_->type_ == MT_Type::String);           } /** @brief Returns true if the current type equals the given type. */
    486     template <> inline bool MultiType::isType<orxonox::Vector2>()     const { return (this->value_ && this->value_->type_ == MT_Type::Vector2);          } /** @brief Returns true if the current type equals the given type. */
    487     template <> inline bool MultiType::isType<orxonox::Vector3>()     const { return (this->value_ && this->value_->type_ == MT_Type::Vector3);          } /** @brief Returns true if the current type equals the given type. */
    488     template <> inline bool MultiType::isType<orxonox::Vector4>()     const { return (this->value_ && this->value_->type_ == MT_Type::Vector4);          } /** @brief Returns true if the current type equals the given type. */
    489     template <> inline bool MultiType::isType<orxonox::ColourValue>() const { return (this->value_ && this->value_->type_ == MT_Type::ColourValue);      } /** @brief Returns true if the current type equals the given type. */
    490     template <> inline bool MultiType::isType<orxonox::Quaternion>()  const { return (this->value_ && this->value_->type_ == MT_Type::Quaternion);       } /** @brief Returns true if the current type equals the given type. */
    491     template <> inline bool MultiType::isType<orxonox::Radian>()      const { return (this->value_ && this->value_->type_ == MT_Type::Radian);           } /** @brief Returns true if the current type equals the given type. */
    492     template <> inline bool MultiType::isType<orxonox::Degree>()      const { return (this->value_ && this->value_->type_ == MT_Type::Degree);           } /** @brief Returns true if the current type equals the given type. */
    493 
    494     template <> inline bool MultiType::convert<void>()                 { this->reset(); return true; } /** @brief Deletes the content, type becomes MT_Type::Null. */
     503    template <> inline bool MultiType::isType<char>()                 const { return (this->value_ && this->value_->type_ == MT_Type::Char);             } ///< Returns true if the current type equals the given type.
     504    template <> inline bool MultiType::isType<unsigned char>()        const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedChar);     } ///< Returns true if the current type equals the given type.
     505    template <> inline bool MultiType::isType<short>()                const { return (this->value_ && this->value_->type_ == MT_Type::Short);            } ///< Returns true if the current type equals the given type.
     506    template <> inline bool MultiType::isType<unsigned short>()       const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedShort);    } ///< Returns true if the current type equals the given type.
     507    template <> inline bool MultiType::isType<int>()                  const { return (this->value_ && this->value_->type_ == MT_Type::Int);              } ///< Returns true if the current type equals the given type.
     508    template <> inline bool MultiType::isType<unsigned int>()         const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedInt);      } ///< Returns true if the current type equals the given type.
     509    template <> inline bool MultiType::isType<long>()                 const { return (this->value_ && this->value_->type_ == MT_Type::Long);             } ///< Returns true if the current type equals the given type.
     510    template <> inline bool MultiType::isType<unsigned long>()        const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedLong);     } ///< Returns true if the current type equals the given type.
     511    template <> inline bool MultiType::isType<long long>()            const { return (this->value_ && this->value_->type_ == MT_Type::LongLong);         } ///< Returns true if the current type equals the given type.
     512    template <> inline bool MultiType::isType<unsigned long long>()   const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedLongLong); } ///< Returns true if the current type equals the given type.
     513    template <> inline bool MultiType::isType<float>()                const { return (this->value_ && this->value_->type_ == MT_Type::Float);            } ///< Returns true if the current type equals the given type.
     514    template <> inline bool MultiType::isType<double>()               const { return (this->value_ && this->value_->type_ == MT_Type::Double);           } ///< Returns true if the current type equals the given type.
     515    template <> inline bool MultiType::isType<long double>()          const { return (this->value_ && this->value_->type_ == MT_Type::LongDouble);       } ///< Returns true if the current type equals the given type.
     516    template <> inline bool MultiType::isType<bool>()                 const { return (this->value_ && this->value_->type_ == MT_Type::Bool);             } ///< Returns true if the current type equals the given type.
     517    template <> inline bool MultiType::isType<void*>()                const { return (this->value_ && this->value_->type_ == MT_Type::VoidPointer);      } ///< Returns true if the current type equals the given type.
     518    template <> inline bool MultiType::isType<std::string>()          const { return (this->value_ && this->value_->type_ == MT_Type::String);           } ///< Returns true if the current type equals the given type.
     519    template <> inline bool MultiType::isType<orxonox::Vector2>()     const { return (this->value_ && this->value_->type_ == MT_Type::Vector2);          } ///< Returns true if the current type equals the given type.
     520    template <> inline bool MultiType::isType<orxonox::Vector3>()     const { return (this->value_ && this->value_->type_ == MT_Type::Vector3);          } ///< Returns true if the current type equals the given type.
     521    template <> inline bool MultiType::isType<orxonox::Vector4>()     const { return (this->value_ && this->value_->type_ == MT_Type::Vector4);          } ///< Returns true if the current type equals the given type.
     522    template <> inline bool MultiType::isType<orxonox::ColourValue>() const { return (this->value_ && this->value_->type_ == MT_Type::ColourValue);      } ///< Returns true if the current type equals the given type.
     523    template <> inline bool MultiType::isType<orxonox::Quaternion>()  const { return (this->value_ && this->value_->type_ == MT_Type::Quaternion);       } ///< Returns true if the current type equals the given type.
     524    template <> inline bool MultiType::isType<orxonox::Radian>()      const { return (this->value_ && this->value_->type_ == MT_Type::Radian);           } ///< Returns true if the current type equals the given type.
     525    template <> inline bool MultiType::isType<orxonox::Degree>()      const { return (this->value_ && this->value_->type_ == MT_Type::Degree);           } ///< Returns true if the current type equals the given type.
     526
     527    /// Deletes the content, type becomes MT_Type::Null.
     528    template <> inline bool MultiType::convert<void>()                 { this->reset(); return true; }
    495529
    496530    // Specialization to avoid ambiguities with the conversion operator
    497     template <> inline bool MultiType::convert<std::string>()          { return this->setValue<std::string>         (this->operator std::string());          } /** @brief Converts the current value to the given type. */
    498     template <> inline bool MultiType::convert<orxonox::Vector2>()     { return this->setValue<orxonox::Vector2>    (this->operator orxonox::Vector2());     } /** @brief Converts the current value to the given type. */
    499     template <> inline bool MultiType::convert<orxonox::Vector3>()     { return this->setValue<orxonox::Vector3>    (this->operator orxonox::Vector3());     } /** @brief Converts the current value to the given type. */
    500     template <> inline bool MultiType::convert<orxonox::Vector4>()     { return this->setValue<orxonox::Vector4>    (this->operator orxonox::Vector4());     } /** @brief Converts the current value to the given type. */
    501     template <> inline bool MultiType::convert<orxonox::ColourValue>() { return this->setValue<orxonox::ColourValue>(this->operator orxonox::ColourValue()); } /** @brief Converts the current value to the given type. */
    502     template <> inline bool MultiType::convert<orxonox::Quaternion>()  { return this->setValue<orxonox::Quaternion> (this->operator orxonox::Quaternion());  } /** @brief Converts the current value to the given type. */
    503     template <> inline bool MultiType::convert<orxonox::Radian>()      { return this->setValue<orxonox::Radian>     (this->operator orxonox::Radian());      } /** @brief Converts the current value to the given type. */
    504     template <> inline bool MultiType::convert<orxonox::Degree>()      { return this->setValue<orxonox::Degree>     (this->operator orxonox::Degree());      } /** @brief Converts the current value to the given type. */
     531    template <> inline bool MultiType::convert<std::string>()          { return this->setValue<std::string>         (this->operator std::string());          } ///< Converts the current value to the given type.
     532    template <> inline bool MultiType::convert<orxonox::Vector2>()     { return this->setValue<orxonox::Vector2>    (this->operator orxonox::Vector2());     } ///< Converts the current value to the given type.
     533    template <> inline bool MultiType::convert<orxonox::Vector3>()     { return this->setValue<orxonox::Vector3>    (this->operator orxonox::Vector3());     } ///< Converts the current value to the given type.
     534    template <> inline bool MultiType::convert<orxonox::Vector4>()     { return this->setValue<orxonox::Vector4>    (this->operator orxonox::Vector4());     } ///< Converts the current value to the given type.
     535    template <> inline bool MultiType::convert<orxonox::ColourValue>() { return this->setValue<orxonox::ColourValue>(this->operator orxonox::ColourValue()); } ///< Converts the current value to the given type.
     536    template <> inline bool MultiType::convert<orxonox::Quaternion>()  { return this->setValue<orxonox::Quaternion> (this->operator orxonox::Quaternion());  } ///< Converts the current value to the given type.
     537    template <> inline bool MultiType::convert<orxonox::Radian>()      { return this->setValue<orxonox::Radian>     (this->operator orxonox::Radian());      } ///< Converts the current value to the given type.
     538    template <> inline bool MultiType::convert<orxonox::Degree>()      { return this->setValue<orxonox::Degree>     (this->operator orxonox::Degree());      } ///< Converts the current value to the given type.
    505539
    506540    // Specialization to avoid ambiguities with the conversion operator
    507     template <> inline bool MultiType::convert<const std::string&>()          { return this->convert<std::string>();          } /** @brief Converts the current value to the given type. */
    508     template <> inline bool MultiType::convert<const orxonox::Vector2&>()     { return this->convert<orxonox::Vector2>();     } /** @brief Converts the current value to the given type. */
    509     template <> inline bool MultiType::convert<const orxonox::Vector3&>()     { return this->convert<orxonox::Vector3>();     } /** @brief Converts the current value to the given type. */
    510     template <> inline bool MultiType::convert<const orxonox::Vector4&>()     { return this->convert<orxonox::Vector4>();     } /** @brief Converts the current value to the given type. */
    511     template <> inline bool MultiType::convert<const orxonox::ColourValue&>() { return this->convert<orxonox::ColourValue>(); } /** @brief Converts the current value to the given type. */
    512     template <> inline bool MultiType::convert<const orxonox::Quaternion&>()  { return this->convert<orxonox::Quaternion>();  } /** @brief Converts the current value to the given type. */
    513     template <> inline bool MultiType::convert<const orxonox::Radian&>()      { return this->convert<orxonox::Radian>();      } /** @brief Converts the current value to the given type. */
    514     template <> inline bool MultiType::convert<const orxonox::Degree&>()      { return this->convert<orxonox::Degree>();      } /** @brief Converts the current value to the given type. */
     541    template <> inline bool MultiType::convert<const std::string&>()          { return this->convert<std::string>();          } ///< Converts the current value to the given type.
     542    template <> inline bool MultiType::convert<const orxonox::Vector2&>()     { return this->convert<orxonox::Vector2>();     } ///< Converts the current value to the given type.
     543    template <> inline bool MultiType::convert<const orxonox::Vector3&>()     { return this->convert<orxonox::Vector3>();     } ///< Converts the current value to the given type.
     544    template <> inline bool MultiType::convert<const orxonox::Vector4&>()     { return this->convert<orxonox::Vector4>();     } ///< Converts the current value to the given type.
     545    template <> inline bool MultiType::convert<const orxonox::ColourValue&>() { return this->convert<orxonox::ColourValue>(); } ///< Converts the current value to the given type.
     546    template <> inline bool MultiType::convert<const orxonox::Quaternion&>()  { return this->convert<orxonox::Quaternion>();  } ///< Converts the current value to the given type.
     547    template <> inline bool MultiType::convert<const orxonox::Radian&>()      { return this->convert<orxonox::Radian>();      } ///< Converts the current value to the given type.
     548    template <> inline bool MultiType::convert<const orxonox::Degree&>()      { return this->convert<orxonox::Degree>();      } ///< Converts the current value to the given type.
    515549
    516550    template <> _UtilExport void MultiType::createNewValueContainer(const char& value);
     
    538572    template <> _UtilExport void MultiType::createNewValueContainer(const orxonox::Degree& value);
    539573
    540     inline bool MultiType::setValue(const char& value)                  { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
    541     inline bool MultiType::setValue(const unsigned char& value)         { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
    542     inline bool MultiType::setValue(const short& value)                 { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
    543     inline bool MultiType::setValue(const unsigned short& value)        { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
    544     inline bool MultiType::setValue(const int& value)                   { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
    545     inline bool MultiType::setValue(const unsigned int& value)          { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
    546     inline bool MultiType::setValue(const long& value)                  { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
    547     inline bool MultiType::setValue(const unsigned long& value)         { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
    548     inline bool MultiType::setValue(const long long& value)             { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
    549     inline bool MultiType::setValue(const unsigned long long& value)    { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
    550     inline bool MultiType::setValue(const float& value)                 { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
    551     inline bool MultiType::setValue(const double& value)                { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
    552     inline bool MultiType::setValue(const long double& value)           { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
    553     inline bool MultiType::setValue(const bool& value)                  { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
    554     inline bool MultiType::setValue(      void* const& value)           { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
    555     inline bool MultiType::setValue(const std::string& value)           { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
    556     inline bool MultiType::setValue(const orxonox::Vector2& value)      { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
    557     inline bool MultiType::setValue(const orxonox::Vector3& value)      { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
    558     inline bool MultiType::setValue(const orxonox::Vector4& value)      { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
    559     inline bool MultiType::setValue(const orxonox::ColourValue& value)  { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
    560     inline bool MultiType::setValue(const orxonox::Quaternion& value)   { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
    561     inline bool MultiType::setValue(const orxonox::Radian& value)       { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
    562     inline bool MultiType::setValue(const orxonox::Degree& value)       { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
    563 
    564     inline bool MultiType::setValue(const char* value)                  { if (this->value_) { return this->value_->setValue(std::string(value)); } else { return this->assignValue(std::string(value)); } }  /** @brief Assigns the given value and converts it to the current type. */
     574    inline bool MultiType::setValue(const char& value)                  { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
     575    inline bool MultiType::setValue(const unsigned char& value)         { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
     576    inline bool MultiType::setValue(const short& value)                 { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
     577    inline bool MultiType::setValue(const unsigned short& value)        { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
     578    inline bool MultiType::setValue(const int& value)                   { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
     579    inline bool MultiType::setValue(const unsigned int& value)          { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
     580    inline bool MultiType::setValue(const long& value)                  { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
     581    inline bool MultiType::setValue(const unsigned long& value)         { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
     582    inline bool MultiType::setValue(const long long& value)             { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
     583    inline bool MultiType::setValue(const unsigned long long& value)    { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
     584    inline bool MultiType::setValue(const float& value)                 { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
     585    inline bool MultiType::setValue(const double& value)                { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
     586    inline bool MultiType::setValue(const long double& value)           { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
     587    inline bool MultiType::setValue(const bool& value)                  { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
     588    inline bool MultiType::setValue(      void* const& value)           { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
     589    inline bool MultiType::setValue(const std::string& value)           { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
     590    inline bool MultiType::setValue(const orxonox::Vector2& value)      { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
     591    inline bool MultiType::setValue(const orxonox::Vector3& value)      { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
     592    inline bool MultiType::setValue(const orxonox::Vector4& value)      { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
     593    inline bool MultiType::setValue(const orxonox::ColourValue& value)  { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
     594    inline bool MultiType::setValue(const orxonox::Quaternion& value)   { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
     595    inline bool MultiType::setValue(const orxonox::Radian& value)       { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
     596    inline bool MultiType::setValue(const orxonox::Degree& value)       { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
     597
     598    /// Assigns the given value and converts it to the current type.
     599    inline bool MultiType::setValue(const char* value)                  { if (this->value_) { return this->value_->setValue(std::string(value)); } else { return this->assignValue(std::string(value)); } }
    565600}
    566601
  • code/trunk/src/libraries/util/MultiTypeValue.h

    r6417 r7401  
    2929/**
    3030    @file
     31    @ingroup MultiType
    3132    @brief Declaration and Implementation of the MT_Value<T> class.
    3233
     
    5354    {
    5455    public:
    55         /** @brief Constructor: Assigns the value and the type identifier. */
     56        /// Constructor: Assigns the value and the type identifier.
    5657        MT_Value(const T& value, MT_Type::Value type) : MT_ValueBase(type), value_(value) {}
    5758
    58         /** @brief Creates a copy of itself. */
     59        /// Creates a copy of itself.
    5960        inline MT_ValueBase* clone() const { return new MT_Value<T>(this->value_, this->type_); }
    6061
    61         /** @brief Resets the current value to the default. */
     62        /// Resets the current value to the default.
    6263        inline void reset() { this->value_ = zeroise<T>(); bHasDefaultValue_ = true; }
    6364
    64         /** @brief Assigns the value of the other MultiType, converted to T. @param other The other MultiType */
     65        /**
     66            @brief Assigns the value of the other MultiType, converted to T.
     67            @param other The other MultiType
     68        */
    6569        inline bool assimilate(const MultiType& other)
    6670        {
     
    7680        }
    7781
    78         inline bool getValue(char*                 value) const { return convertValue<T, char                >(value, value_, 0); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    79         inline bool getValue(unsigned char*        value) const { return convertValue<T, unsigned char       >(value, value_, 0); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    80         inline bool getValue(short*                value) const { return convertValue<T, short               >(value, value_, 0); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    81         inline bool getValue(unsigned short*       value) const { return convertValue<T, unsigned short      >(value, value_, 0); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    82         inline bool getValue(int*                  value) const { return convertValue<T, int                 >(value, value_, 0); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    83         inline bool getValue(unsigned int*         value) const { return convertValue<T, unsigned int        >(value, value_, 0); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    84         inline bool getValue(long*                 value) const { return convertValue<T, long                >(value, value_, 0); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    85         inline bool getValue(unsigned long*        value) const { return convertValue<T, unsigned long       >(value, value_, 0); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    86         inline bool getValue(long long*            value) const { return convertValue<T, long long           >(value, value_, 0); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    87         inline bool getValue(unsigned long long*   value) const { return convertValue<T, unsigned long long  >(value, value_, 0); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    88         inline bool getValue(float*                value) const { return convertValue<T, float               >(value, value_, 0); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    89         inline bool getValue(double*               value) const { return convertValue<T, double              >(value, value_, 0); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    90         inline bool getValue(long double*          value) const { return convertValue<T, long double         >(value, value_, 0); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    91         inline bool getValue(bool*                 value) const { return convertValue<T, bool                >(value, value_, 0); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    92         inline bool getValue(void**                value) const { return convertValue<T, void*               >(value, value_, 0); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    93         inline bool getValue(std::string*          value) const { return convertValue<T, std::string         >(value, value_, zeroise<std::string>         ()); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    94         inline bool getValue(orxonox::Vector2*     value) const { return convertValue<T, orxonox::Vector2    >(value, value_, zeroise<orxonox::Vector2>    ()); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    95         inline bool getValue(orxonox::Vector3*     value) const { return convertValue<T, orxonox::Vector3    >(value, value_, zeroise<orxonox::Vector3>    ()); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    96         inline bool getValue(orxonox::Vector4*     value) const { return convertValue<T, orxonox::Vector4    >(value, value_, zeroise<orxonox::Vector4>    ()); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    97         inline bool getValue(orxonox::ColourValue* value) const { return convertValue<T, orxonox::ColourValue>(value, value_, zeroise<orxonox::ColourValue>()); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    98         inline bool getValue(orxonox::Quaternion*  value) const { return convertValue<T, orxonox::Quaternion >(value, value_, zeroise<orxonox::Quaternion> ()); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    99         inline bool getValue(orxonox::Radian*      value) const { return convertValue<T, orxonox::Radian     >(value, value_, zeroise<orxonox::Radian>     ()); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    100         inline bool getValue(orxonox::Degree*      value) const { return convertValue<T, orxonox::Degree     >(value, value_, zeroise<orxonox::Degree>     ()); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    101 
    102         inline bool setValue(const char& value)                 { return !(bHasDefaultValue_ = !convertValue<char                , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
    103         inline bool setValue(const unsigned char& value)        { return !(bHasDefaultValue_ = !convertValue<unsigned char       , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
    104         inline bool setValue(const short& value)                { return !(bHasDefaultValue_ = !convertValue<short               , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
    105         inline bool setValue(const unsigned short& value)       { return !(bHasDefaultValue_ = !convertValue<unsigned short      , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
    106         inline bool setValue(const int& value)                  { return !(bHasDefaultValue_ = !convertValue<int                 , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
    107         inline bool setValue(const unsigned int& value)         { return !(bHasDefaultValue_ = !convertValue<unsigned int        , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
    108         inline bool setValue(const long& value)                 { return !(bHasDefaultValue_ = !convertValue<long                , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
    109         inline bool setValue(const unsigned long& value)        { return !(bHasDefaultValue_ = !convertValue<unsigned long       , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
    110         inline bool setValue(const long long& value)            { return !(bHasDefaultValue_ = !convertValue<long long           , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
    111         inline bool setValue(const unsigned long long& value)   { return !(bHasDefaultValue_ = !convertValue<unsigned long long  , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
    112         inline bool setValue(const float& value)                { return !(bHasDefaultValue_ = !convertValue<float               , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
    113         inline bool setValue(const double& value)               { return !(bHasDefaultValue_ = !convertValue<double              , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
    114         inline bool setValue(const long double& value)          { return !(bHasDefaultValue_ = !convertValue<long double         , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
    115         inline bool setValue(const bool& value)                 { return !(bHasDefaultValue_ = !convertValue<bool                , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
    116         inline bool setValue(      void* const& value)          { return !(bHasDefaultValue_ = !convertValue<void*               , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
    117         inline bool setValue(const std::string& value)          { return !(bHasDefaultValue_ = !convertValue<std::string         , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
    118         inline bool setValue(const orxonox::Vector2& value)     { return !(bHasDefaultValue_ = !convertValue<orxonox::Vector2    , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
    119         inline bool setValue(const orxonox::Vector3& value)     { return !(bHasDefaultValue_ = !convertValue<orxonox::Vector3    , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
    120         inline bool setValue(const orxonox::Vector4& value)     { return !(bHasDefaultValue_ = !convertValue<orxonox::Vector4    , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
    121         inline bool setValue(const orxonox::ColourValue& value) { return !(bHasDefaultValue_ = !convertValue<orxonox::ColourValue, T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
    122         inline bool setValue(const orxonox::Quaternion& value)  { return !(bHasDefaultValue_ = !convertValue<orxonox::Quaternion , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
    123         inline bool setValue(const orxonox::Radian& value)      { return !(bHasDefaultValue_ = !convertValue<orxonox::Radian     , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
    124         inline bool setValue(const orxonox::Degree& value)      { return !(bHasDefaultValue_ = !convertValue<orxonox::Degree     , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
    125 
    126         inline operator char()                 const { return getConvertedValue<T, char>                (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
    127         inline operator unsigned char()        const { return getConvertedValue<T, unsigned char>       (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
    128         inline operator short()                const { return getConvertedValue<T, short>               (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
    129         inline operator unsigned short()       const { return getConvertedValue<T, unsigned short>      (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
    130         inline operator int()                  const { return getConvertedValue<T, int>                 (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
    131         inline operator unsigned int()         const { return getConvertedValue<T, unsigned int>        (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
    132         inline operator long()                 const { return getConvertedValue<T, long>                (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
    133         inline operator unsigned long()        const { return getConvertedValue<T, unsigned long>       (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
    134         inline operator long long()            const { return getConvertedValue<T, long long>           (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
    135         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. */
    136         inline operator float()                const { return getConvertedValue<T, float>               (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
    137         inline operator double()               const { return getConvertedValue<T, double>              (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
    138         inline operator long double()          const { return getConvertedValue<T, long double>         (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
    139         inline operator bool()                 const { return getConvertedValue<T, bool>                (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
    140         inline operator void*()                const { return getConvertedValue<T, void*>               (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
    141         inline operator std::string()          const { return getConvertedValue<T, std::string>         (this->value_, NilValue<std::string         >()); } /** @brief Returns the current value, converted to the requested type. */
    142         inline operator orxonox::Vector2()     const { return getConvertedValue<T, orxonox::Vector2>    (this->value_, NilValue<orxonox::Vector2    >()); } /** @brief Returns the current value, converted to the requested type. */
    143         inline operator orxonox::Vector3()     const { return getConvertedValue<T, orxonox::Vector3>    (this->value_, NilValue<orxonox::Vector3    >()); } /** @brief Returns the current value, converted to the requested type. */
    144         inline operator orxonox::Vector4()     const { return getConvertedValue<T, orxonox::Vector4>    (this->value_, NilValue<orxonox::Vector4    >()); } /** @brief Returns the current value, converted to the requested type. */
    145         inline operator orxonox::ColourValue() const { return getConvertedValue<T, orxonox::ColourValue>(this->value_, NilValue<orxonox::ColourValue>()); } /** @brief Returns the current value, converted to the requested type. */
    146         inline operator orxonox::Quaternion()  const { return getConvertedValue<T, orxonox::Quaternion> (this->value_, NilValue<orxonox::Quaternion >()); } /** @brief Returns the current value, converted to the requested type. */
    147         inline operator orxonox::Radian()      const { return getConvertedValue<T, orxonox::Radian>     (this->value_, NilValue<orxonox::Radian     >()); } /** @brief Returns the current value, converted to the requested type. */
    148         inline operator orxonox::Degree()      const { return getConvertedValue<T, orxonox::Degree>     (this->value_, NilValue<orxonox::Degree     >()); } /** @brief Returns the current value, converted to the requested type. */
    149 
    150         /** @brief Puts the current value on the stream */
     82        inline bool getValue(char*                 value) const { return convertValue<T, char                >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     83        inline bool getValue(unsigned char*        value) const { return convertValue<T, unsigned char       >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     84        inline bool getValue(short*                value) const { return convertValue<T, short               >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     85        inline bool getValue(unsigned short*       value) const { return convertValue<T, unsigned short      >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     86        inline bool getValue(int*                  value) const { return convertValue<T, int                 >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     87        inline bool getValue(unsigned int*         value) const { return convertValue<T, unsigned int        >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     88        inline bool getValue(long*                 value) const { return convertValue<T, long                >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     89        inline bool getValue(unsigned long*        value) const { return convertValue<T, unsigned long       >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     90        inline bool getValue(long long*            value) const { return convertValue<T, long long           >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     91        inline bool getValue(unsigned long long*   value) const { return convertValue<T, unsigned long long  >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     92        inline bool getValue(float*                value) const { return convertValue<T, float               >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     93        inline bool getValue(double*               value) const { return convertValue<T, double              >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     94        inline bool getValue(long double*          value) const { return convertValue<T, long double         >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     95        inline bool getValue(bool*                 value) const { return convertValue<T, bool                >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     96        inline bool getValue(void**                value) const { return convertValue<T, void*               >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     97        inline bool getValue(std::string*          value) const { return convertValue<T, std::string         >(value, value_, zeroise<std::string>         ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     98        inline bool getValue(orxonox::Vector2*     value) const { return convertValue<T, orxonox::Vector2    >(value, value_, zeroise<orxonox::Vector2>    ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     99        inline bool getValue(orxonox::Vector3*     value) const { return convertValue<T, orxonox::Vector3    >(value, value_, zeroise<orxonox::Vector3>    ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     100        inline bool getValue(orxonox::Vector4*     value) const { return convertValue<T, orxonox::Vector4    >(value, value_, zeroise<orxonox::Vector4>    ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     101        inline bool getValue(orxonox::ColourValue* value) const { return convertValue<T, orxonox::ColourValue>(value, value_, zeroise<orxonox::ColourValue>()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     102        inline bool getValue(orxonox::Quaternion*  value) const { return convertValue<T, orxonox::Quaternion >(value, value_, zeroise<orxonox::Quaternion> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     103        inline bool getValue(orxonox::Radian*      value) const { return convertValue<T, orxonox::Radian     >(value, value_, zeroise<orxonox::Radian>     ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     104        inline bool getValue(orxonox::Degree*      value) const { return convertValue<T, orxonox::Degree     >(value, value_, zeroise<orxonox::Degree>     ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     105
     106        inline bool setValue(const char& value)                 { return !(bHasDefaultValue_ = !convertValue<char                , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
     107        inline bool setValue(const unsigned char& value)        { return !(bHasDefaultValue_ = !convertValue<unsigned char       , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
     108        inline bool setValue(const short& value)                { return !(bHasDefaultValue_ = !convertValue<short               , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
     109        inline bool setValue(const unsigned short& value)       { return !(bHasDefaultValue_ = !convertValue<unsigned short      , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
     110        inline bool setValue(const int& value)                  { return !(bHasDefaultValue_ = !convertValue<int                 , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
     111        inline bool setValue(const unsigned int& value)         { return !(bHasDefaultValue_ = !convertValue<unsigned int        , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
     112        inline bool setValue(const long& value)                 { return !(bHasDefaultValue_ = !convertValue<long                , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
     113        inline bool setValue(const unsigned long& value)        { return !(bHasDefaultValue_ = !convertValue<unsigned long       , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
     114        inline bool setValue(const long long& value)            { return !(bHasDefaultValue_ = !convertValue<long long           , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
     115        inline bool setValue(const unsigned long long& value)   { return !(bHasDefaultValue_ = !convertValue<unsigned long long  , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
     116        inline bool setValue(const float& value)                { return !(bHasDefaultValue_ = !convertValue<float               , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
     117        inline bool setValue(const double& value)               { return !(bHasDefaultValue_ = !convertValue<double              , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
     118        inline bool setValue(const long double& value)          { return !(bHasDefaultValue_ = !convertValue<long double         , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
     119        inline bool setValue(const bool& value)                 { return !(bHasDefaultValue_ = !convertValue<bool                , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
     120        inline bool setValue(      void* const& value)          { return !(bHasDefaultValue_ = !convertValue<void*               , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
     121        inline bool setValue(const std::string& value)          { return !(bHasDefaultValue_ = !convertValue<std::string         , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
     122        inline bool setValue(const orxonox::Vector2& value)     { return !(bHasDefaultValue_ = !convertValue<orxonox::Vector2    , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
     123        inline bool setValue(const orxonox::Vector3& value)     { return !(bHasDefaultValue_ = !convertValue<orxonox::Vector3    , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
     124        inline bool setValue(const orxonox::Vector4& value)     { return !(bHasDefaultValue_ = !convertValue<orxonox::Vector4    , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
     125        inline bool setValue(const orxonox::ColourValue& value) { return !(bHasDefaultValue_ = !convertValue<orxonox::ColourValue, T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
     126        inline bool setValue(const orxonox::Quaternion& value)  { return !(bHasDefaultValue_ = !convertValue<orxonox::Quaternion , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
     127        inline bool setValue(const orxonox::Radian& value)      { return !(bHasDefaultValue_ = !convertValue<orxonox::Radian     , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
     128        inline bool setValue(const orxonox::Degree& value)      { return !(bHasDefaultValue_ = !convertValue<orxonox::Degree     , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
     129
     130        inline operator char()                 const { return getConvertedValue<T, char>                (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
     131        inline operator unsigned char()        const { return getConvertedValue<T, unsigned char>       (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
     132        inline operator short()                const { return getConvertedValue<T, short>               (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
     133        inline operator unsigned short()       const { return getConvertedValue<T, unsigned short>      (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
     134        inline operator int()                  const { return getConvertedValue<T, int>                 (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
     135        inline operator unsigned int()         const { return getConvertedValue<T, unsigned int>        (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
     136        inline operator long()                 const { return getConvertedValue<T, long>                (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
     137        inline operator unsigned long()        const { return getConvertedValue<T, unsigned long>       (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
     138        inline operator long long()            const { return getConvertedValue<T, long long>           (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
     139        inline operator unsigned long long()   const { return getConvertedValue<T, unsigned long long>  (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
     140        inline operator float()                const { return getConvertedValue<T, float>               (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
     141        inline operator double()               const { return getConvertedValue<T, double>              (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
     142        inline operator long double()          const { return getConvertedValue<T, long double>         (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
     143        inline operator bool()                 const { return getConvertedValue<T, bool>                (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
     144        inline operator void*()                const { return getConvertedValue<T, void*>               (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
     145        inline operator std::string()          const { return getConvertedValue<T, std::string>         (this->value_, NilValue<std::string         >()); } ///< Returns the current value, converted to the requested type.
     146        inline operator orxonox::Vector2()     const { return getConvertedValue<T, orxonox::Vector2>    (this->value_, NilValue<orxonox::Vector2    >()); } ///< Returns the current value, converted to the requested type.
     147        inline operator orxonox::Vector3()     const { return getConvertedValue<T, orxonox::Vector3>    (this->value_, NilValue<orxonox::Vector3    >()); } ///< Returns the current value, converted to the requested type.
     148        inline operator orxonox::Vector4()     const { return getConvertedValue<T, orxonox::Vector4>    (this->value_, NilValue<orxonox::Vector4    >()); } ///< Returns the current value, converted to the requested type.
     149        inline operator orxonox::ColourValue() const { return getConvertedValue<T, orxonox::ColourValue>(this->value_, NilValue<orxonox::ColourValue>()); } ///< Returns the current value, converted to the requested type.
     150        inline operator orxonox::Quaternion()  const { return getConvertedValue<T, orxonox::Quaternion> (this->value_, NilValue<orxonox::Quaternion >()); } ///< Returns the current value, converted to the requested type.
     151        inline operator orxonox::Radian()      const { return getConvertedValue<T, orxonox::Radian>     (this->value_, NilValue<orxonox::Radian     >()); } ///< Returns the current value, converted to the requested type.
     152        inline operator orxonox::Degree()      const { return getConvertedValue<T, orxonox::Degree>     (this->value_, NilValue<orxonox::Degree     >()); } ///< Returns the current value, converted to the requested type.
     153
     154        /// Puts the current value on the stream
    151155        inline void toString(std::ostream& outstream) const { outstream << this->value_; }
    152156
    153         /** @brief loads data from the bytestream (mem) into the MT and increases the bytestream pointer by the size of the data */
     157        /// loads data from the bytestream (mem) into the MT and increases the bytestream pointer by the size of the data
    154158        inline void importData( uint8_t*& mem )         { loadAndIncrease( /*(const T&)*/this->value_, mem ); }
    155         /** @brief saves data from the MT into the bytestream (mem) and increases the bytestream pointer by the size of the data */
     159        /// saves data from the MT into the bytestream (mem) and increases the bytestream pointer by the size of the data
    156160        inline void exportData( uint8_t*& mem ) const   { saveAndIncrease( /*(const T&)*/this->value_, mem ); }
    157         /** @brief returns the size of the data that would be saved by exportData */
     161        /// returns the size of the data that would be saved by exportData
    158162        inline uint8_t getSize() const { return returnSize( this->value_ ); }
    159163
    160         T value_; //!< The stored value
     164        T value_; ///< The stored value
    161165    };
    162166
  • code/trunk/src/libraries/util/OrxAssert.h

    r6105 r7401  
    2929/**
    3030@file
     31@ingroup ExceptionAssertion
    3132@brief
    3233    Declaration of custom assertion facilities
     
    4142#include "OutputHandler.h"
    4243
    43 // define an assert macro that can display a message
    4444#ifndef NDEBUG
     45/** Run time assertion like assert(), but with an embedded message.
     46@details
     47    The message will be printed as error with COUT(1). <br>
     48    You can use the same magic here as you can with \ref ThrowException
     49    @code
     50        OrxAssert(condition, "Text: " << number << " more text");
     51    @endcode
     52*/
    4553#define OrxAssert(Assertion, ErrorMessage) \
    4654    Assertion ? ((void)0) : (void)(orxonox::OutputHandler::getOutStream(1) << ErrorMessage << std::endl); \
  • code/trunk/src/libraries/util/OrxEnum.h

    r5738 r7401  
    2828
    2929/**
    30 @file
    31 @brief
    32     Declaration of the OrxEnum class.
     30    @file
     31    @ingroup Util
    3332*/
    3433
     
    4039namespace orxonox
    4140{
     41    /** Lightweight enumeration class that can be extended at run time.
     42    @details
     43        The class accepts type int and also defines operator int(). Therefore
     44        int and OrxEnum can be used interchangeably so you can extend the content
     45        of the enumeration at run time by adding ints.
     46    @par Declaring an OrxEnum
     47        Write a struct that inherits OrxEnum and use some macros:
     48        @code
     49        struct MyEnum : OrxEnum<MyEnum>
     50        {
     51            OrxEnumConstructors(MyEnum);
     52
     53            static const int Value1 = -1;
     54            static const int Value2 = 0;
     55            static const int Value3 = Value2 + 10;
     56        };
     57        @endcode
     58    */
    4259    template <class T>
    4360    struct OrxEnum
     
    4562        public:
    4663            OrxEnum() { }
    47             OrxEnum(int type)                  { type_ = type; }
     64            OrxEnum(int type)            { type_ = type; }
    4865            OrxEnum(const T& instance)   { type_ = instance.type_; }
    4966
    50             operator int()                     { return type_; }
     67            operator int()               { return type_; }
    5168            T& operator =(int type)      { type_ = type; return *this; }
    5269            bool operator <(const T& right) const { return (type_ < right.type_); }
     
    5976}
    6077
     78/// See orxonox::OrxEnum for more info
    6179#define OrxEnumConstructors(enumName)                        \
    6280enumName() { }                                               \
  • code/trunk/src/libraries/util/OutputHandler.cc

    r6417 r7401  
    6767        @brief
    6868            Gets temporary log path and starts the log file
    69         @param outputHandler
    70             This is only required to avoid another call to getInstance (this c'tor was
    71             called from getInstance!)
    7269        */
    7370        LogFileWriter()
     
    117114
    118115    private:
    119         std::ofstream logFile_;     //! File handle for the log file
    120         std::string   logFilename_; //! Filename of the log file
     116        std::ofstream logFile_;     //!< File handle for the log file
     117        std::string   logFilename_; //!< Filename of the log file
    121118    };
    122119
     
    162159        @brief
    163160            Sets the right soft debug level and registers itself
    164         @param outputHandler
    165             This is only required to avoid another call to getInstance (this c'tor was
    166             called from getInstance!)
    167161        */
    168162        MemoryLogWriter()
     
    186180
    187181    private:
    188         std::ostringstream                        buffer_; //! Stream object used to process the output
    189         std::vector<std::pair<int, std::string> > output_; //! Vector containing ALL output
     182        std::ostringstream                        buffer_; //!< Stream object used to process the output
     183        std::vector<std::pair<int, std::string> > output_; //!< Vector containing ALL output
    190184    };
    191185
  • code/trunk/src/libraries/util/OutputHandler.h

    r7284 r7401  
    2929/**
    3030@file
     31@ingroup Util Output
    3132@brief
    32     Declaration of classes related to output (logging).
     33    Declaration of classes related to output (logging), most notably OutputHandler and OutputListener.
    3334*/
    3435
     
    5051        Denotes different levels of text output (log output)
    5152
    52         0, None   : Very important output
    53         1, Error  : Errors
    54         2, Warning: Warnings
    55         3, Info   : Information
    56         4, Debug  : Debug information
    57         5, Verbose: More debug information
    58         6, Ultra  : Crazy debug information
     53         - 0, None   : Very important output
     54         - 1, Error  : Errors
     55         - 2, Warning: Warnings
     56         - 3, Info   : Information
     57         - 4, Debug  : Debug information
     58         - 5, Verbose: More debug information
     59         - 6, Ultra  : Crazy debug information
    5960    */
    6061    namespace OutputLevel
     
    7980    /**
    8081    @brief
    81         The OutputHandler acts like std::cout, but output isn't only shown in the console.
    82 
    83         You can register your own listener for output by inheriting from OutputListner.
     82        The OutputHandler acts like @c std::cout, but output isn't only shown in the console.
     83
     84        Output passed to the OutputHandler is distributed to all registered listeners,
     85        for example the console, the logfile, or the ingame shell.
     86
     87        You can register your own listener for output by inheriting from OutputListener.
    8488        And if you need the output previously processed, iterate over it with
    85         OutputHandler::getOutputVector[Begin/End].
     89        OutputHandler::getOutputVectorBegin and OutputHandler::getOutputVectorEnd.
     90
    8691        The way to output text is to first set the desired output level with
    87         OutputHandler::getOutStream(level) and then use the "<<" operator like with std::cout.
     92        @ref getOutStream "OutputHandler::getOutStream(level)" and then use
     93        the "<<" operator like with @c std::cout. Alternatively you can use the COUT() macro.
    8894    */
    8995    class _UtilExport OutputHandler
     
    213219            OutputHandler();
    214220            ~OutputHandler();
    215             OutputHandler(const OutputHandler& rhs); //! Unused and undefined
     221            OutputHandler(const OutputHandler& rhs);      //!< Copy-constructor: Unused and undefined
    216222
    217223            std::list<OutputListener*> listeners_;        //!< Array with all registered output listeners
  • code/trunk/src/libraries/util/Scope.cc

    r5738 r7401  
    2727 */
    2828
     29/**
     30    @file
     31    @brief Static linkage of the two maps in orxonox::ScopeManager.
     32*/
     33
    2934#include "Scope.h"
    3035
  • code/trunk/src/libraries/util/Scope.h

    r7266 r7401  
    2727 */
    2828
     29/**
     30@file
     31@ingroup SingletonScope
     32@brief Declaration of the classes that are needed to use Scopes:
     33orxonox::Scope, orxonox::ScopeListener, and orxonox::ScopeManager.
     34
     35@anchor Scope
     36
     37A virtual scope can be represented by an instance of class orxonox::Scope. orxonox::Scope<@a scope> is a template
     38an its template argument defines the name of the virtual scope. See orxonox::ScopeID for an enumeration of the
     39available values for @a scope. The orxonox::Scope object for a given @a scope can be activated or deactivated.
     40Instances of orxonox::ScopeListener can register for a given @a scope and will get a notification if the
     41corresponding orxonox::Scope object changes its state.
     42
     43To avoid multiple instances of orxonox::Scope<@a scope> in different libraries, each instance of orxonox::Scope
     44registers in orxonox::ScopeManager, where they are linked statically in the util library.
     45
     46Scopes are usually used to control the creation and destruction of Singletons.
     47
     48@see orxonox::ScopedSingletonManager
     49@see orxonox::Singleton
     50*/
     51
    2952#ifndef __Util_Scope_H__
    3053#define __Util_Scope_H__
     
    4265{
    4366    /**
    44         @brief The ScopeManager stores the variables of the scope templates in a statically linked context.
     67        @brief The ScopeManager stores the variables of the Scope templates in a statically linked context.
     68
     69        If all Scope objects are managed by this class, they are statically linked in the util library.
     70        Without this, a new instance of Scope<T> for each T would be created in every library of Orxonox,
     71        which is of course not the desired behavior.
     72
     73        @see See @ref Scope "this description" for details about the interrelationship of Scope, ScopeListener, and ScopeManager.
    4574    */
    4675    class _UtilExport ScopeManager
     
    5685
    5786    /**
    58         @brief ScopeListeners register themselves in the corresponding scope and wait for notifications.
     87        @brief ScopeListeners register themselves in the corresponding Scope and wait for notifications.
     88        Notifications are sent if a Scope is activated or deactivated.
     89
     90        @see See @ref Scope "this description" for details about the interrelationship of Scope, ScopeListener, and ScopeManager.
    5991    */
    6092    class _UtilExport ScopeListener
     
    86118        Objects inheriting from a ScopeListener are registered in a list (different for each scope).
    87119        If the scope gets activated or deactivated, all objects in this list are notified.
     120
     121        @see See @ref Scope "this description" for details about the interrelationship of Scope, ScopeListener, and ScopeManager.
    88122    */
    89123    template <ScopeID::Value scope>
     
    130164            }
    131165
     166            //! Deactivates the listeners of this scope in case the scope is destroyed or the construction fails.
    132167            void deactivateListeners()
    133168            {
  • code/trunk/src/libraries/util/ScopedSingletonManager.cc

    r7284 r7401  
    2727 */
    2828
     29/**
     30    @file
     31    @brief Static linkage of the ScopedSingletonManager maps.
     32*/
     33
    2934#include "ScopedSingletonManager.h"
    3035
  • code/trunk/src/libraries/util/ScopedSingletonManager.h

    r7284 r7401  
    2626 *
    2727 */
     28
     29/**
     30    @file
     31    @ingroup SingletonScope
     32    @brief Definition of orxonox::ScopedSingletonManager, orxonox::ClassScopedSingletonManager, and the ManageScopedSingleton macro.
     33
     34    ScopedSingletonManager is used to create and destroy Singletons that belong to
     35    a given Scope. For each one of these singletons, the macro ManageScopedSingleton()
     36    has to be called to register the singleton with orxonox::ScopedSingletonManager.
     37
     38    See @ref SingletonExample "this code" for an example.
     39
     40    @see orxonox::Singleton
     41    @see orxonox::Scope
     42*/
    2843
    2944#ifndef __ScopedSingletonManager_H__
     
    3853#include "util/Singleton.h"
    3954
     55/**
     56    @brief Registers an orxonox::Singleton with orxonox::ScopedSingletonManager.
     57    @param className The name of the singleton class
     58    @param scope The scope in which the singleton should exist
     59    @param allowedToFail If true, the singleton is allowed to fail and thus a try-catch block is used when creating the singleton.
     60
     61    If this macro is called for a singleton, it is registered with ScopedSingletonManager
     62    and will thus be created if its scope becomes active and destroyed if is deactivated.
     63*/
    4064#define ManageScopedSingleton(className, scope, allowedToFail) \
    4165    className* className::singletonPtr_s = NULL; \
     
    4670    class OrxonoxClass;
    4771
     72    /**
     73        @brief Base class of ClassScopedSingletonManager, implements some static functions
     74        used to dispatch calls to preUpdate and postUpdate to all instances of this class.
     75        It also keeps track of all existing ScopedSingletonManagers and stores them in a
     76        map, sorted by the scope they belong to.
     77    */
    4878    class _UtilExport ScopedSingletonManager
    4979    {
    5080        public:
     81            /// Constructor: Initializes all the values
    5182            ScopedSingletonManager(const std::string& className, ScopeID::Value scope)
    5283                : className_(className)
     
    5485            { }
    5586            virtual ~ScopedSingletonManager() { }
     87
     88            /// Adds a new instance of ScopedSingletonManager to the map.
    5689            static void addManager(ScopedSingletonManager* manager);
    5790
     91            /// Calls preUpdate in all instances of ScopedSingletonManager that are registered in the map.
    5892            template<ScopeID::Value scope>
    5993            static void preUpdate(const Clock& time)
     
    6498            }
    6599            virtual void preUpdate(const Clock& time) = 0;
     100
     101            /// Calls postUpdate in all instances of ScopedSingletonManager that are registered in the map.
    66102            template<ScopeID::Value scope>
    67103            static void postUpdate(const Clock& time)
     
    78114
    79115        protected:
    80             const std::string className_;
    81             const ScopeID::Value scope_;
     116            const std::string className_;   ///< The name of the scoped singleton class that is managed by this object
     117            const ScopeID::Value scope_;    ///< The scope of the singleton that is managed by this object
    82118    };
    83119
     120    /**
     121        @anchor ClassScopedSingletonManager
     122
     123        @brief Manages a scoped singleton for a given scope.
     124        @param T The managed singleton class
     125        @param scope The scope in which the singleton @a T should be active
     126        @param allowedToFail If true, a specialization of this template is used, that uses try-catch blocks to handle possible failures.
     127
     128        This class inherits from ScopeListener for the given scope and thus its functions
     129        activated() and deactivated() are called whenever the Scope changes its state.
     130
     131        If the Scope is activated, a new instance of @a T (which must be a singleton) is created.
     132        If the Scope is deactivated, the singleton is destroyed.
     133
     134        @see Singleton
     135    */
    84136    template <class T, ScopeID::Value scope, bool allowedToFail>
    85137    class ClassScopedSingletonManager : public ScopedSingletonManager, public ScopeListener
    86138    {
    87139    public:
     140        //! Constructor: Initializes the singleton pointer and passes the scope to ScopedSingletonManager and ScopeListener
    88141        ClassScopedSingletonManager(const std::string& className)
    89142            : ScopedSingletonManager(className, scope)
     
    113166        }
    114167
     168        //! Destroys the singleton instance - overloaded for OrxonoxClass, calls OrxonoxClass::destroy()
    115169        void destroy(OrxonoxClass*)
    116170        {
    117171            singletonPtr_->destroy();
    118172        }
     173        //! Destroys the singleton instance - overloaded for all other pointers, calls delete
    119174        void destroy(void*)
    120175        {
     
    139194
    140195    private:
    141         T* singletonPtr_;
     196        T* singletonPtr_;   ///< Unique instance of the singleton class @a T
    142197    };
    143198
     199    /**
     200        @brief This class partially spezializes ClassScopedSingletonManager for classes @a T that are allowed to fail.
     201        @param T The managed singleton class
     202        @param scope The scope in which the singleton @a T should be active
     203
     204        Because @a T could fail when being created, this partial spezialization of ClassScopedSingletonManager
     205        uses a try-catch block to handle exceptions.
     206
     207        See @ref ClassScopedSingletonManager for a full documentation of the basis template.
     208    */
    144209    template <class T, ScopeID::Value scope>
    145210    class ClassScopedSingletonManager<T, scope, true> : public ScopedSingletonManager, public ScopeListener
    146211    {
    147212    public:
     213        //! Constructor: Initializes the singleton pointer and passes the scope to ScopedSingletonManager and ScopeListener
    148214        ClassScopedSingletonManager(const std::string& className)
    149215            : ScopedSingletonManager(className, scope)
     
    180246        }
    181247
     248        //! Destroys the singleton instance - overloaded for OrxonoxClass, calls OrxonoxClass::destroy()
    182249        void destroy(OrxonoxClass* ptr)
    183250        {
    184251            singletonPtr_->destroy();
    185252        }
     253        //! Destroys the singleton instance - overloaded for void*, calls delete
    186254        void destroy(void* ptr)
    187255        {
     
    208276
    209277    private:
    210         T* singletonPtr_;
     278        T* singletonPtr_;   ///< Unique instance of the singleton class @a T
    211279    };
    212280}
  • code/trunk/src/libraries/util/Serialise.h

    r7182 r7401  
    2929/**
    3030    @file
     31    @ingroup Util
    3132    @brief Functions to serialise most of the types/classed used in Orxonox
    3233*/
     
    5354    template <class T> inline bool checkEquality( const T& variable, uint8_t* mem );
    5455
    55  
     56
    5657  // =========== char*
    57    
     58
    5859  inline uint32_t returnSize( char*& variable )
    5960  {
    6061    return strlen(variable)+1;
    6162  }
    62      
     63
    6364  inline void saveAndIncrease( char*& variable, uint8_t*& mem )
    6465  {
     
    6667    mem += returnSize(variable);
    6768  }
    68        
     69
    6970  inline void loadAndIncrease( char*& variable, uint8_t*& mem )
    7071  {
     
    7677    mem += len;
    7778  }
    78          
     79
    7980  inline bool checkEquality( char*& variable, uint8_t* mem )
    8081  {
    8182    return strcmp(variable, (char*)mem)==0;
    8283  }
    83    
     84
    8485// =================== Template specialisation stuff =============
    8586
     
    423424        return memcmp(&temp, mem, sizeof(uint64_t))==0;
    424425    }
    425        
     426
    426427// =========== string
    427428
  • code/trunk/src/libraries/util/SharedPtr.cc

    r7284 r7401  
    2727 */
    2828
     29/**
     30    @file
     31    @brief Static linkage of the SmallObjectAllocator used by SharedPtr.
     32*/
     33
    2934#include "SharedPtr.h"
    3035
    3136namespace orxonox
    3237{
    33     SmallObjectAllocator& createSharedCounterPool()
     38    namespace detail
    3439    {
    35         static SmallObjectAllocator instance(sizeof(SharedCounterImpl<void>));
    36         return instance;
     40        SmallObjectAllocator& createSharedCounterPool()
     41        {
     42            static SmallObjectAllocator instance(sizeof(SharedCounterImpl<void>));
     43            return instance;
     44        }
    3745    }
    3846}
  • code/trunk/src/libraries/util/SharedPtr.h

    r7284 r7401  
    2727 */
    2828
     29/**
     30    @defgroup SharedPtr SharedPtr<T>
     31    @ingroup Util
     32*/
     33
     34/**
     35    @file
     36    @ingroup SharedPtr
     37    @brief Definition of the SharedPtr template that is used to manage pointers.
     38
     39    @anchor SharedPtrExample
     40
     41    The orxonox::SharedPtr template can be used to manage a pointer to an object
     42    that was created with new. The SharedPtr acts like the pointer itself, but it
     43    keeps track of the number of references to it. If all references are removed,
     44    SharedPtr deletes the managed object automatically.
     45
     46    Example:
     47
     48    Classic implementation using new and delete:
     49    @code
     50    void someFunction()
     51    {
     52        MyClass* object = new MyClass();            // Create a new instance of MyClass
     53
     54        object->myFunction();                       // Calls MyClass::myFunction()
     55
     56        delete object;                              // Delete the object at the end of the scope
     57    }
     58    @endcode
     59
     60    The same function using SharedPtr:
     61    @code
     62    void someFunction()
     63    {
     64        SharedPtr<MyClass> object = new MyClass();  // Create a new instance of MyClass and store its pointer in a SharedPtr
     65
     66        object->myFunction();                       // Calls MyClass::myFunction()
     67
     68    }                                               // At the end of the scope, the SharedPtr is destroyed. Because no other SharedPtrs
     69                                                    // point at the object, the object itself is also destroyed automatically
     70    @endcode
     71
     72    This is especially handy if you do not know what will happen with an object that was
     73    created with new, for example if you pass it to another object. If multiple instances
     74    share a pointer to the same object, none of these instances can delete the object
     75    without interfering with the other instances. But if none of the instances destroy the
     76    object, it will never be destroyed and results in a memory leak. With a SharedPtr
     77    however you don't have to think about destroying the object, because the SharedPtr
     78    itself keeps track of the references.
     79
     80    Example:
     81
     82    Classic implementation using new and delete:
     83    @code
     84    class OtherClass                                    // Declaration of some class
     85    {
     86        public:
     87            OtherClass(MyClass* object)                 // Constructor
     88            {
     89                this->object_ = object;                 // Assigns the pointer to the member variable object_
     90            }
     91
     92            ~OtherClass()                               // Destructor
     93            {
     94                ???                                     // What to do with object_?
     95            }
     96
     97        private:
     98            MyClass* object_;                           // A pointer to the object
     99    };
     100
     101    void someFunction()
     102    {
     103        MyClass* object = new MyClass();                // Create a new instance of MyClass
     104
     105        OtherClass* other1 = new OtherClass(object);    // Create an instance of OtherClass and pass the object pointer
     106        OtherClass* other2 = new OtherClass(object);    // "
     107        OtherClass* other3 = new OtherClass(object);    // "
     108
     109        ???                                             // What happens with object now?
     110    }
     111    @endcode
     112
     113    If you use SharedPtr<MyClass> instead of a classic MyClass* pointer, the instance of
     114    MyClass would be automatically destroyed if all instances of OtherClass are destroyed.
     115    You don't need any code in the destructor and you can completely forget about the
     116    object, because its managed by the SharedPtr.
     117
     118    The same code using SharedPtr:
     119    @code
     120    class OtherClass                                        // Declaration of some class
     121    {
     122        public:
     123            OtherClass(const SharedPtr<MyClass>& object)    // Constructor
     124            {
     125                this->object_ = object;                     // Assigns the pointer to the member variable object_
     126            }
     127
     128        private:
     129            SharedPtr<MyClass> object_;                     // A SharedPtr to the object
     130    };
     131
     132    void someFunction()
     133    {
     134        SharedPtr<MyClass> object = new MyClass();          // Create a new instance of MyClass
     135
     136        OtherClass* other1 = new OtherClass(object);        // Create an instance of OtherClass and pass the object pointer
     137        OtherClass* other2 = new OtherClass(object);        // "
     138        OtherClass* other3 = new OtherClass(object);        // "
     139
     140    }                                                       // The SmartPtr "object" is destroyed at the end of the scope,
     141                                                            // but the three instances of OtherClass keep the object alive
     142                                                            // until they are all destroyed.
     143    @endcode
     144*/
     145
    29146#ifndef _SharedPtr_H__
    30147#define _SharedPtr_H__
     
    39156namespace orxonox
    40157{
    41     class SharedCounter
    42     {
    43         public:
    44             SharedCounter() : count_(1) {}
    45             virtual void destroy() = 0;
    46 
    47             int count_;
    48     };
    49 
    50     template <class T>
    51     class SharedCounterImpl : public SharedCounter
    52     {
    53         public:
    54             SharedCounterImpl(T* pointer) : pointer_(pointer) {}
    55 
    56             void destroy()
    57             {
    58                 delete this->pointer_;
    59             }
    60 
    61         private:
    62             T* pointer_;
    63     };
    64 
    65     _UtilExport SmallObjectAllocator& createSharedCounterPool();
    66 
    67     FORCEINLINE SmallObjectAllocator& getSharedCounterPool()
    68     {
    69         static SmallObjectAllocator& instance = createSharedCounterPool();
    70         return instance;
     158    namespace detail
     159    {
     160        /// BaseClass of SharedCounterImpl, has a counter that is initialized with 1
     161        class SharedCounter
     162        {
     163            public:
     164                SharedCounter() : count_(1) {}
     165                virtual void destroy() = 0;
     166
     167                int count_;
     168        };
     169
     170        /// Child class of SharedCounter, keeps a pointer to an object of type T that can be destroyed with destroy()
     171        template <class T>
     172        class SharedCounterImpl : public SharedCounter
     173        {
     174            public:
     175                SharedCounterImpl(T* pointer) : pointer_(pointer) {}
     176
     177                void destroy()
     178                {
     179                    delete this->pointer_;
     180                }
     181
     182            private:
     183                T* pointer_;
     184        };
     185
     186        _UtilExport SmallObjectAllocator& createSharedCounterPool();
     187
     188        FORCEINLINE SmallObjectAllocator& getSharedCounterPool()
     189        {
     190            static SmallObjectAllocator& instance = createSharedCounterPool();
     191            return instance;
     192        }
    71193    }
    72194
     195    /**
     196        @brief The SharedPtr template is a utility to manage pointers to an object.
     197        @param T The type of the managed object
     198
     199        SharedPtr acts like a real pointer, except that it keeps track of the number of
     200        references to the object. If the the number of references drops to zero, the
     201        object is destroyed automatically.
     202
     203        @see See @ref SharedPtrExample "this description" for some examples and more information.
     204
     205        @note The number of references is stored in a separate object that is shared
     206        among all instances of SharedPtr that point to the same pointer. This object is
     207        also responsible for destroying the pointer if the reference counter becomes zero.
     208    */
    73209    template <class T>
    74210    class SharedPtr
     
    78214
    79215        public:
     216            /// Default constructor, the pointer is set to NULL.
    80217            inline SharedPtr() : pointer_(0), counter_(0)
    81218            {
    82219            }
    83220
     221            /// Constructor, creates a SharedPtr that points to @a pointer, increments the counter.
    84222            inline SharedPtr(T* pointer) : pointer_(pointer), counter_(0)
    85223            {
    86224                if (this->pointer_)
    87225                {
    88                     void* chunk = getSharedCounterPool().alloc();
    89                     this->counter_ = new (chunk) SharedCounterImpl<T>(this->pointer_);
     226                    void* chunk = detail::getSharedCounterPool().alloc();
     227                    this->counter_ = new (chunk) detail::SharedCounterImpl<T>(this->pointer_);
    90228                }
    91229            }
    92230
     231            /// Copy-constructor, this SharedPtr now points to the same object like the other SharedPtr, increments the counter.
    93232            inline SharedPtr(const SharedPtr& other) : pointer_(other.pointer_), counter_(other.counter_)
    94233            {
     
    97236            }
    98237
     238            /// Copy-constructor for SharedPtr with another template agument, increments the counter.
    99239            template <class O>
    100240            inline SharedPtr(const SharedPtr<O>& other) : pointer_(other.pointer_), counter_(other.counter_)
     
    104244            }
    105245
     246            /// Destructor, decrements the counter and deletes the object if the counter becomes zero.
    106247            inline ~SharedPtr()
    107248            {
     
    113254                    {
    114255                        this->counter_->destroy();
    115                         getSharedCounterPool().free(this->counter_);
     256                        detail::getSharedCounterPool().free(this->counter_);
    116257                    }
    117258                }
    118259            }
    119260
     261            /// Assigns a new object, decrements the counter of the old object, increments the counter of the new object.
    120262            inline SharedPtr& operator=(const SharedPtr& other)
    121263            {
     
    124266            }
    125267
     268            /// Assigns a new object with another template argument, decrements the counter of the old object, increments the counter of the new object.
    126269            template <class O>
    127270            inline SharedPtr& operator=(const SharedPtr<O>& other)
     
    131274            }
    132275
     276            /// Casts the pointer to another type
    133277            template <class O>
    134278            inline SharedPtr<O> cast() const
     
    138282            }
    139283
     284            /// Overloaded -> operator, returns the pointer to the managed object.
    140285            inline T* operator->() const
    141286            {
     
    144289            }
    145290
     291            /// Overloaded * operator, returns a reference ot the managed object.
    146292            inline T& operator*() const
    147293            {
     
    150296            }
    151297
     298            /// Returns the pointer to the managed object.
    152299            inline T* get() const
    153300            {
     
    155302            }
    156303
     304            /// Returns true if the pointer is not NULL.
    157305            inline operator bool() const
    158306            {
     
    160308            }
    161309
     310            /// Swaps the pointer and the counter of two instances of SharedPtr with the same template argument.
    162311            inline void swap(SharedPtr& other)
    163312            {
     
    167316
    168317        private:
    169             inline SharedPtr(T* pointer, SharedCounter* counter) : pointer_(pointer), counter_(counter)
     318            /// Private constructor, used by the cast() function.
     319            inline SharedPtr(T* pointer, detail::SharedCounter* counter) : pointer_(pointer), counter_(counter)
    170320            {
    171321                if (this->pointer_)
     
    173323            }
    174324
    175             T* pointer_;
    176             SharedCounter* counter_;
     325            T* pointer_;                        ///< A pointer to the managed object of type @a T
     326            detail::SharedCounter* counter_;    ///< A pointer to the shared reference counter
    177327    };
    178328
     329    /**
     330        @brief A child class of SharedPtr, used to reflect the hierarchy of the underlying class @a T.
     331        @param T The type of the managed object
     332        @param Parent The type of the SharedPtr that manages the parent class of @a T
     333
     334        This class is used to reflect the hierarchy of the underlying class @a T.
     335        For example the @c Functor classes: While a @c Functor* pointer would be managed by
     336        @c SharedPtr<Functor>, the child class @c FunctorStatic is managed by the class
     337        <tt>SharedChildPtr<FunctorStatic, SharedPtr<Functor> ></tt>.
     338
     339        The second template argument @a Parent is used as the parent class of
     340        SharedChildPtr. This means that each instance of <tt>SharedChildPtr<T, Parent></tt>
     341        can be upcasted to @c Parent.
     342
     343        So for example this works:
     344        @code
     345        SharedChildPtr<FunctorStatic, SharedPtr<Functor> > functorStatic = createFunctor(&MyClass::myStaticFunction);
     346        SharedPtr<Functor> functor = functorStatic;
     347        @endcode
     348
     349        @note There are some typedefs and more to make the usage of SharedChildPtr easier
     350        for the classes Functor and Executor. See FunctorPtr.h and ExecutorPtr.h. The above
     351        example could thus be simplified the following way:
     352        @code
     353        FunctorStaticPtr functorStatic = createFunctor(&MyClass::myStaticFunction);
     354        FunctorPtr functor = functorStatic;
     355        @endcode
     356
     357        @see See SharedPtr for more information about the base class SharedPtr.
     358        @see See @ref SharedPtrExample "this description" for some examples about how to use SharedPtr.
     359    */
    179360    template <class T, class Parent>
    180361    class SharedChildPtr : public Parent
  • code/trunk/src/libraries/util/SignalHandler.h

    r5738 r7401  
    2929/**
    3030    @file
     31    @ingroup Util
    3132    @brief Declaration of the SignalHandler class.
    3233*/
     
    6869    typedef std::list<SignalCallbackRec> SignalCallbackList;
    6970
     71    /// The SignalHandler is used to catch signals like SIGSEGV and write a backtrace to the logfile.
    7072    class SignalHandler : public Singleton<SignalHandler>
    7173    {
     
    99101namespace orxonox
    100102{
     103    /// The SignalHandler is used to catch signals like SIGSEGV and write a backtrace to the logfile. Not implemented on Windows.
    101104    class _UtilExport SignalHandler : public Singleton<SignalHandler>
    102105    {
  • code/trunk/src/libraries/util/Singleton.h

    r7163 r7401  
    2727 */
    2828
     29/**
     30    @defgroup SingletonScope Singletons and Scope
     31    @ingroup Util
     32*/
     33
     34/**
     35    @file
     36    @ingroup SingletonScope
     37    @brief Definition of the Singleton template that is used as base class for classes that allow only one instance.
     38
     39    @anchor SingletonExample
     40
     41    Classes that inherit from orxonox::Singleton follow the singleton pattern and thus
     42    allow only one instance of the class to exist. This istance is stored in a static
     43    variable called @c singletonPtr_s. orxonox::Singleton will access this variable, but
     44    it must be implemented in the deriving class.
     45
     46    Example:
     47    @code
     48    class TestSingleton : public Singleton<TestSingleton>   // inherit from Singleton, pass the own class as template argument
     49    {
     50        friend class Singleton<TestSingleton>;              // friend declaration so Singleton can access singletonPtr_s
     51
     52        public:
     53            TestSingleton();                                // public constructor because we may want to manage this singleton
     54                                                            //     with an orxonox::ScopedSingletonManager (see below)
     55            virtual ~TestSingleton();                       // public destructor
     56
     57            void testFunction();                            // put your functions here
     58
     59        private:
     60            int testValue_;                                 // put your variables here
     61
     62            static TestSingleton* singletonPtr_s;           // static singleton instance pointer, used by the Singleton template
     63    };
     64    @endcode
     65
     66    And don't forget to initialize the static singleton pointer in the source (*.cc) %file:
     67    @code
     68    TestSingleton* TestSingleton::singletonPtr_s = NULL;
     69    @endcode
     70
     71    Usually a singleton gets created automatically when it is first used, but it will never
     72    be destroyed (unless the singleton explicitly deletes itself). To allow controlled
     73    construction and destruction, the singleton can be put within a virtual scope. This is
     74    done by registering the singleton class with orxonox::ScopedSingletonManager. To
     75    do so, the ManageScopedSingleton() macro has to be called:
     76
     77    @code
     78    ManageScopedSingleton(TestSingleton, ScopeID::Graphics, false); // muste be called in a source (*.cc) file
     79    @endcode
     80
     81    @b Important: If you call ManageScopedSingleton(), you don't have to initialize singletonPtr_s anymore,
     82    because that's already done by the macro.
     83
     84    Now the singleton TestSingleton gets automatically created if the scope Graphics becomes
     85    active and also gets destroyed if the scope is deactivated.
     86
     87    Note that not all singletons must register with a scope, but it's recommended.
     88
     89    If a class inherits from orxonox::Singleton, it also inherits its functions. The most important
     90    function is orxonox::Singleton::getInstance() which returns a reference to the only instance
     91    of the singleton.
     92
     93    Example:
     94    @code
     95    TestSingleton::TestSingleton()                          // implement the constructor
     96    {
     97        this->testValue_ = 15;
     98    }
     99
     100    void TestSingleton::testFunction()                      // implement testFunction
     101    {
     102        COUT(0) << "My value is " << this->testValue_ << std::endl;
     103    }
     104
     105    TestSingleton::getInstance().testFunction();            // prints "My value is 15"
     106    @endcode
     107*/
     108
    29109#ifndef __Util_Singleton_H__
    30110#define __Util_Singleton_H__
     
    42122
    43123        Usage:
    44         Inherit publicly from Singleton<MyClass> and provide access to
    45         MyClass::singletonPtr_s.
     124        Inherit publicly from Singleton<MyClass> and provide access to MyClass::singletonPtr_s.
    46125        This can easily be done with a friend declaration.
     126
     127        See @ref SingletonExample "this example" for an exemplary implementation.
    47128    */
    48129    template <class T>
     
    80161        }
    81162
    82         //! Constructor resets the singleton instance pointer
     163        //! Destructor resets the singleton instance pointer
    83164        ~Singleton()
    84165        {
  • code/trunk/src/libraries/util/SmallObjectAllocator.cc

    r7284 r7401  
    2727 */
    2828
     29/**
     30    @file
     31    @brief Implementation of SmallObjectAllocator
     32*/
     33
    2934#include "SmallObjectAllocator.h"
    3035
    3136namespace orxonox
    3237{
     38    /**
     39        @brief Constructor: initializes the allocator and its values.
     40        @param objectSize The size in bytes (returned by sizeof()) of the allocated objects
     41        @param numObjects The number of objects that are allocated in one block of memory
     42    */
    3343    SmallObjectAllocator::SmallObjectAllocator(size_t objectSize, size_t numObjects)
    3444    {
    35         this->objectSize_ = std::max(objectSize, sizeof(Chunk));
    36         this->numObjects_ = numObjects;
     45        this->chunkSize_ = std::max(objectSize, sizeof(Chunk)); // the chunk's size will be the maximum of the object's size and the size of a Chunk object itself
     46        this->numChunksPerBlock_ = numObjects;
    3747        this->first_ = 0;
    3848    }
    3949
     50    /**
     51        @brief Destructor: deletes the allocated memory blocks.
     52    */
    4053    SmallObjectAllocator::~SmallObjectAllocator()
    4154    {
     
    4457    }
    4558
     59    /**
     60        @brief Helper function, used to set the next_ pointer of a Chunk.
     61    */
    4662    /* static */ void SmallObjectAllocator::setNext(void* chunk, void* next)
    4763    {
     
    4965    }
    5066
     67    /**
     68        @brief Helper function, returns the next_ pointer of a Chunk
     69    */
    5170    /* static */ void* SmallObjectAllocator::getNext(void* chunk)
    5271    {
     
    5473    }
    5574
     75    /**
     76        @brief Returns the first free memory chunk or allocates a new block of memory.
     77    */
    5678    void* SmallObjectAllocator::alloc()
    5779    {
     80        // get the first free chunk
    5881        void* chunk = this->first_;
    5982
     83        // check if the chunk exists
    6084        if (chunk)
    6185        {
     86            // yes it does - the first_ pointer now points to the second element in the list
    6287            this->first_ = getNext(chunk);
    6388        }
    6489        else
    6590        {
    66             char* block = new char[this->objectSize_ * this->numObjects_];
     91            // no it doesnt - allocate a new block of memory
     92            char* block = new char[this->chunkSize_ * this->numChunksPerBlock_];
    6793            this->blocks_.push_back(block);
    6894
    69             for (size_t i = 1; i < this->numObjects_ - 1; ++i)
    70                 setNext(block + i * this->objectSize_, block + (i + 1) * this->objectSize_);
     95            // iterate through the chunks in the new memory block and link them together to a single linked list
     96            for (size_t i = 1; i < this->numChunksPerBlock_ - 1; ++i)
     97                setNext(block + i * this->chunkSize_, block + (i + 1) * this->chunkSize_);
    7198
    72             setNext(block + (this->numObjects_ - 1) * this->objectSize_, 0);
     99            // the next_ pointer of the last chunk must point to NULL
     100            setNext(block + (this->numChunksPerBlock_ - 1) * this->chunkSize_, 0);
    73101
    74             this->first_ = block + this->objectSize_;
     102            // The second chunk in the block is assigned to the first_ pointer
     103            this->first_ = block + this->chunkSize_;
    75104
     105            // The first chunk in the block is returned
    76106            chunk = block;
    77107        }
    78108
     109        // return the pointer to the chunk
    79110        return chunk;
    80111    }
    81112
     113    /**
     114        @brief Puts the memory chunk back on the list of free memory.
     115    */
    82116    void SmallObjectAllocator::free(void* chunk)
    83117    {
     118        // The first_ pointer points to the freed chunk, its next_ pointer points to the rest of the list
    84119        setNext(chunk, this->first_);
    85120        this->first_ = chunk;
  • code/trunk/src/libraries/util/SmallObjectAllocator.h

    r7284 r7401  
    2727 */
    2828
     29/**
     30    @defgroup SmallObjectAllocator SmallObjectAllocator
     31    @ingroup Util
     32*/
     33
     34/**
     35    @file
     36    @ingroup SmallObjectAllocator
     37    @brief Declaration of SmallObjectAllocator
     38
     39    @anchor SmallObjectAllocatorExample
     40
     41    The default implementations of new and delete are designed to work with objects of
     42    arbitrary size. They are thus not optimal for small objects.
     43    @ref orxonox::SmallObjectAllocator "SmallObjectAllocator" allocates a large memory
     44    block and divides it into small chunks. These chunks are returned by the function
     45    @ref orxonox::SmallObjectAllocator::alloc() "alloc()" and can be used to create a
     46    new object using the placement new operator. Instead of delete, the function
     47    @ref orxonox::SmallObjectAllocator::free() "free()" is used to give the memory
     48    back to SmallObjectAllocator.
     49
     50    Example:
     51    @code
     52    SmallObjectAllocator allocator(sizeof(MySmallObject));  // Create an allocator. The size of the memory chunks must equal the size of the desired class
     53
     54    void* chunk = allocator.alloc();                        // Allocate a memory chunk
     55    MySmallObject* object = new (chunk) MySmallObject();    // Call the placement new operator
     56
     57    object->someFunction();                                 // Do something with the object
     58
     59    object->~MySmallObject();                               // Call the destructor
     60    allocator.free(object);                                 // Free the allocated memory
     61    @endcode
     62
     63    @b Important: You have to call the destructor of the object manually, because this
     64    is not automatically done by the allocator nor free().
     65
     66    @note The destructor can be ignored if it is empty or not implemented. This saves
     67    another amount of time.
     68
     69    @remarks For a distributed usage of SmallObjectAllocator it may be a good idea to
     70    create a static function that returns an instance to it. The allocator then works
     71    like a singleton and can be accesses from everywhere.
     72*/
     73
    2974#ifndef _SmallObjectAllocator_H__
    3075#define _SmallObjectAllocator_H__
     
    3580namespace orxonox
    3681{
     82    /**
     83        @brief This class is used to allocate and free small objects (usually not polymorphic).
     84
     85        SmallObjectAllocator provides a fast alternative to new and delete for small objects.
     86
     87        @see See @ref SmallObjectAllocatorExample "this description" for more information and an example.
     88    */
    3789    class _UtilExport SmallObjectAllocator
    3890    {
     91        /// The memory chunk is at the same time an element of a single linked list.
    3992        struct Chunk
    4093        {
    41             Chunk* next_;
     94            Chunk* next_;   ///< A pointer to the next chunk in the list
    4295        };
    4396
     
    53106            static void* getNext(void* chunk);
    54107
    55             void* first_;
    56             size_t objectSize_;
    57             size_t numObjects_;
     108            void* first_;                   ///< A pointer to the first free memory chunk
     109            size_t chunkSize_;              ///< The size of each chunk (and usually also the size of the created objects)
     110            size_t numChunksPerBlock_;      ///< The number of chunks per memory block
    58111
    59             std::vector<char*> blocks_;
     112            std::vector<char*> blocks_;     ///< A list of all allocated memory blocks (used to destroy them again)
    60113    };
    61114}
  • code/trunk/src/libraries/util/StringUtils.cc

    r7284 r7401  
    4141namespace orxonox
    4242{
     43    /// A blank string (""). Used to return a blank string by reference.
    4344    std::string BLANKSTRING;
    4445
     46    /// Returns a string of a unique number. This function is guaranteed to never return the same string twice.
    4547    std::string getUniqueNumberString()
    4648    {
     
    4850    }
    4951
    50     /**
    51         @brief Removes all whitespaces from a string.
    52         @param str The string to strip
    53     */
     52    /// Removes all whitespaces from a string.
    5453    void strip(std::string* str)
    5554    {
     
    6362    }
    6463
    65     /**
    66         @brief Returns a copy of a string without whitespaces.
    67         @param str The string to strip
    68         @return The stripped line
    69     */
     64    /// Returns a copy of a string without whitespaces.
    7065    std::string getStripped(const std::string& str)
    7166    {
     
    7570    }
    7671
    77     /**
    78         @brief Returns a copy of a string without trailing whitespaces.
    79         @param str The string
    80         @return The modified copy
    81     */
     72    /// Returns a copy of a string without trailing whitespaces.
    8273    std::string removeTrailingWhitespaces(const std::string& str)
    8374    {
     
    9081
    9182    /**
    92         @brief Returns the position of the next quote in the string, starting with start.
     83        @brief Returns the position of the next quotation mark in the string, starting with start.
    9384        @param str The string
    94         @param start The startposition
    95         @return The position of the next quote (std::string::npos if there is no next quote)
     85        @param start The first position to look at
     86        @return The position of the next quotation mark (@c std::string::npos if there is none)
    9687    */
    9788    size_t getNextQuote(const std::string& str, size_t start)
     
    115106
    116107    /**
    117         @brief Returns true if pos is between two quotes.
     108        @brief Returns true if pos is between two quotation marks.
    118109        @param str The string
    119110        @param pos The position to check
    120         @return True if pos is between two quotes
     111        @return True if pos is between two quotation marks
    121112    */
    122113    bool isBetweenQuotes(const std::string& str, size_t pos)
     
    140131    }
    141132
    142     /**
    143         @brief Returns true if the string contains something like '..."between quotes"...'.
    144         @param The string
    145         @return True if there is something between quotes
    146     */
     133    /// Returns true if the string contains something like '..."between quotaton marks"...'.
    147134    bool hasStringBetweenQuotes(const std::string& str)
    148135    {
     
    152139    }
    153140
    154     /**
    155         @brief If the string contains something like '..."between quotes"...' then 'between quotes' gets returned (without quotes).
    156         @param The string
    157         @param The string between the quotes
    158     */
     141    /// If the string contains something like '..."between quotaton marks"...' then 'between quotaton marks' gets returned, otherwise "".
    159142    std::string getStringBetweenQuotes(const std::string& str)
    160143    {
     
    168151
    169152    /**
    170         @brief Removes enclosing quotes if available (including whitespaces at the outside of the quotes).
    171         @brief str The string to strip
    172         @return The string with removed quotes
     153        @brief Removes enclosing quotation marks if available (including whitespaces at the outside of the quotation marks).
     154        @return The striped string without quotation marks
    173155    */
    174156    std::string stripEnclosingQuotes(const std::string& str)
     
    208190
    209191    /**
    210         @brief Removes enclosing {braces} (braces must be exactly on the beginning and the end of the string).
    211         @param str The string to strip
    212         @return The striped string
     192        @brief Removes enclosing braces '{' and '}' (the braces must be exactly on the beginning and the end of the string).
     193        @return The striped string without braces
    213194    */
    214195    std::string stripEnclosingBraces(const std::string& str)
     
    224205    /**
    225206        @brief Determines if a string is a comment (starts with a comment-symbol).
    226         @param str The string to check
    227         @return True = it's a comment
    228207
    229208        A comment is defined by a leading '#', '%', ';' or '//'.
     
    253232    }
    254233
    255     /**
    256         @brief Determines if a string is empty (contains only whitespaces).
    257         @param str The string to check
    258         @return True = it's empty
    259     */
     234    /// Determines if a string is empty (contains only whitespaces).
    260235    bool isEmpty(const std::string& str)
    261236    {
     
    263238    }
    264239
    265     /**
    266         @brief Determines if a string contains only numbers and maximal one '.'.
    267         @param str The string to check
    268         @return True = it's a number
    269     */
     240    /// Determines if a string contains only numbers and maximal one '.'.
    270241    bool isNumeric(const std::string& str)
    271242    {
     
    288259    /**
    289260        @brief Adds backslashes to the given string which makes special chars visible. Existing slashes will be doubled.
    290         @param str The string to manipulate
    291         @return The string with added slashes
     261
     262        This function converts all special chars like line breaks, tabs, quotation marks etc. into
     263        a human readable format by adding a backslash. So for example "\n" will be converted to
     264        "\\" + "n".
     265
     266        This is usually used when a string is written to a file.
     267
     268        @see removeSlashes
    292269    */
    293270    std::string addSlashes(const std::string& str)
     
    320297    /**
    321298        @brief Removes backslashes from the given string. Double backslashes are interpreted as one backslash.
    322         @param str The string to manipulate
    323         @return The string with removed slashes
     299
     300        This function removes all backslashes and converts the human readable equivalents of
     301        special chars like "\\" + "n" into their real meaning (in this case a line break or "\n").
     302
     303        This is usually used when reading a string from a file.
     304
     305        @see addSlashes
    324306    */
    325307    std::string removeSlashes(const std::string& str)
     
    361343    }
    362344
    363     /**
    364         @brief Replaces each char between A and Z with its lowercase equivalent.
    365         @param str The string to convert
    366     */
     345    /// Replaces each char between A and Z with its lowercase equivalent.
    367346    void lowercase(std::string* str)
    368347    {
     
    373352    }
    374353
    375     /**
    376         @brief Returns a copy of the given string without uppercase chars.
    377         @param str The string
    378         @return The copy
    379     */
     354    /// Returns a copy of the given string where all chars are converted to lowercase.
    380355    std::string getLowercase(const std::string& str)
    381356    {
     
    385360    }
    386361
    387     /**
    388         @brief Replaces each char between a and z with its uppercase equivalent.
    389         @param str The string to convert
    390     */
     362    /// Replaces each char between a and z with its uppercase equivalent.
    391363    void uppercase(std::string* str)
    392364    {
     
    397369    }
    398370
    399     /**
    400         @brief Returns a copy of the given string without lowercase chars.
    401         @param str The string
    402         @return The copy
    403     */
     371    /// Returns a copy of the given string where all chars are converted to uppercase.
    404372    std::string getUppercase(const std::string& str)
    405373    {
     
    411379    /**
    412380        @brief Compares two strings ignoring different casing.
    413         @param s1 First string
    414         @param s2 Second string
     381        @return s1 == s1 -> returns 0 / s1 < s2 -> returns -1 / s1 >= s2 -> returns 1
    415382    */
    416383    int nocaseCmp(const std::string& s1, const std::string& s2)
     
    438405
    439406    /**
    440         @brief Compares the first 'len' chars of two strings ignoring different casing.
     407        @brief Compares the first @a len chars of two strings ignoring different casing.
    441408        @param s1 First string
    442409        @param s2 Second string
     
    463430    }
    464431
    465     /**
    466         @brief Returns true if the string contains a comment, introduced by #, %, ; or //.
     432    /// Returns true if the string contains a comment, introduced by #, %, ; or //.
     433    bool hasComment(const std::string& str)
     434    {
     435        return (getCommentPosition(str) != std::string::npos);
     436    }
     437
     438    /// If the string contains a comment, the comment gets returned (including the comment symbol), an empty string otherwise.
     439    std::string getComment(const std::string& str)
     440    {
     441        return str.substr(getCommentPosition(str));
     442    }
     443
     444    /// If the string contains a comment, the position of the comment-symbol gets returned, @c std::string::npos otherwise.
     445    size_t getCommentPosition(const std::string& str)
     446    {
     447        return getNextCommentPosition(str, 0);
     448    }
     449
     450    /**
     451        @brief Returns the position of the next comment-symbol, starting with @a start.
    467452        @param str The string
    468         @return True if the string contains a comment
    469     */
    470     bool hasComment(const std::string& str)
    471     {
    472         return (getCommentPosition(str) != std::string::npos);
    473     }
    474 
    475     /**
    476         @brief If the string contains a comment, the comment gets returned (including the comment symbol), an empty string otherwise.
    477         @param str The string
    478         @return The comment
    479     */
    480     std::string getComment(const std::string& str)
    481     {
    482         return str.substr(getCommentPosition(str));
    483     }
    484 
    485     /**
    486         @brief If the string contains a comment, the position of the comment-symbol gets returned, std::string::npos otherwise.
    487         @param str The string
    488         @return The position
    489     */
    490     size_t getCommentPosition(const std::string& str)
    491     {
    492         return getNextCommentPosition(str, 0);
    493     }
    494 
    495     /**
    496         @brief Returns the position of the next comment-symbol, starting with start.
    497         @param str The string
    498         @param start The startposition
    499         @return The position
     453        @param start The first position to look at
    500454    */
    501455    size_t getNextCommentPosition(const std::string& str, size_t start)
  • code/trunk/src/libraries/util/StringUtils.h

    r7284 r7401  
    2828
    2929/**
     30    @defgroup String String functions
     31    @ingroup Util
     32*/
     33
     34/**
    3035    @file
     36    @ingroup String
    3137    @brief Declaration of several string manipulation functions, used in many parts of the game.
    3238*/
  • code/trunk/src/libraries/util/SubString.cc

    r7284 r7401  
    3838 */
    3939
     40/**
     41    @file
     42    @brief Implementation of the SubString class.
     43*/
     44
    4045#include "SubString.h"
    4146#include <cstdio>
     47#include "Debug.h"
    4248
    4349namespace orxonox
    4450{
    45     /**
    46      * @brief default constructor
    47      */
     51    const std::string SubString::WhiteSpaces          = " \n\t";
     52    const std::string SubString::WhiteSpacesWithComma = " \n\t,";
     53    const SubString SubString::NullSubString          = SubString();
     54
     55    /**
     56        @brief Default constructor.
     57    */
    4858    SubString::SubString()
    49     {}
    50 
    51 
    52     /**
    53      * @brief create a SubString from
    54      * @param string the String to Split
    55      * @param delimiter the Character at which to split string (delimiter)
    56      */
    57     SubString::SubString(const std::string& string, char delimiter)
    58     {
    59         this->split(string, delimiter);
    60     }
    61 
    62 
    63     /**
    64      * @brief Splits a String into multiple splitters.
    65      * @param string the String to split
    66      * @param delimiters multiple set of characters at what to split. (delimiters)
    67      * @param delimiterNeighbours neighbours of the delimiters, that will be erased only when near a delimiter.
    68      * @param emptyEntries If empty entries should be allewed or removed.
    69      * @param escapeChar The Escape Character that overrides splitters commends and so on...
    70      * @param safemode_char within these characters splitting won't happen
    71      * @param comment_char the Comment character.
    72      */
    73     SubString::SubString(const std::string& string,
    74                          const std::string& delimiters, const std::string& delimiterNeighbours, bool emptyEntries,
    75                          char escapeChar, bool removeEscapeChar, char safemode_char, bool removeSafemodeChar,
    76                          char openparenthesis_char, char closeparenthesis_char, bool removeParenthesisChars, char comment_char)
    77     {
    78         SubString::splitLine(this->strings, this->bInSafemode, string, delimiters, delimiterNeighbours, emptyEntries, escapeChar, removeEscapeChar, safemode_char, removeSafemodeChar, openparenthesis_char, closeparenthesis_char, removeParenthesisChars, comment_char);
    79     }
    80 
    81     /**
    82      * @brief creates a SubSet of a SubString.
    83      * @param subString the SubString to take a set from.
    84      * @param subSetBegin the beginning to the end
    85      */
    86     SubString::SubString(const SubString& subString, unsigned int subSetBegin)
    87     {
    88         for (unsigned int i = subSetBegin; i < subString.size(); i++)
    89         {
    90             this->strings.push_back(subString[i]);
    91             this->bInSafemode.push_back(subString.isInSafemode(i));
    92         }
    93     }
    94 
    95 
    96     /**
    97      * @brief creates a SubSet of a SubString.
    98      * @param subString the SubString to take a Set from
    99      * @param subSetBegin the beginning to the end
    100      * @param subSetEnd the end of the SubSet (max subString.size() will be checked internaly)
    101      */
    102     SubString::SubString(const SubString& subString, unsigned int subSetBegin, unsigned int subSetEnd)
    103     {
    104         for (unsigned int i = subSetBegin; i < subString.size() && i < subSetEnd; i++)
    105         {
    106             this->strings.push_back(subString[i]);
    107             this->bInSafemode.push_back(subString.isInSafemode(i));
    108         }
    109     }
    110 
    111     /**
    112      * @brief creates a Substring from a count and values set.
    113      * @param argc: the Arguments Count.
    114      * @param argv: Argument Values.
    115      */
     59    {
     60    }
     61
     62    /**
     63        @brief Splits a string into multiple tokens.
     64        @param line The line to split
     65        @param delimiters Multiple characters at which to split the line
     66        @param delimiterNeighbours Neighbours of the delimiters that will be erased as well (for example white-spaces)
     67        @param bAllowEmptyEntries If true, empty tokens are also added to the SubString (if there are two delimiters without a char in between)
     68        @param escapeChar The escape character that is used to escape safemode chars (for example if you want to use a quotation mark between two other quotation marks).
     69        @param bRemoveEscapeChar If true, the escape char is removed from the tokens
     70        @param safemodeChar Within these characters splitting won't happen (usually the quotation marks)
     71        @param bRemoveSafemodeChar Removes the safemodeChar from the beginning and the ending of a token
     72        @param openparenthesisChar The beginning of a safemode is marked with this (usually an opening brace)
     73        @param closeparenthesisChar The ending of a safemode is marked with this (usually a closing brace)
     74        @param bRemoveParenthesisChars Removes the parenthesis chars from the beginning and the ending of a token
     75        @param commentChar The comment character (used to ignore the part of the line after the comment char).
     76    */
     77    SubString::SubString(const std::string& line,
     78                         const std::string& delimiters, const std::string& delimiterNeighbours, bool bAllowEmptyEntries,
     79                         char escapeChar, bool bRemoveEscapeChar, char safemodeChar, bool bRemoveSafemodeChar,
     80                         char openparenthesisChar, char closeparenthesisChar, bool bRemoveParenthesisChars, char commentChar)
     81    {
     82        SubString::splitLine(this->tokens_, this->bTokenInSafemode_, line, delimiters, delimiterNeighbours, bAllowEmptyEntries, escapeChar, bRemoveEscapeChar, safemodeChar, bRemoveSafemodeChar, openparenthesisChar, closeparenthesisChar, bRemoveParenthesisChars, commentChar);
     83    }
     84
     85    /**
     86        @brief creates a new SubString based on a subset of an other SubString.
     87        @param other The other SubString
     88        @param begin The beginning of the subset
     89
     90        The subset ranges from the token with index @a begin to the end of the tokens.
     91        If @a begin is greater than the greatest index, the new SubString will be empty.
     92    */
     93    SubString::SubString(const SubString& other, unsigned int begin)
     94    {
     95        for (unsigned int i = begin; i < other.size(); ++i)
     96        {
     97            this->tokens_.push_back(other[i]);
     98            this->bTokenInSafemode_.push_back(other.isInSafemode(i));
     99        }
     100    }
     101
     102    /**
     103        @brief creates a new SubString based on a subset of an other SubString.
     104        @param other The other SubString
     105        @param begin The beginning of the subset
     106        @param end The end of the subset
     107
     108        The subset ranges from the token with index @a begin until (but not including) the token with index @a end.
     109        If @a begin or @a end are beyond the allowed index, the resulting SubString will be empty.
     110    */
     111    SubString::SubString(const SubString& other, unsigned int begin, unsigned int end)
     112    {
     113        for (unsigned int i = begin; i < std::min(other.size(), end); ++i)
     114        {
     115            this->tokens_.push_back(other[i]);
     116            this->bTokenInSafemode_.push_back(other.isInSafemode(i));
     117        }
     118    }
     119
     120    /**
     121        @brief Creates a SubString from a count and values set.
     122        @param argc The number of arguments
     123        @param argv An array of pointers to the arguments
     124    */
    116125    SubString::SubString(unsigned int argc, const char** argv)
    117126    {
    118127        for(unsigned int i = 0; i < argc; ++i)
    119128        {
    120             this->strings.push_back(std::string(argv[i]));
    121             this->bInSafemode.push_back(false);
    122         }
    123     }
    124 
    125     /**
    126      * @brief removes the object from memory
    127      */
     129            this->tokens_.push_back(std::string(argv[i]));
     130            this->bTokenInSafemode_.push_back(false);
     131        }
     132    }
     133
     134    /**
     135        @brief Destructor
     136    */
    128137    SubString::~SubString()
    129138    { }
    130139
    131     /** @brief An empty String */
    132     // const std::string SubString::emptyString = "";
    133     /** @brief Helper that gets you a String consisting of all White Spaces */
    134     const std::string SubString::WhiteSpaces = " \n\t";
    135     /** @brief Helper that gets you a String consisting of all WhiteSpaces and the Comma */
    136     const std::string SubString::WhiteSpacesWithComma = " \n\t,";
    137     /** An Empty SubString */
    138     const SubString SubString::NullSubString = SubString();
    139 
    140     /**
    141      * @brief stores the Value of subString in this SubString
    142      * @param subString will be copied into this String.
    143      * @returns this SubString.
    144      */
    145     SubString& SubString::operator=(const SubString& subString)
    146     {
    147         this->strings = subString.strings;
    148         this->bInSafemode = subString.bInSafemode;
     140    /**
     141        @brief Stores the tokens of @a other in this SubString
     142        @return This SubString.
     143    */
     144    SubString& SubString::operator=(const SubString& other)
     145    {
     146        this->tokens_ = other.tokens_;
     147        this->bTokenInSafemode_ = other.bTokenInSafemode_;
    149148        return *this;
    150149    }
    151150
    152 
    153     /**
    154      * @brief comparator.
    155      * @param subString the SubString to compare against this one.
    156      * @returns true if the Stored Strings match
    157      */
    158     bool SubString::operator==(const SubString& subString) const
    159     {
    160         return ((this->strings == subString.strings) && (this->bInSafemode == subString.bInSafemode));
    161     }
    162 
    163     /**
    164      * @brief comparator.
    165      * @param subString the SubString to compare against this one.
    166      * @returns true if the Stored Strings match
    167      */
    168     bool SubString::compare(const SubString& subString) const
    169     {
    170         return (*this == subString);
    171     }
    172 
    173     /**
    174      * @brief comparator.
    175      * @param subString the SubString to compare against this one.
    176      * @param length how many entries to compare. (from 0 to length)
    177      * @returns true if the Stored Strings match
    178      */
    179     bool SubString::compare(const SubString& subString, unsigned int length) const
    180     {
    181         if (length > this->size() || length > subString.size())
     151    /**
     152        @brief Compares this SubString to another SubString and returns true if they contain the same values.
     153    */
     154    bool SubString::operator==(const SubString& other) const
     155    {
     156        return ((this->tokens_ == other.tokens_) && (this->bTokenInSafemode_ == other.bTokenInSafemode_));
     157    }
     158
     159    /**
     160        @copydoc operator==
     161    */
     162    bool SubString::compare(const SubString& other) const
     163    {
     164        return (*this == other);
     165    }
     166
     167    /**
     168        @brief Compares this SubString to another SubString and returns true if the first @a length values match.
     169        @param other The other SubString
     170        @param length How many tokens to compare
     171    */
     172    bool SubString::compare(const SubString& other, unsigned int length) const
     173    {
     174        if (length > this->size() || length > other.size())
    182175            return false;
    183176
    184         for (unsigned int i = 0; i < length; i++)
    185             if ((this->strings[i] != subString.strings[i]) || (this->bInSafemode[i] != subString.bInSafemode[i]))
     177        for (unsigned int i = 0; i < length; ++i)
     178            if ((this->tokens_[i] != other.tokens_[i]) || (this->bTokenInSafemode_[i] != other.bTokenInSafemode_[i]))
    186179                return false;
    187180        return true;
    188181    }
    189182
    190 
    191     /**
    192      * @brief append operator
    193      * @param subString the String to append.
    194      * @returns a SubString where this and subString are appended.
    195      */
    196     SubString SubString::operator+(const SubString& subString) const
    197     {
    198         return SubString(*this) += subString;
    199     }
    200 
    201 
    202     /**
    203      * @brief append operator.
    204      * @param subString append subString to this SubString.
    205      * @returns this substring appended with subString
    206      */
    207     SubString& SubString::operator+=(const SubString& subString)
    208     {
    209         for (unsigned int i = 0; i < subString.size(); i++)
    210         {
    211             this->strings.push_back(subString[i]);
    212             this->bInSafemode.push_back(subString.isInSafemode(i));
     183    /**
     184        @brief Concatenates the tokens of two SubStrings and returns the resulting new SubString
     185        @return A new SubString that contains the tokens of this and the other SubString
     186    */
     187    SubString SubString::operator+(const SubString& other) const
     188    {
     189        return SubString(*this) += other;
     190    }
     191
     192    /**
     193        @brief Appends the tokens of @a other to this SubString
     194        @return This SubString
     195    */
     196    SubString& SubString::operator+=(const SubString& other)
     197    {
     198        for (unsigned int i = 0; i < other.size(); ++i)
     199        {
     200            this->tokens_.push_back(other[i]);
     201            this->bTokenInSafemode_.push_back(other.isInSafemode(i));
    213202        }
    214203        return *this;
    215204    }
    216205
    217 
    218     /**
    219      * @brief Split the String at
    220      * @param string where to split
    221      * @param splitter delimiter.
    222      */
    223     unsigned int SubString::split(const std::string& string, char splitter)
    224     {
    225         this->strings.clear();
    226         this->bInSafemode.clear();
    227         char split[2];
    228         split[0] = splitter;
    229         split[1] = '\0';
    230         SubString::splitLine(this->strings, this->bInSafemode, string, split);
    231         return strings.size();
    232     }
    233 
    234 
    235     /**
    236      * @brief Splits a String into multiple splitters.
    237      * @param string the String to split
    238      * @param delimiters multiple set of characters at what to split. (delimiters)
    239      * @param delimiterNeighbours: Neighbours to the Delimiters that will be erased too.
    240      * @param emptyEntries: If empty entries are added to the List of SubStrings
    241      * @param escapeChar The Escape Character that overrides splitters commends and so on...
    242      * @param safemode_char within these characters splitting won't happen
    243      * @param comment_char the Comment character.
    244      */
    245     unsigned int SubString::split(const std::string& string,
    246                                   const std::string& delimiters, const std::string& delimiterNeighbours, bool emptyEntries,
    247                                   char escapeChar, bool removeExcapeChar, char safemode_char, bool removeSafemodeChar,
    248                                   char openparenthesis_char, char closeparenthesis_char, bool removeParenthesisChars, char comment_char)
    249     {
    250         this->strings.clear();
    251         this->bInSafemode.clear();
    252         SubString::splitLine(this->strings, this->bInSafemode, string, delimiters, delimiterNeighbours, emptyEntries, escapeChar, removeExcapeChar, safemode_char, removeSafemodeChar, openparenthesis_char, closeparenthesis_char, removeParenthesisChars, comment_char);
    253         return this->strings.size();
    254     }
    255 
    256 
    257     /**
    258      * @brief joins together all Strings of this Substring.
    259      * @param delimiter the String between the subStrings.
    260      * @returns the joined String.
    261      */
     206    /**
     207        @copydoc SubString(const std::string&,const std::string&,const std::string&,bool,char,bool,char,bool,char,char,bool,char)
     208    */
     209    unsigned int SubString::split(const std::string& line,
     210                                  const std::string& delimiters, const std::string& delimiterNeighbours, bool bAllowEmptyEntries,
     211                                  char escapeChar, bool bRemoveEscapeChar, char safemodeChar, bool bRemoveSafemodeChar,
     212                                  char openparenthesisChar, char closeparenthesisChar, bool bRemoveParenthesisChars, char commentChar)
     213    {
     214        this->tokens_.clear();
     215        this->bTokenInSafemode_.clear();
     216        SubString::splitLine(this->tokens_, this->bTokenInSafemode_, line, delimiters, delimiterNeighbours, bAllowEmptyEntries, escapeChar, bRemoveEscapeChar, safemodeChar, bRemoveSafemodeChar, openparenthesisChar, closeparenthesisChar, bRemoveParenthesisChars, commentChar);
     217        return this->tokens_.size();
     218    }
     219
     220    /**
     221        @brief Joins the tokens of this SubString using the given delimiter and returns a string.
     222        @param delimiter This delimiter will be placed between each two tokens
     223        @return The joined string.
     224    */
    262225    std::string SubString::join(const std::string& delimiter) const
    263226    {
    264         if (!this->strings.empty())
    265         {
    266             std::string retVal = this->strings[0];
    267             for (unsigned int i = 1; i < this->strings.size(); i++)
    268                 retVal += delimiter + this->strings[i];
     227        if (!this->tokens_.empty())
     228        {
     229            std::string retVal = this->tokens_[0];
     230            for (unsigned int i = 1; i < this->tokens_.size(); ++i)
     231                retVal += delimiter + this->tokens_[i];
    269232            return retVal;
    270233        }
     
    273236    }
    274237
    275 
    276     /**
    277      * @brief creates a SubSet of a SubString.
    278      * @param subSetBegin the beginning to the end
    279      * @returns the SubSet
    280      *
    281      * This function is added for your convenience, and does the same as
    282      * SubString::SubString(const SubString& subString, unsigned int subSetBegin)
    283      */
    284     SubString SubString::subSet(unsigned int subSetBegin) const
    285     {
    286         return SubString(*this, subSetBegin);
    287     }
    288 
    289 
    290     /**
    291      * @brief creates a SubSet of a SubString.
    292      * @param subSetBegin the beginning to
    293      * @param subSetEnd the end of the SubSet to select (if bigger than subString.size() it will be downset.)
    294      * @returns the SubSet
    295      *
    296      * This function is added for your convenience, and does the same as
    297      * SubString::SubString(const SubString& subString, unsigned int subSetBegin)
    298      */
    299     SubString SubString::subSet(unsigned int subSetBegin, unsigned int subSetEnd) const
    300     {
    301         return SubString(*this, subSetBegin, subSetEnd);
    302     }
    303 
    304 
    305     /**
    306      * @brief splits line into tokens and stores them in ret.
    307      * @param ret the Array, where the Splitted strings will be stored in
    308      * to the beginning of the current token is stored
    309      * @param line the inputLine to split
    310      * @param delimiters a String of Delimiters (here the input will be splitted)
    311      * @param delimiterNeighbours Neighbours to the Delimiter, that will be removed if they are to the left or the right of a Delimiter.
    312      * @param emptyEntries: if empty Strings are added to the List of Strings.
    313      * @param escape_char: Escape carater (escapes splitters)
    314      * @param safemode_char: the beginning of the safemode is marked with this
    315      * @param removeSafemodeChar removes the safemode_char from the beginning and the ending of a token
    316      * @param openparenthesis_char the beginning of a safemode is marked with this
    317      * @param closeparenthesis_char the ending of a safemode is marked with this
    318      * @param removeParenthesisChars removes the parenthesis from the beginning and the ending of a token
    319      * @param comment_char: the beginning of a comment is marked with this: (until the end of a Line)
    320      * @param start_state: the Initial state on how to parse the String.
    321      * @return SPLIT_LINE_STATE the parser was in when returning
    322      *
    323      * This is the Actual Splitting Algorithm from Clemens Wacha
    324      * Supports delimiters, escape characters,
    325      * ignores special  characters between safemode_char and between comment_char and linend '\n'.
    326      */
     238    /**
     239        @brief Creates a subset of this SubString.
     240        @param begin The beginning of the subset
     241        @return A new SubString containing the defined subset.
     242
     243        The subset ranges from the token with index @a begin to the end of the tokens.
     244        If @a begin is greater than the greatest index, the new SubString will be empty.
     245
     246        This function is added for your convenience, and does the same as
     247        SubString::SubString(const SubString& other, unsigned int begin)
     248    */
     249    SubString SubString::subSet(unsigned int begin) const
     250    {
     251        return SubString(*this, begin);
     252    }
     253
     254    /**
     255        @brief Creates a subset of this SubString.
     256        @param begin The beginning of the subset
     257        @param end The ending of the subset
     258        @return A new SubString containing the defined subset.
     259
     260        The subset ranges from the token with index @a begin until (but not including) the token with index @a end.
     261        If @a begin or @a end are beyond the allowed index, the resulting SubString will be empty.
     262
     263        This function is added for your convenience, and does the same as
     264        SubString::SubString(const SubString& other, unsigned int begin, unsigned int end)
     265    */
     266    SubString SubString::subSet(unsigned int begin, unsigned int end) const
     267    {
     268        return SubString(*this, begin, end);
     269    }
     270
     271    /**
     272        @copydoc SubString(const std::string&,const std::string&,const std::string&,bool,char,bool,char,bool,char,char,bool,char)
     273        @param tokens The array, where the splitted strings will be stored in
     274        @param bTokenInSafemode A vector wich stores for each character of the string if it is in safemode or not
     275        @param start_state The internal state of the parser
     276
     277        This is the actual splitting algorithm from Clemens Wacha.
     278        Supports delimiters, escape characters, ignores special characters between safemodeChar and between commentChar and line end "\n".
     279
     280        Extended by Orxonox to support parenthesis as additional safe-mode.
     281    */
    327282    SubString::SPLIT_LINE_STATE
    328     SubString::splitLine(std::vector<std::string>& ret,
    329                          std::vector<bool>& bInSafemode,
     283    SubString::splitLine(std::vector<std::string>& tokens,
     284                         std::vector<bool>& bTokenInSafemode,
    330285                         const std::string& line,
    331286                         const std::string& delimiters,
    332287                         const std::string& delimiterNeighbours,
    333                          bool emptyEntries,
    334                          char escape_char,
    335                          bool removeExcapeChar,
    336                          char safemode_char,
    337                          bool removeSafemodeChar,
    338                          char openparenthesis_char,
    339                          char closeparenthesis_char,
    340                          bool removeParenthesisChars,
    341                          char comment_char,
     288                         bool bAllowEmptyEntries,
     289                         char escapeChar,
     290                         bool bRemoveEscapeChar,
     291                         char safemodeChar,
     292                         bool bRemoveSafemodeChar,
     293                         char openparenthesisChar,
     294                         char closeparenthesisChar,
     295                         bool bRemoveParenthesisChars,
     296                         char commentChar,
    342297                         SPLIT_LINE_STATE start_state)
    343298    {
     
    349304        bool inSafemode = false;
    350305
    351         if(start_state != SL_NORMAL && ret.size() > 0)
    352         {
    353             token = ret[ret.size()-1];
    354             ret.pop_back();
    355         }
    356         if(start_state != SL_NORMAL && bInSafemode.size() > 0)
    357         {
    358             inSafemode = bInSafemode[bInSafemode.size()-1];
    359             bInSafemode.pop_back();
     306        if(start_state != SL_NORMAL && tokens.size() > 0)
     307        {
     308            token = tokens[tokens.size()-1];
     309            tokens.pop_back();
     310        }
     311        if(start_state != SL_NORMAL && bTokenInSafemode.size() > 0)
     312        {
     313            inSafemode = bTokenInSafemode[bTokenInSafemode.size()-1];
     314            bTokenInSafemode.pop_back();
    360315        }
    361316
     
    365320            {
    366321            case SL_NORMAL:
    367                 if(line[i] == escape_char)
     322                if(line[i] == escapeChar)
    368323                {
    369324                    state = SL_ESCAPE;
    370                     if (!removeExcapeChar)
     325                    if (!bRemoveEscapeChar)
    371326                        token += line[i];
    372                 }
    373                 else if(line[i] == safemode_char)
     327                    fallBackNeighbours = 0;
     328                }
     329                else if(line[i] == safemodeChar)
    374330                {
    375331                    state = SL_SAFEMODE;
    376332                    inSafemode = true;
    377                     if (!removeSafemodeChar)
     333                    if (!bRemoveSafemodeChar)
    378334                        token += line[i];
    379                 }
    380                 else if(line[i] == openparenthesis_char)
     335                    fallBackNeighbours = 0;
     336                }
     337                else if(line[i] == openparenthesisChar)
    381338                {
    382339                    state = SL_PARENTHESES;
    383340                    inSafemode = true;
    384                     if (!removeParenthesisChars)
     341                    if (!bRemoveParenthesisChars)
    385342                        token += line[i];
    386                 }
    387                 else if(line[i] == comment_char)
     343                    fallBackNeighbours = 0;
     344                }
     345                else if(line[i] == commentChar)
    388346                {
    389347                    if (fallBackNeighbours > 0)
    390348                        token = token.substr(0, token.size() - fallBackNeighbours);
    391                     /// FINISH
    392                     if(emptyEntries || token.size() > 0)
     349                    fallBackNeighbours = 0;
     350                    // FINISH
     351                    if(bAllowEmptyEntries || token.size() > 0)
    393352                    {
    394                         ret.push_back(token);
     353                        tokens.push_back(token);
    395354                        token.clear();
    396                         bInSafemode.push_back(inSafemode);
     355                        bTokenInSafemode.push_back(inSafemode);
    397356                        inSafemode = false;
    398357                    }
     
    405364                    if (fallBackNeighbours > 0)
    406365                        token = token.substr(0, token.size() - fallBackNeighbours);
    407                     /// FINISH
    408                     if(emptyEntries || token.size() > 0)
     366                    fallBackNeighbours = 0;
     367                    // FINISH
     368                    if(bAllowEmptyEntries || token.size() > 0)
    409369                    {
    410                         ret.push_back(token);
     370                        tokens.push_back(token);
    411371                        token.clear();
    412                         bInSafemode.push_back(inSafemode);
     372                        bTokenInSafemode.push_back(inSafemode);
    413373                        inSafemode = false;
    414374                    }
     
    423383                        else
    424384                        {
    425                             i++;
     385                            ++i;
    426386                            continue;
    427387                        }
     
    433393                break;
    434394            case SL_ESCAPE:
    435                 if (!removeSafemodeChar)
     395                if (!bRemoveSafemodeChar)
    436396                    token += line[i];
    437397                else
     
    450410                break;
    451411            case SL_SAFEMODE:
    452                 if(line[i] == safemode_char)
     412                if(line[i] == safemodeChar)
    453413                {
    454414                    state = SL_NORMAL;
    455                     if (!removeSafemodeChar)
     415                    if (!bRemoveSafemodeChar)
    456416                        token += line[i];
    457417                }
    458                 else if(line[i] == escape_char)
     418                else if(line[i] == escapeChar)
    459419                {
    460420                    state = SL_SAFEESCAPE;
     
    480440
    481441            case SL_PARENTHESES:
    482                 if(line[i] == closeparenthesis_char)
     442                if(line[i] == closeparenthesisChar)
    483443                {
    484444                    state = SL_NORMAL;
    485                     if (!removeParenthesisChars)
     445                    if (!bRemoveParenthesisChars)
    486446                        token += line[i];
    487447                }
    488                 else if(line[i] == escape_char)
     448                else if(line[i] == escapeChar)
    489449                {
    490450                    state = SL_PARENTHESESESCAPE;
     
    512472                if(line[i] == '\n')
    513473                {
    514                     /// FINISH
     474                    // FINISH
    515475                    if(token.size() > 0)
    516476                    {
    517                         ret.push_back(token);
     477                        tokens.push_back(token);
    518478                        token.clear();
    519                         bInSafemode.push_back(inSafemode);
     479                        bTokenInSafemode.push_back(inSafemode);
    520480                        inSafemode = false;
    521481                    }
     
    532492                break;
    533493            }
    534             i++;
    535         }
    536 
    537         /// FINISH
     494            ++i;
     495        }
     496
     497        // FINISH
    538498        if (fallBackNeighbours > 0)
    539499            token = token.substr(0, token.size() - fallBackNeighbours);
    540         if(emptyEntries || token.size() > 0)
    541         {
    542             ret.push_back(token);
     500        if(bAllowEmptyEntries || token.size() > 0)
     501        {
     502            tokens.push_back(token);
    543503            token.clear();
    544             bInSafemode.push_back(inSafemode);
     504            bTokenInSafemode.push_back(inSafemode);
    545505            inSafemode = false;
    546506        }
     
    548508    }
    549509
    550 
    551     /**
    552      * @brief Some nice debug information about this SubString
    553      */
     510    /**
     511        @brief Some nice debug information about this SubString.
     512    */
    554513    void SubString::debug() const
    555514    {
    556         printf("Substring-information::count=%d ::", this->strings.size());
    557         for (unsigned int i = 0; i < this->strings.size(); i++)
    558             printf("s%d='%s'::", i, this->strings[i].c_str());
    559         printf("\n");
     515        COUT(0) << "Substring-information::count=" << this->tokens_.size() << " ::";
     516        for (unsigned int i = 0; i < this->tokens_.size(); ++i)
     517            COUT(0) << "s" << i << "='" << this->tokens_[i].c_str() << "'::";
     518        COUT(0) << std::endl;
    560519    }
    561520}
  • code/trunk/src/libraries/util/SubString.h

    r7284 r7401  
    3737 */
    3838
    39  /*!
    40  * @file
    41  * @brief a small class to get the parts of a string separated by commas
    42  *
    43  * This class is also identified as a Tokenizer. It splits up one long
    44  * String into multiple small ones by a designated Delimiter.
    45  *
    46  * Substring is Advanced, and it is possible, to split a string by ','
    47  * but also removing leading and trailing spaces around the comma.
    48  *
    49  * @example
    50  * Split the String std::string st = "1345, The new empire   , is , orxonox"
    51  * is splitted with:
    52  * SubString(st, ',', " \n\t")
    53  * into
    54  * "1345", "The new empire", "is", "orxonox"
    55  * As you can see, the useless spaces around ',' were removed.
    56  */
     39 /**
     40    @file
     41    @ingroup String
     42    @brief A helper class to split a string into several tokens.
     43
     44    @anchor SubStringExample
     45
     46    The class SubString can be used to split an std::string into multiple tokens, using
     47    a delimiter. SubString allows different options, for example to remove whitespaces
     48    around the delimiters or different safe-mode chars, like quotation marks and braces.
     49
     50    You can access the tokens of the SubString using the [] operator like an array.
     51    SubString also supports to join the tokens (or a subset of the tokens) again using
     52    @ref orxonox::SubString::join() "join()". It's even possible to get a subset of the
     53    SubString as another SubString using @ref orxonox::SubString::subSet() "subSet()".
     54
     55    Example:
     56    @code
     57    std::string text = "This is a test, \"Hello \\\" World\" and vector {1, 2, 3}";
     58    SubString tokens(text, SubString::WhiteSpaces, "", false, '\\', true, '"', true, '{', '}', true, '\0');
     59
     60    for (unsigned int i = 0; i < tokens.size(); ++i)
     61        COUT(0) << i << ": " << tokens[i] << std::endl;
     62    @endcode
     63
     64    The output of this code is:
     65     - 0: This
     66     - 1: is
     67     - 2: a
     68     - 3: test,
     69     - 4: Hello " World
     70     - 5: and
     71     - 6: vector
     72     - 7: 1, 2, 3
     73
     74    The string was split using the delimiter " ". A string between quotation mark is not
     75    split, the same holds for strings between '{' and '}'. Note how the quotation marks and
     76    the braces were removed from the tokens, because the corresponding argument is 'true'.
     77
     78    Also note that the comma after "test" in token 3 is still there - it is neither part of the
     79    delimiters SubString::WhiteSpaces nor part of the delimiterNeighbours parameter, so it
     80    remains a part of the token.
     81*/
    5782
    5883#ifndef __SubString_H__
     
    6691namespace orxonox
    6792{
    68     //! A class that can load one string and split it in multipe ones
    6993    /**
    70      * SubString is a very Powerfull way to create a SubSet from a String
    71      * It can be used, to Split strings append them and join them again.
    72      */
     94        @brief A class that splits a string into multiple tokens using different options.
     95
     96        The string is split into multiple tokens using a delimiter. Different options like
     97        escape character, quotation marks, and more can be used to satisfy your needs.
     98
     99        See @ref SubStringExample "this description" for an example.
     100    */
    73101    class _UtilExport SubString
    74102    {
    75     public:
    76         //! An enumerator for the State the Parser is in
    77         typedef enum {
     103        /// An enumerator for the internal state of the parser
     104        enum SPLIT_LINE_STATE
     105        {
    78106            SL_NORMAL,            //!< Normal state
    79107            SL_ESCAPE,            //!< After an escape character
    80             SL_SAFEMODE,          //!< In safe mode (between "" mostly).
     108            SL_SAFEMODE,          //!< In safe mode (usually between quotation marks).
    81109            SL_SAFEESCAPE,        //!< In safe mode with the internal escape character, that escapes even the savemode character.
    82110            SL_COMMENT,           //!< In Comment mode.
    83111            SL_PARENTHESES,       //!< Between parentheses (usually '{' and '}')
    84112            SL_PARENTHESESESCAPE, //!< Between parentheses with the internal escape character, that escapes even the closing paranthesis character.
    85         } SPLIT_LINE_STATE;
    86 
     113        };
    87114
    88115    public:
    89116        SubString();
    90         SubString(const std::string& string, char delimiter = ',');
    91         SubString(const std::string& string,
    92                   const std::string& delimiters, const std::string& delimiterNeighbours = "", bool emptyEntries=false,
    93                   char escapeChar ='\\', bool removeEscapeChar = true, char safemode_char = '"', bool removeSafemodeChar = true,
    94                   char openparenthesis_char = '{', char closeparenthesis_char = '}',  bool removeParenthesisChars = true, char comment_char = '\0');
     117        SubString(const std::string& line,
     118                  const std::string& delimiters = SubString::WhiteSpaces,
     119                  const std::string& delimiterNeighbours = "",
     120                  bool bAllowEmptyEntries=false,
     121                  char escapeChar ='\\',
     122                  bool bRemoveEscapeChar = true,
     123                  char safemodeChar = '"',
     124                  bool bRemoveSafemodeChar = true,
     125                  char openparenthesisChar = '{',
     126                  char closeparenthesisChar = '}',
     127                  bool bRemoveParenthesisChars = true,
     128                  char commentChar = '\0');
    95129        SubString(unsigned int argc, const char** argv);
    96         /** @brief create a Substring as a copy of another one. @param subString the SubString to copy. */
    97         SubString(const SubString& subString) { *this = subString; };
    98         SubString(const SubString& subString, unsigned int subSetBegin);
    99         SubString(const SubString& subString, unsigned int subSetBegin, unsigned int subSetEnd);
     130        SubString(const SubString& other, unsigned int begin);
     131        SubString(const SubString& other, unsigned int begin, unsigned int end);
    100132        ~SubString();
    101133
    102134        // operate on the SubString
    103         SubString& operator=(const SubString& subString);
    104         bool operator==(const SubString& subString) const;
    105         bool compare(const SubString& subString) const;
    106         bool compare(const SubString& subString, unsigned int length) const;
    107         SubString operator+(const SubString& subString) const;
    108         SubString& operator+=(const SubString& subString);
    109         /** @param subString the String to append @returns appended String. @brief added for convenience */
    110         SubString& append(const SubString subString) { return (*this += subString); };
     135        SubString& operator=(const SubString& other);
     136        bool operator==(const SubString& other) const;
     137        bool compare(const SubString& other) const;
     138        bool compare(const SubString& other, unsigned int length) const;
     139        SubString operator+(const SubString& other) const;
     140        SubString& operator+=(const SubString& other);
     141        /// Appends the tokens of another SubString to this. @return This SubString.
     142        inline SubString& append(const SubString& other) { return (*this += other); }
    111143
    112144        /////////////////////////////////////////
    113145        // Split and Join the any String. ///////
    114         unsigned int split(const std::string& string = "", char delimiter = ',');
    115         unsigned int split(const std::string& string,
    116                            const std::string& delimiters, const std::string& delimiterNeighbours = "", bool emptyEntries = false,
    117                            char escapeChar ='\\', bool removeExcapeChar = true, char safemode_char = '"', bool removeSafemodeChar = true,
    118                            char openparenthesis_char = '{', char closeparenthesis_char = '}',  bool removeParenthesisChars = true, char comment_char = '\0');
     146        unsigned int split(const std::string& line,
     147                           const std::string& delimiters = SubString::WhiteSpaces,
     148                           const std::string& delimiterNeighbours = "",
     149                           bool bAllowEmptyEntries = false,
     150                           char escapeChar ='\\',
     151                           bool bRemoveEscapeChar = true,
     152                           char safemodeChar = '"',
     153                           bool bRemoveSafemodeChar = true,
     154                           char openparenthesisChar = '{',
     155                           char closeparenthesisChar = '}',
     156                           bool bRemoveParenthesisChars = true,
     157                           char commentChar = '\0');
     158
    119159        std::string join(const std::string& delimiter = " ") const;
    120160        ////////////////////////////////////////
    121161
    122162        // retrieve a SubSet from the String
    123         SubString subSet(unsigned int subSetBegin) const;
    124         SubString subSet(unsigned int subSetBegin, unsigned int subSetEnd) const;
     163        SubString subSet(unsigned int begin) const;
     164        SubString subSet(unsigned int begin, unsigned int end) const;
    125165
    126166        // retrieve Information from within
    127         /** @brief Returns true if the SubString is empty */
    128         inline bool empty() const { return this->strings.empty(); };
    129         /** @brief Returns the count of Strings stored in this substring */
    130         inline unsigned int size() const { return this->strings.size(); };
    131         /** @brief Returns the i'th string from the subset of Strings @param i the i'th String */
    132         inline const std::string& operator[](unsigned int i) const { return this->strings[i]; };
    133         /** @brief Returns the i'th string from the subset of Strings @param i the i'th String */
    134         inline const std::string& getString(unsigned int i) const { return (*this)[i]; };
    135         /** @brief Returns all Strings as std::vector */
    136         inline const std::vector<std::string>& getAllStrings() const { return this->strings; }
    137         /** @brief Returns true if the token is in safemode. @param i the i'th token */
    138         inline bool isInSafemode(unsigned int i) const { return this->bInSafemode[i]; }
    139         /** @brief Returns the front of the StringList. */
    140         inline const std::string& front() const { return this->strings.front(); };
    141         /** @brief Returns the back of the StringList. */
    142         inline const std::string& back() const { return this->strings.back(); };
    143         /** @brief removes the back of the strings list. */
    144         inline void pop_back() { this->strings.pop_back(); this->bInSafemode.pop_back(); };
    145 
     167        /// Returns true if the SubString is empty
     168        inline bool empty() const { return this->tokens_.empty(); }
     169        /// Returns the number of tokens stored in this SubString
     170        inline unsigned int size() const { return this->tokens_.size(); }
     171        /// Returns the i'th token from the subset of strings @param index The index of the requested doken
     172        inline const std::string& operator[](unsigned int index) const { return this->tokens_[index]; }
     173        /// Returns the i'th token from the subset of strings @param index The index of the requested token
     174        inline const std::string& getString(unsigned int index) const { return (*this)[index]; }
     175        /// Returns all tokens as std::vector
     176        inline const std::vector<std::string>& getAllStrings() const { return this->tokens_; }
     177        /// Returns true if the token is in safemode. @param index The index of the token
     178        inline bool isInSafemode(unsigned int index) const { return this->bTokenInSafemode_[index]; }
     179        /// Returns the front of the list of tokens.
     180        inline const std::string& front() const { return this->tokens_.front(); }
     181        /// Returns the back of the list of tokens.
     182        inline const std::string& back() const { return this->tokens_.back(); }
     183        /// Removes the back of the list of tokens.
     184        inline void pop_back() { this->tokens_.pop_back(); this->bTokenInSafemode_.pop_back(); }
     185
     186        void debug() const;
     187
     188    public:
     189        static const std::string WhiteSpaces;           ///< All whitespaces (usually used as delimiters or delimiterNeighbours
     190        static const std::string WhiteSpacesWithComma;  ///< All whitespaces and the comma (usually used as delimiters)
     191        static const SubString   NullSubString;         ///< An empty SubString
     192
     193    private:
    146194        // the almighty algorithm.
    147         static SPLIT_LINE_STATE splitLine(std::vector<std::string>& ret,
    148                                           std::vector<bool>& bInSafemode,
     195        static SPLIT_LINE_STATE splitLine(std::vector<std::string>& tokens,
     196                                          std::vector<bool>& bTokenInSafemode,
    149197                                          const std::string& line,
    150198                                          const std::string& delimiters = SubString::WhiteSpaces,
    151199                                          const std::string& delimiterNeighbours = "",
    152                                           bool emptyEntries = false,
    153                                           char escape_char = '\\',
    154                                           bool removeExcapeChar = true,
    155                                           char safemode_char = '"',
    156                                           bool removeSafemodeChar = true,
    157                                           char openparenthesis_char = '{',
    158                                           char closeparenthesis_char = '}',
    159                                           bool removeParenthesisChars = true,
    160                                           char comment_char = '\0',
     200                                          bool bAllowEmptyEntries = false,
     201                                          char escapeChar = '\\',
     202                                          bool bRemoveEscapeChar = true,
     203                                          char safemodeChar = '"',
     204                                          bool bRemoveSafemodeChar = true,
     205                                          char openparenthesisChar = '{',
     206                                          char closeparenthesisChar = '}',
     207                                          bool bRemoveParenthesisChars = true,
     208                                          char commentChar = '\0',
    161209                                          SPLIT_LINE_STATE start_state = SL_NORMAL);
    162         // debugging.
    163         void debug() const;
    164 
    165     public:
    166         static const std::string WhiteSpaces;
    167         static const std::string WhiteSpacesWithComma;
    168         static const SubString   NullSubString;
    169 
    170     private:
    171         std::vector<std::string>  strings;                      //!< strings produced from a single string splitted in multiple strings
    172         std::vector<bool>         bInSafemode;
     210
     211        std::vector<std::string>  tokens_;              ///< The tokens after spliting the input line
     212        std::vector<bool>         bTokenInSafemode_;    ///< Saves for each token if it was in safe mode (between quotation marks or parenthesis)
    173213    };
    174214}
  • code/trunk/src/libraries/util/TriBool.h

    r6746 r7401  
    2727 */
    2828
     29/**
     30    @file
     31    @ingroup Util
     32*/
     33
    2934#ifndef _TriBool_H__
    3035#define _TriBool_H__
     
    3540namespace orxonox
    3641{
     42    /** Sort of a boolean value that also has state \c Dontcare
     43    @remarks
     44        Even though \c False has the value 0, both \c True and \c Dontcare have
     45        a value other than 0. Keep that in mind when using TriBools in if statements.
     46    */
    3747    namespace TriBool
    3848    {
  • code/trunk/src/libraries/util/VA_NARGS.h

    r7284 r7401  
    2929/**
    3030    @file
     31    @ingroup Util
    3132    @brief Declaration of the ORXONOX_VA_NARGS macro which returns the number of arguments passed to a variadic macro.
     33
     34    With this utility you can overload a macro for different numbers of arguments
     35    (of course overloading is not possible for different types, as macros are not
     36    type aware, but for different numbers of arguments is still very powerful).
     37
     38    Example: A macro to call functions
     39    @code
     40    myfunction();                                           // A static function
     41    MyClass::myStaticFunction();                            // A static class function
     42    MyClass::myFunction();                                  // A member function
     43
     44    #define CallFunction(...) \                             // Define a variadic macro that passes the arguments to the overloaded implementations
     45        BOOST_PP_EXPAND(BOOST_PP_CAT(CallFunction, ORXONOX_VA_NARGS(__VA_ARGS__))(__VA_ARGS__))
     46
     47    #define CallFunction1(function) \                       // Overloaded macro for 1 argument
     48        function()                                          // Calls the static function
     49
     50    #define CallFunction2(class, function) \                // Overloaded macro for 2 arguments
     51        class::function()                                   // Calls the static class function
     52
     53    #define CallFunction3(class, function, object) \        // Overloaded macro for 3 arguments
     54        object->class::function()                           // Calls the function on the object
     55
     56
     57    CallFunction(myFunction);                               // Call the macro with 1 argument
     58    CallFunction(MyClass, myStaticFunction);                // Call the macro with 2 arguments
     59    CallFunction(MyClass, myFunction, new MyClass());       // Call the macro with 3 arguments
     60    @endcode
     61
     62    Note that the first (variadic) macro concatenates the name "CallFunction" with
     63    the number of arguments ("1" - "N"). Then all arguments are passed to the right macro.
    3264*/
    3365
  • code/trunk/src/libraries/util/mbool.h

    r7268 r7401  
    2727 */
    2828
     29/**
     30    @file
     31    @ingroup Util
     32    @brief Declaration and implementation of the @ref orxonox::mbool class.
     33*/
     34
    2935#ifndef _mbool_H__
    3036#define _mbool_H__
     
    3440namespace orxonox
    3541{
     42    /**
     43        @brief mbool is a small helper class that acts like a bool, but keeps track of the number of its state changes.
     44
     45        The mbool class acts like a bool, but it has an internal counter that counts
     46        the number state changes (i.e. when the bool changes from true to false or
     47        back). This is used in the network if a boolean value is synchronized, because
     48        if a value changes quickly from false to true and back in the same tick, the
     49        clients will never be notified of this action. By using mbool however this
     50        behaviour is fixed, which is important for triggers and other objects.
     51
     52        @note This is efficiently solved by using a union that combines a counter and a
     53        boolean bitfield of size 1. The boolean value corresponds always to the first
     54        bit of the counter - this means, if the counter is incremented, the boolean state
     55        changes. On the other hand, if you want to change the state, you can simply increase
     56        the counter.
     57    */
    3658    struct _UtilExport mbool
    3759    {
    3860        public:
     61            /// Constructor: Creates the mbool and initializes the boolean value (default to false).
    3962            inline mbool(bool value = false)
    4063                { this->value_.memory_ = 0; this->value_.bool_ = value; }
     64            /// Copy-constructor, copies state and memory.
    4165            inline mbool(const mbool& value)
    4266                { this->value_.memory_ = value.value_.memory_; }
    4367
     68            /// Assigns a boolean value (and increases the memory value if the value is different to the old value).
    4469            inline mbool& operator=(bool value)
    4570                { if (value != this->value_.bool_) { ++this->value_.memory_; } return (*this); }
     71            /// Assigns another mbool, copies state and memory.
    4672            inline mbool& operator=(const mbool& value)
    4773                { this->value_.memory_ = value.value_.memory_; return (*this); }
    4874
     75            /// Increases the memory which also inverts it's state (++mbool).
    4976            inline mbool& operator++()
    5077                { ++this->value_.memory_; return (*this); }
    51             inline mbool operator++(int i)
     78            /// Increases the memory which also inverts it's state (mbool++).
     79            inline mbool operator++(int)
    5280                { mbool temp = (*this); ++this->value_.memory_; return temp; }
    5381
     82            /// Implicitly converts the mbool to a bool.
    5483            inline operator bool() const
    5584                { return this->value_.bool_; }
    5685
     86            /// Compares the mbool to a bool, returns true if the bool has the same value as the state of the mbool.
    5787            inline bool operator==(bool other) const
    5888                { return this->value_.bool_ == other; }
     89            /// Compares the mbool to a bool, returns true if the bool has a different value than the state of the mbool.
    5990            inline bool operator!=(bool other) const
    6091                { return this->value_.bool_ != other; }
    6192
     93            /// Compares two mbools, returns true if their memory matches.
    6294            inline bool operator==(const mbool& other) const
    6395                { return this->value_.memory_ == other.value_.memory_; }
     96            /// Compares two mbools, returns true if they have a different memory value.
    6497            inline bool operator!=(const mbool& other) const
    6598                { return this->value_.memory_ != other.value_.memory_; }
    6699
     100            /// Returns the inverted state of the bool (doesn't change the internal state).
    67101            inline bool operator!() const
    68102                { return (!this->value_.bool_); }
    69103
     104            /// Returns the memory value.
    70105            inline unsigned char& getMemory(){ return value_.memory_; }
    71106
     
    73108            union
    74109            {
    75                 bool bool_ : 1;
    76                 unsigned char memory_;
    77             } value_;
     110                bool bool_ : 1;         ///< The boolean state of the mbool, is located on the first bit of the memory variable
     111                unsigned char memory_;  ///< The memory of the mbool, counts the state-changes (and the first bit represents also the boolean value)
     112            } value_;                   ///< A union containing the state and the memory of the mbool
    78113    };
    79114}
Note: See TracChangeset for help on using the changeset viewer.