Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1716 for code/branches


Ignore:
Timestamp:
Sep 6, 2008, 4:21:56 PM (16 years ago)
Author:
landauf
Message:

Added new 'MultiType', replacing MultiTypePrimitive, MultiTypeString and MultiTypeMath. MultiType can hold all types MultiTypeMath was able to hold, namely all primitives, pointers, string and several math objects (vector2, 3 and 4, quaternion, colourvalue, radian, degree).

The new MultiType has a completely changed behaviour, I'll explain this on a wiki page somewhen.
But to say the most important things in a few words:
The MultiType has a fixed type. This type is determined by the first assigned value (by using setValue(value), operator=(value) or MultiType(value)). Every other value getting assigned later, will be converted to the first type. But you can change the type (setType<T>()), convert the value (convert<T>()) or force the type of a newly assigned value manually (setValue<T>(value)) by using template functions.

In contrast, the old MultiTypeMath changed it's internal type whenever a new type was assigned. So be aware of this important change.

At the moment I can't see any issues, but there might very well be several problems yet to discover, so further tests will be done.

Location:
code/branches/core3/src
Files:
2 added
6 deleted
15 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core3/src/core/CommandEvaluation.cc

    r1586 r1716  
    218218    }
    219219
    220     void CommandEvaluation::setEvaluatedParameter(unsigned int index, MultiTypeMath param)
     220    void CommandEvaluation::setEvaluatedParameter(unsigned int index, MultiType param)
    221221    {
    222222        if (index >= 0 && index < MAX_FUNCTOR_ARGUMENTS)
     
    224224    }
    225225
    226     MultiTypeMath CommandEvaluation::getEvaluatedParameter(unsigned int index) const
     226    MultiType CommandEvaluation::getEvaluatedParameter(unsigned int index) const
    227227    {
    228228        if (index >= 0 && index < MAX_FUNCTOR_ARGUMENTS)
     
    240240    }
    241241
    242     MultiTypeMath CommandEvaluation::getReturnvalue() const
     242    MultiType CommandEvaluation::getReturnvalue() const
    243243    {
    244244        if (this->function_)
    245245            return this->function_->getReturnvalue();
    246246
    247         return MultiTypeMath();
     247        return MultiType();
    248248    }
    249249
  • code/branches/core3/src/core/CommandEvaluation.h

    r1505 r1716  
    3737#include "ArgumentCompletionListElement.h"
    3838#include "util/SubString.h"
    39 #include "util/MultiTypeMath.h"
     39#include "util/MultiType.h"
    4040
    4141namespace orxonox
     
    8181                { return (this->additionalParameter_ != "") ? (" " + this->additionalParameter_) : ""; }
    8282
    83             void setEvaluatedParameter(unsigned int index, MultiTypeMath param);
    84             MultiTypeMath getEvaluatedParameter(unsigned int index) const;
     83            void setEvaluatedParameter(unsigned int index, MultiType param);
     84            MultiType getEvaluatedParameter(unsigned int index) const;
    8585
    8686            bool hasReturnvalue() const;
    87             MultiTypeMath getReturnvalue() const;
     87            MultiType getReturnvalue() const;
    8888
    8989        private:
     
    115115
    116116            bool bEvaluatedParams_;
    117             MultiTypeMath param_[5];
     117            MultiType param_[5];
    118118    };
    119119}
  • code/branches/core3/src/core/ConfigValueContainer.cc

    r1658 r1716  
    6464        @brief Does some special initialization for single config-values.
    6565    */
    66     void ConfigValueContainer::initValue(const MultiTypeMath& defvalue)
     66    void ConfigValueContainer::initValue(const MultiType& defvalue)
    6767    {
    6868        this->value_ = defvalue;
     
    8282        for (unsigned int i = 0; i < this->valueVector_.size(); i++)
    8383        {
    84             ConfigFileManager::getInstance()->getValue(this->type_, this->sectionname_, this->varname_, i, this->valueVector_[i].toString(), this->value_.isA(MT_string));
    85             this->defvalueStringVector_.push_back(this->valueVector_[i].toString());
     84            ConfigFileManager::getInstance()->getValue(this->type_, this->sectionname_, this->varname_, i, this->valueVector_[i], this->value_.isType(MT_string));
     85            this->defvalueStringVector_.push_back(this->valueVector_[i]);
    8686        }
    8787
     
    103103        @return True if the new value was successfully assigned
    104104    */
    105     bool ConfigValueContainer::set(const MultiTypeMath& input)
    106     {
    107         if (this->bIsVector_)
    108         {
    109             return this->callFunctionWithIndex(&ConfigValueContainer::set, input.toString());
     105    bool ConfigValueContainer::set(const MultiType& input)
     106    {
     107        if (this->bIsVector_)
     108        {
     109            return this->callFunctionWithIndex(&ConfigValueContainer::set, input);
    110110        }
    111111        else
     
    113113            if (this->tset(input))
    114114            {
    115                 ConfigFileManager::getInstance()->setValue(this->type_, this->sectionname_, this->varname_, input.toString(), this->value_.isA(MT_string));
     115                ConfigFileManager::getInstance()->setValue(this->type_, this->sectionname_, this->varname_, input, this->value_.isType(MT_string));
    116116                return true;
    117117            }
     
    126126        @return True if the new value was successfully assigned
    127127    */
    128     bool ConfigValueContainer::set(unsigned int index, const MultiTypeMath& input)
     128    bool ConfigValueContainer::set(unsigned int index, const MultiType& input)
    129129    {
    130130        if (this->bIsVector_)
     
    132132            if (this->tset(index, input))
    133133            {
    134                 ConfigFileManager::getInstance()->setValue(this->type_, this->sectionname_, this->varname_, index, input.toString(), this->value_.isA(MT_string));
     134                ConfigFileManager::getInstance()->setValue(this->type_, this->sectionname_, this->varname_, index, input, this->value_.isType(MT_string));
    135135                return true;
    136136            }
     
    148148        @return True if the new value was successfully assigned
    149149    */
    150     bool ConfigValueContainer::tset(const MultiTypeMath& input)
    151     {
    152         if (this->bIsVector_)
    153         {
    154             return this->callFunctionWithIndex(&ConfigValueContainer::tset, input.toString());
    155         }
    156         else
    157         {
    158             MultiTypeMath temp = this->value_;
    159             if (temp.assimilate(input))
    160             {
    161                 this->value_ = temp;
     150    bool ConfigValueContainer::tset(const MultiType& input)
     151    {
     152        if (this->bIsVector_)
     153        {
     154            return this->callFunctionWithIndex(&ConfigValueContainer::tset, input);
     155        }
     156        else
     157        {
     158//            MultiType temp = this->value_;
     159//            if (temp.assimilate(input))
     160//            {
     161//                this->value_ = temp;
     162                this->value_ = input;
    162163                if (this->identifier_)
    163164                    this->identifier_->updateConfigValues();
    164165
    165166                return true;
    166             }
     167//            }
    167168        }
    168169        return false;
     
    175176        @return True if the new value was successfully assigned
    176177    */
    177     bool ConfigValueContainer::tset(unsigned int index, const MultiTypeMath& input)
     178    bool ConfigValueContainer::tset(unsigned int index, const MultiType& input)
    178179    {
    179180        if (this->bIsVector_)
     
    189190                for (unsigned int i = this->valueVector_.size(); i <= index; i++)
    190191                {
    191                     this->valueVector_.push_back(MultiTypeMath());
     192                    this->valueVector_.push_back(MultiType());
    192193                }
    193194            }
    194195
    195             MultiTypeMath temp = this->value_;
    196             if (temp.assimilate(input))
    197             {
    198                 this->valueVector_[index] = temp;
     196//            MultiType temp = this->value_;
     197//            if (temp.assimilate(input))
     198//            {
     199//                this->valueVector_[index] = temp;
     200                this->valueVector_[index] = input;
    199201
    200202                if (this->identifier_)
     
    202204
    203205                return true;
    204             }
     206//            }
    205207        }
    206208        else
     
    216218        @return True if the new entry was successfully added
    217219    */
    218     bool ConfigValueContainer::add(const MultiTypeMath& input)
     220    bool ConfigValueContainer::add(const MultiType& input)
    219221    {
    220222        if (this->bIsVector_)
     
    239241                this->valueVector_.erase(this->valueVector_.begin() + index);
    240242                for (unsigned int i = index; i < this->valueVector_.size(); i++)
    241                     ConfigFileManager::getInstance()->setValue(this->type_, this->sectionname_, this->varname_, i, this->valueVector_[i], this->value_.isA(MT_string));
     243                    ConfigFileManager::getInstance()->setValue(this->type_, this->sectionname_, this->varname_, i, this->valueVector_[i], this->value_.isType(MT_string));
    242244                ConfigFileManager::getInstance()->deleteVectorEntries(this->type_, this->sectionname_, this->varname_, this->valueVector_.size());
    243245
     
    275277    {
    276278        if (!this->bIsVector_)
    277             this->value_.fromString(ConfigFileManager::getInstance()->getValue(this->type_, this->sectionname_, this->varname_, this->defvalueString_, this->value_.isA(MT_string)));
     279            this->value_ = ConfigFileManager::getInstance()->getValue(this->type_, this->sectionname_, this->varname_, this->defvalueString_, this->value_.isType(MT_string));
    278280        else
    279281        {
     
    283285                if (i < this->defvalueStringVector_.size())
    284286                {
    285                     this->value_.fromString(ConfigFileManager::getInstance()->getValue(this->type_, this->sectionname_, this->varname_, i, this->defvalueStringVector_[i], this->value_.isA(MT_string)));
     287                    this->value_ = ConfigFileManager::getInstance()->getValue(this->type_, this->sectionname_, this->varname_, i, this->defvalueStringVector_[i], this->value_.isType(MT_string));
    286288                }
    287289                else
    288290                {
    289                     this->value_.fromString(ConfigFileManager::getInstance()->getValue(this->type_, this->sectionname_, this->varname_, i, MultiTypeMath(), this->value_.isA(MT_string)));
     291                    this->value_ = ConfigFileManager::getInstance()->getValue(this->type_, this->sectionname_, this->varname_, i, MultiType(), this->value_.isType(MT_string));
    290292                }
    291293
     
    301303        @return The returnvalue of the functioncall
    302304    */
    303     bool ConfigValueContainer::callFunctionWithIndex(bool (ConfigValueContainer::* function) (unsigned int, const MultiTypeMath&), const std::string& input)
     305    bool ConfigValueContainer::callFunctionWithIndex(bool (ConfigValueContainer::* function) (unsigned int, const MultiType&), const std::string& input)
    304306    {
    305307        SubString token(input, " ", SubString::WhiteSpaces, true, '\\', false, '"', false, '(', ')', false, '\0');
  • code/branches/core3/src/core/ConfigValueContainer.h

    r1611 r1716  
    5050
    5151#include "util/Math.h"
    52 #include "util/MultiTypeMath.h"
     52#include "util/MultiType.h"
    5353#include "ConfigFileManager.h"
    5454
     
    124124                this->value_ = V();
    125125                for (unsigned int i = 0; i < defvalue.size(); i++)
    126                     this->valueVector_.push_back(MultiTypeMath(defvalue[i]));
     126                    this->valueVector_.push_back(MultiType(defvalue[i]));
    127127
    128128                this->initVector();
     
    247247            }
    248248
    249             bool set(const MultiTypeMath& input);
    250             bool tset(const MultiTypeMath& input);
    251 
    252             bool set(unsigned int index, const MultiTypeMath& input);
    253             bool tset(unsigned int index, const MultiTypeMath& input);
    254             bool add(const MultiTypeMath& input);
     249            bool set(const MultiType& input);
     250            bool tset(const MultiType& input);
     251
     252            bool set(unsigned int index, const MultiType& input);
     253            bool tset(unsigned int index, const MultiType& input);
     254            bool add(const MultiType& input);
    255255            bool remove(unsigned int index);
    256256
     
    260260            /** @brief Converts the config-value to a string. @return The string */
    261261            inline std::string toString() const
    262                 { return this->value_.toString(); }
     262                { return this->value_; }
    263263            /** @brief Returns the typename of the assigned config-value. @return The typename */
    264264            inline std::string getTypename() const
     
    267267        private:
    268268            void init(ConfigFileType type, Identifier* identifier, const std::string& varname);
    269             void initValue(const MultiTypeMath& defvalue);
     269            void initValue(const MultiType& defvalue);
    270270            void initVector();
    271             bool callFunctionWithIndex(bool (ConfigValueContainer::* function) (unsigned int, const MultiTypeMath&), const std::string& input);
     271            bool callFunctionWithIndex(bool (ConfigValueContainer::* function) (unsigned int, const MultiType&), const std::string& input);
    272272
    273273            bool                       bIsVector_;                  //!< True if the container contains a std::vector
     
    280280            std::vector<std::string>   defvalueStringVector_;       //!< A vector, containg the strings of the default-values in case we're storing a vector
    281281
    282             MultiTypeMath              value_;                      //!< The value
    283             std::vector<MultiTypeMath> valueVector_;                //!< A vector, containg the values in case we're storing a vector
     282            MultiType                  value_;                      //!< The value
     283            std::vector<MultiType>    valueVector_;                //!< A vector, containg the values in case we're storing a vector
    284284
    285285            bool                       bAddedDescription_;          //!< True if a description was added
  • code/branches/core3/src/core/ConsoleCommand.h

    r1594 r1716  
    9393            inline ConsoleCommand& descriptionReturnvalue(const std::string& description)
    9494                { this->ExecutorStatic::setDescriptionReturnvalue(description); return (*this); }
    95             inline ConsoleCommand& defaultValues(const MultiTypeMath& param1)
     95            inline ConsoleCommand& defaultValues(const MultiType& param1)
    9696                { this->ExecutorStatic::setDefaultValues(param1); return (*this); }
    97             inline ConsoleCommand& defaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2)
     97            inline ConsoleCommand& defaultValues(const MultiType& param1, const MultiType& param2)
    9898                { this->ExecutorStatic::setDefaultValues(param1, param2); return (*this); }
    99             inline ConsoleCommand& defaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3)
     99            inline ConsoleCommand& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3)
    100100                { this->ExecutorStatic::setDefaultValues(param1, param2, param3); return (*this); }
    101             inline ConsoleCommand& defaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4)
     101            inline ConsoleCommand& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4)
    102102                { this->ExecutorStatic::setDefaultValues(param1, param2, param3, param4); return (*this); }
    103             inline ConsoleCommand& defaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4, const MultiTypeMath& param5)
     103            inline ConsoleCommand& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5)
    104104                { this->ExecutorStatic::setDefaultValues(param1, param2, param3, param4, param5); return (*this); }
    105             inline ConsoleCommand& defaultValue(unsigned int index, const MultiTypeMath& param)
     105            inline ConsoleCommand& defaultValue(unsigned int index, const MultiType& param)
    106106                { this->ExecutorStatic::setDefaultValue(index, param); return (*this); }
    107107
  • code/branches/core3/src/core/Executor.cc

    r1505 r1716  
    6565    }
    6666
    67     bool Executor::evaluate(const std::string& params, MultiTypeMath param[5], const std::string& delimiter) const
     67    bool Executor::evaluate(const std::string& params, MultiType param[5], const std::string& delimiter) const
    6868    {
    6969        unsigned int paramCount = this->functor_->getParamCount();
     
    171171    }
    172172
    173     Executor& Executor::setDefaultValues(const MultiTypeMath& param1)
    174     {
    175         this->defaultValue_[0] = param1;
    176         this->bAddedDefaultValue_[0] = true;
    177 
    178         return (*this);
    179     }
    180 
    181     Executor& Executor::setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2)
    182     {
    183         this->defaultValue_[0] = param1;
    184         this->bAddedDefaultValue_[0] = true;
    185         this->defaultValue_[1] = param2;
    186         this->bAddedDefaultValue_[1] = true;
    187 
    188         return (*this);
    189     }
    190 
    191     Executor& Executor::setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3)
     173    Executor& Executor::setDefaultValues(const MultiType& param1)
     174    {
     175        this->defaultValue_[0] = param1;
     176        this->bAddedDefaultValue_[0] = true;
     177
     178        return (*this);
     179    }
     180
     181    Executor& Executor::setDefaultValues(const MultiType& param1, const MultiType& param2)
     182    {
     183        this->defaultValue_[0] = param1;
     184        this->bAddedDefaultValue_[0] = true;
     185        this->defaultValue_[1] = param2;
     186        this->bAddedDefaultValue_[1] = true;
     187
     188        return (*this);
     189    }
     190
     191    Executor& Executor::setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3)
    192192    {
    193193        this->defaultValue_[0] = param1;
     
    201201    }
    202202
    203     Executor& Executor::setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4)
     203    Executor& Executor::setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4)
    204204    {
    205205        this->defaultValue_[0] = param1;
     
    215215    }
    216216
    217     Executor& Executor::setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4, const MultiTypeMath& param5)
     217    Executor& Executor::setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5)
    218218    {
    219219        this->defaultValue_[0] = param1;
     
    231231    }
    232232
    233     Executor& Executor::setDefaultValue(unsigned int index, const MultiTypeMath& param)
     233    Executor& Executor::setDefaultValue(unsigned int index, const MultiType& param)
    234234    {
    235235        if (index >= 0 && index < MAX_FUNCTOR_ARGUMENTS)
  • code/branches/core3/src/core/Executor.h

    r1586 r1716  
    6464        { \
    6565            COUT(5) << "Calling Executor " << this->name_ << " through parser with one parameter, using whole string: " << params << std::endl; \
    66             EXECUTOR_PARSE_FUNCTORCALL(mode)(EXECUTOR_PARSE_OBJECT(mode, 1) MultiTypeMath(params)); \
     66            EXECUTOR_PARSE_FUNCTORCALL(mode)(EXECUTOR_PARSE_OBJECT(mode, 1) MultiType(params)); \
    6767        } \
    6868        else if (this->bAddedDefaultValue_[0]) \
     
    9090        } \
    9191        \
    92         MultiTypeMath param[MAX_FUNCTOR_ARGUMENTS]; \
     92        MultiType param[MAX_FUNCTOR_ARGUMENTS]; \
    9393        COUT(5) << "Calling Executor " << this->name_ << " through parser with " << paramCount << " parameters, using " << tokens.size() << " tokens ("; \
    9494        for (unsigned int i = 0; i < tokens.size() && i < MAX_FUNCTOR_ARGUMENTS; i++) \
     
    145145            inline void operator()() const
    146146                { (*this->functor_)(this->defaultValue_[0], this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
    147             inline void operator()(const MultiTypeMath& param1) const
     147            inline void operator()(const MultiType& param1) const
    148148                { (*this->functor_)(param1, this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
    149             inline void operator()(const MultiTypeMath& param1, const MultiTypeMath& param2) const
     149            inline void operator()(const MultiType& param1, const MultiType& param2) const
    150150                { (*this->functor_)(param1, param2, this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
    151             inline void operator()(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3) const
     151            inline void operator()(const MultiType& param1, const MultiType& param2, const MultiType& param3) const
    152152                { (*this->functor_)(param1, param2, param3, this->defaultValue_[3], this->defaultValue_[4]); }
    153             inline void operator()(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4) const
     153            inline void operator()(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4) const
    154154                { (*this->functor_)(param1, param2, param3, param4, this->defaultValue_[4]); }
    155             inline void operator()(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4, const MultiTypeMath& param5) const
     155            inline void operator()(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) const
    156156                { (*this->functor_)(param1, param2, param3, param4, param5); }
    157157
    158158            bool parse(const std::string& params, const std::string& delimiter = " ") const;
    159159
    160             bool evaluate(const std::string& params, MultiTypeMath param[5], const std::string& delimiter = " ") const;
     160            bool evaluate(const std::string& params, MultiType param[5], const std::string& delimiter = " ") const;
    161161
    162162            Executor& setDescription(const std::string& description);
     
    177177            inline FunctionType getType() const
    178178                { return this->functor_->getType(); }
    179             inline MultiTypeMath getReturnvalue() const
     179            inline MultiType getReturnvalue() const
    180180                { return this->functor_->getReturnvalue(); }
    181181            inline std::string getTypenameParam(unsigned int param) const
     
    189189                { return this->name_; }
    190190
    191             Executor& setDefaultValues(const MultiTypeMath& param1);
    192             Executor& setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2);
    193             Executor& setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3);
    194             Executor& setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4);
    195             Executor& setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4, const MultiTypeMath& param5);
    196             Executor& setDefaultValue(unsigned int index, const MultiTypeMath& param);
    197 
    198             inline MultiTypeMath getDefaultValue(unsigned int index) const
     191            Executor& setDefaultValues(const MultiType& param1);
     192            Executor& setDefaultValues(const MultiType& param1, const MultiType& param2);
     193            Executor& setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3);
     194            Executor& setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4);
     195            Executor& setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5);
     196            Executor& setDefaultValue(unsigned int index, const MultiType& param);
     197
     198            inline MultiType getDefaultValue(unsigned int index) const
    199199            {
    200200                if (index >= 0 && index < MAX_FUNCTOR_ARGUMENTS)
     
    216216            Functor* functor_;
    217217            std::string name_;
    218             MultiTypeMath defaultValue_[MAX_FUNCTOR_ARGUMENTS];
     218            MultiType defaultValue_[MAX_FUNCTOR_ARGUMENTS];
    219219            bool bAddedDefaultValue_[MAX_FUNCTOR_ARGUMENTS];
    220220
     
    245245            inline void operator()(T* object) const
    246246                { (*((FunctorMember<T>*)this->functor_))(object, this->defaultValue_[0], this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
    247             inline void operator()(T* object, const MultiTypeMath& param1) const
     247            inline void operator()(T* object, const MultiType& param1) const
    248248                { (*((FunctorMember<T>*)this->functor_))(object, param1, this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
    249             inline void operator()(T* object, const MultiTypeMath& param1, const MultiTypeMath& param2) const
     249            inline void operator()(T* object, const MultiType& param1, const MultiType& param2) const
    250250                { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
    251             inline void operator()(T* object, const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3) const
     251            inline void operator()(T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3) const
    252252                { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, this->defaultValue_[3], this->defaultValue_[4]); }
    253             inline void operator()(T* object, const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4) const
     253            inline void operator()(T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4) const
    254254                { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, param4, this->defaultValue_[4]); }
    255             inline void operator()(T* object, const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4, const MultiTypeMath& param5) const
     255            inline void operator()(T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) const
    256256                { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, param4, param5); }
    257257
     
    259259            inline void operator()(const T* object) const
    260260                { (*((FunctorMember<T>*)this->functor_))(object, this->defaultValue_[0], this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
    261             inline void operator()(const T* object, const MultiTypeMath& param1) const
     261            inline void operator()(const T* object, const MultiType& param1) const
    262262                { (*((FunctorMember<T>*)this->functor_))(object, param1, this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
    263             inline void operator()(const T* object, const MultiTypeMath& param1, const MultiTypeMath& param2) const
     263            inline void operator()(const T* object, const MultiType& param1, const MultiType& param2) const
    264264                { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
    265             inline void operator()(const T* object, const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3) const
     265            inline void operator()(const T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3) const
    266266                { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, this->defaultValue_[3], this->defaultValue_[4]); }
    267             inline void operator()(const T* object, const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4) const
     267            inline void operator()(const T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4) const
    268268                { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, param4, this->defaultValue_[4]); }
    269             inline void operator()(const T* object, const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4, const MultiTypeMath& param5) const
     269            inline void operator()(const T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) const
    270270                { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, param4, param5); }
    271271
  • code/branches/core3/src/core/Functor.h

    r1592 r1716  
    3333#include "CorePrereqs.h"
    3434
    35 #include "util/MultiTypeMath.h"
     35#include "util/MultiType.h"
    3636#include "util/Debug.h"
    3737
     
    9595            virtual ~Functor() {}
    9696
    97             virtual void operator()(const MultiTypeMath& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& param5 = MT_null) = 0;
     97            virtual void operator()(const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) = 0;
    9898
    9999            inline unsigned int getParamCount() const { return this->numParams_; }
    100100            inline bool hasReturnvalue() const { return this->hasReturnValue_; }
    101101            inline FunctionType getType() const { return this->type_; }
    102             inline MultiTypeMath getReturnvalue() const { return this->returnedValue_; }
     102            inline MultiType getReturnvalue() const { return this->returnedValue_; }
    103103
    104104            std::string getTypenameParam(unsigned int param) const { return (param >= 0 && param < 5) ? this->typeParam_[param] : ""; }
    105105            std::string getTypenameReturnvalue() const { return this->typeReturnvalue_; }
    106106
    107             virtual void evaluateParam(unsigned int index, MultiTypeMath& param) const = 0;
     107            virtual void evaluateParam(unsigned int index, MultiType& param) const = 0;
    108108
    109109        protected:
     
    111111            bool hasReturnValue_;
    112112            FunctionType type_;
    113             MultiTypeMath returnedValue_;
     113            MultiType returnedValue_;
    114114
    115115            std::string typeReturnvalue_;
     
    121121        public:
    122122            virtual ~FunctorStatic() {}
    123             virtual void operator()(const MultiTypeMath& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& param5 = MT_null) = 0;
     123            virtual void operator()(const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) = 0;
    124124    };
    125125
     
    136136            virtual ~FunctorMember() {}
    137137
    138             virtual void operator()(T* object, const MultiTypeMath& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& param5 = MT_null) = 0;
    139             virtual void operator()(const T* object, const MultiTypeMath& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& param5 = MT_null) = 0;
    140 
    141             virtual void operator()(const MultiTypeMath& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& param5 = MT_null)
     138            virtual void operator()(T* object, const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) = 0;
     139            virtual void operator()(const T* object, const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) = 0;
     140
     141            virtual void operator()(const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null)
    142142            {
    143143                if (this->bConstObject_)
     
    280280
    281281
    282 
     282/*
    283283#define FUNCTOR_EVALUATE_PARAM(numparams) FUNCTOR_EVALUATE_PARAM##numparams
    284284#define FUNCTOR_EVALUATE_PARAM0
     
    303303    else if (index == 3) { P4 temp = param; param = temp; } \
    304304    else if (index == 4) { P5 temp = param; param = temp; }
    305 
     305*/
     306#define FUNCTOR_EVALUATE_PARAM(numparams) FUNCTOR_EVALUATE_PARAM##numparams
     307#define FUNCTOR_EVALUATE_PARAM0
     308#define FUNCTOR_EVALUATE_PARAM1 \
     309    if (index == 0) { param.convert<P1>(); }
     310#define FUNCTOR_EVALUATE_PARAM2 \
     311    if (index == 0) { param.convert<P1>(); } \
     312    else if (index == 1) { param.convert<P2>(); }
     313#define FUNCTOR_EVALUATE_PARAM3 \
     314    if (index == 0) { param.convert<P1>(); } \
     315    else if (index == 1) { param.convert<P2>(); } \
     316    else if (index == 2) { param.convert<P3>(); }
     317#define FUNCTOR_EVALUATE_PARAM4 \
     318    if (index == 0) { param.convert<P1>(); } \
     319    else if (index == 1) { param.convert<P2>(); } \
     320    else if (index == 2) { param.convert<P3>(); } \
     321    else if (index == 3) { param.convert<P4>(); }
     322#define FUNCTOR_EVALUATE_PARAM5 \
     323    if (index == 0) { param.convert<P1>(); } \
     324    else if (index == 1) { param.convert<P2>(); } \
     325    else if (index == 2) { param.convert<P3>(); } \
     326    else if (index == 3) { param.convert<P4>(); } \
     327    else if (index == 4) { param.convert<P5>(); }
    306328
    307329
     
    324346            } \
    325347    \
    326             void operator()(const MultiTypeMath& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& param5 = MT_null) \
     348            void operator()(const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) \
    327349            { \
    328350                FUNCTOR_STORE_RETURNVALUE(returnvalue, (*this->functionPointer_)(FUNCTOR_FUNCTION_CALL(numparams))); \
    329351            } \
    330352    \
    331             virtual void evaluateParam(unsigned int index, MultiTypeMath& param) const \
     353            virtual void evaluateParam(unsigned int index, MultiType& param) const \
    332354            { \
    333355                FUNCTOR_EVALUATE_PARAM(numparams); \
     
    362384            } \
    363385    \
    364             void operator()(T* object, const MultiTypeMath& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& param5 = MT_null) \
     386            void operator()(T* object, const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) \
    365387            { \
    366388                FUNCTOR_STORE_RETURNVALUE(returnvalue, (*object.*this->functionPointer_)(FUNCTOR_FUNCTION_CALL(numparams))); \
    367389            } \
    368390    \
    369             void operator()(const T* object, const MultiTypeMath& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& param5 = MT_null) \
     391            void operator()(const T* object, const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) \
    370392            { \
    371393                COUT(1) << "An error occurred in Functor.h:" << std::endl; \
     
    373395            } \
    374396    \
    375             virtual void evaluateParam(unsigned int index, MultiTypeMath& param) const \
     397            virtual void evaluateParam(unsigned int index, MultiType& param) const \
    376398            { \
    377399                FUNCTOR_EVALUATE_PARAM(numparams); \
     
    395417            } \
    396418    \
    397             void operator()(T* object, const MultiTypeMath& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& param5 = MT_null) \
     419            void operator()(T* object, const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) \
    398420            { \
    399421                FUNCTOR_STORE_RETURNVALUE(returnvalue, (*object.*this->functionPointer_)(FUNCTOR_FUNCTION_CALL(numparams))); \
    400422            } \
    401423    \
    402             void operator()(const T* object, const MultiTypeMath& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& param5 = MT_null) \
     424            void operator()(const T* object, const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) \
    403425            { \
    404426                FUNCTOR_STORE_RETURNVALUE(returnvalue, (*object.*this->functionPointer_)(FUNCTOR_FUNCTION_CALL(numparams))); \
    405427            } \
    406428    \
    407             virtual void evaluateParam(unsigned int index, MultiTypeMath& param) const \
     429            virtual void evaluateParam(unsigned int index, MultiType& param) const \
    408430            { \
    409431                FUNCTOR_EVALUATE_PARAM(numparams); \
  • code/branches/core3/src/core/XMLPort.h

    r1610 r1716  
    3434#include "util/Debug.h"
    3535#include "util/XMLIncludes.h"
    36 #include "util/MultiTypeMath.h"
     36#include "util/MultiType.h"
    3737#include "tinyxml/ticpp.h"
    3838#include "Executor.h"
     
    107107            virtual const std::string& getDescription() = 0;
    108108
    109             virtual XMLPortParamContainer& defaultValue(unsigned int index, const MultiTypeMath& param) = 0;
    110             virtual XMLPortParamContainer& defaultValues(const MultiTypeMath& param1) = 0;
    111             virtual XMLPortParamContainer& defaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2) = 0;
    112             virtual XMLPortParamContainer& defaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3) = 0;
    113             virtual XMLPortParamContainer& defaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4) = 0;
    114             virtual XMLPortParamContainer& defaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4, const MultiTypeMath& param5) = 0;
     109            virtual XMLPortParamContainer& defaultValue(unsigned int index, const MultiType& param) = 0;
     110            virtual XMLPortParamContainer& defaultValues(const MultiType& param1) = 0;
     111            virtual XMLPortParamContainer& defaultValues(const MultiType& param1, const MultiType& param2) = 0;
     112            virtual XMLPortParamContainer& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3) = 0;
     113            virtual XMLPortParamContainer& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4) = 0;
     114            virtual XMLPortParamContainer& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) = 0;
    115115
    116116        protected:
     
    197197                { return this->loadexecutor_->getDescription(); }
    198198
    199             virtual XMLPortParamContainer& defaultValue(unsigned int index, const MultiTypeMath& param)
     199            virtual XMLPortParamContainer& defaultValue(unsigned int index, const MultiType& param)
    200200            {
    201201                if (!this->loadexecutor_->defaultValueSet(index))
     
    203203                return this->portIfWaitingForDefaultValues(this->parseResult_, this->parseParams_);
    204204            }
    205             virtual XMLPortParamContainer& defaultValues(const MultiTypeMath& param1)
     205            virtual XMLPortParamContainer& defaultValues(const MultiType& param1)
    206206            {
    207207                if (!this->loadexecutor_->defaultValueSet(0))
     
    209209                return this->portIfWaitingForDefaultValues(this->parseResult_, this->parseParams_);
    210210            }
    211             virtual XMLPortParamContainer& defaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2)
     211            virtual XMLPortParamContainer& defaultValues(const MultiType& param1, const MultiType& param2)
    212212            {
    213213                if ((!this->loadexecutor_->defaultValueSet(0)) || (!this->loadexecutor_->defaultValueSet(1)))
     
    215215                return this->portIfWaitingForDefaultValues(this->parseResult_, this->parseParams_);
    216216            }
    217             virtual XMLPortParamContainer& defaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3)
     217            virtual XMLPortParamContainer& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3)
    218218            {
    219219                if ((!this->loadexecutor_->defaultValueSet(0)) || (!this->loadexecutor_->defaultValueSet(1)) || (!this->loadexecutor_->defaultValueSet(2)))
     
    221221                return this->portIfWaitingForDefaultValues(this->parseResult_, this->parseParams_);
    222222            }
    223             virtual XMLPortParamContainer& defaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4)
     223            virtual XMLPortParamContainer& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4)
    224224            {
    225225                if ((!this->loadexecutor_->defaultValueSet(0)) || (!this->loadexecutor_->defaultValueSet(1)) || (!this->loadexecutor_->defaultValueSet(2)) || (!this->loadexecutor_->defaultValueSet(3)))
     
    227227                return this->portIfWaitingForDefaultValues(this->parseResult_, this->parseParams_);
    228228            }
    229             virtual XMLPortParamContainer& defaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4, const MultiTypeMath& param5)
     229            virtual XMLPortParamContainer& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5)
    230230            {
    231231                if ((!this->loadexecutor_->defaultValueSet(0)) || (!this->loadexecutor_->defaultValueSet(1)) || (!this->loadexecutor_->defaultValueSet(2)) || (!this->loadexecutor_->defaultValueSet(3)) || (!this->loadexecutor_->defaultValueSet(4)))
  • code/branches/core3/src/core/input/InputManager.cc

    r1596 r1716  
    321321    if (joySticksSize_)
    322322    {
    323       std::vector<MultiTypeMath> coeffPos;
    324       std::vector<MultiTypeMath> coeffNeg;
    325       std::vector<MultiTypeMath> zero;
     323      std::vector<double> coeffPos;
     324      std::vector<double> coeffNeg;
     325      std::vector<int> zero;
    326326      coeffPos.resize(24);
    327327      coeffNeg.resize(24);
  • code/branches/core3/src/util/CMakeLists.txt

    r1606 r1716  
    55  ExprParser.cc
    66  Math.cc
    7   MultiTypePrimitive.cc
    8   MultiTypeString.cc
    9   MultiTypeMath.cc
     7  MultiType.cc
    108  OutputBuffer.cc
    119  OutputHandler.cc
  • code/branches/core3/src/util/Convert.h

    r1586 r1716  
    4343#include "Debug.h"
    4444#include "SubString.h"
    45 #include "MultiTypeMath.h"
     45//#include "MultiTypeMath.h"
    4646
    4747// disable annoying warning about forcing value to boolean
     
    323323// MULTITYPES //
    324324////////////////
    325 
     325/*
    326326// convert from MultiTypePrimitive
    327327template <class ToType>
     
    403403    }
    404404};
    405 
     405*/
    406406
    407407////////////////////
  • code/branches/core3/src/util/MultiType.h

    r1505 r1716  
    2525 *      ...
    2626 *
    27  *   Inspiration: MultiType by Benjamin Grauer
    2827 */
    2928
     
    3332#include "UtilPrereqs.h"
    3433
    35 enum _UtilExport MultiType
     34#include <boost/static_assert.hpp>
     35
     36#include "Math.h"
     37
     38// disable annoying warning about multiple assignment operators
     39#if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC
     40#pragma warning(push)
     41#pragma warning(disable:4522)
     42#endif
     43
     44enum _UtilExport MT_Type
    3645{
    3746    MT_null,
    38     MT_void,
    39     MT_int,
    40     MT_uint,
    4147    MT_char,
    4248    MT_uchar,
    4349    MT_short,
    4450    MT_ushort,
     51    MT_int,
     52    MT_uint,
    4553    MT_long,
    4654    MT_ulong,
     55    MT_longlong,
     56    MT_ulonglong,
    4757    MT_float,
    4858    MT_double,
    4959    MT_longdouble,
    5060    MT_bool,
    51     MT_constchar,
     61    MT_void,
    5262    MT_string,
    53     MT_xmlelement,
    5463    MT_vector2,
    5564    MT_vector3,
     
    5766    MT_colourvalue,
    5867    MT_quaternion,
    59     MT_degree,
    60     MT_radian
     68    MT_radian,
     69    MT_degree
    6170};
    6271
    63 union _UtilExport MultiTypeValue
     72class _UtilExport MultiType
    6473{
    65     void*           void_;
    66     int             int_;
    67     unsigned int    uint_;
    68     char            char_;
    69     unsigned char   uchar_;
    70     short           short_;
    71     unsigned short  ushort_;
    72     long            long_;
    73     unsigned long   ulong_;
    74     float           float_;
    75     double          double_;
    76     long double     longdouble_;
    77     bool            bool_;
     74    friend std::ostream& operator<<(std::ostream& outstream, const MultiType& mt);
     75
     76    struct _UtilExport MT_ValueBase
     77    {
     78        virtual ~MT_ValueBase() {}
     79
     80        virtual MT_ValueBase* clone() const = 0;
     81
     82        virtual void setValue(const char& value)                 = 0;
     83        virtual void setValue(const unsigned char& value)        = 0;
     84        virtual void setValue(const short& value)                = 0;
     85        virtual void setValue(const unsigned short& value)       = 0;
     86        virtual void setValue(const int& value)                  = 0;
     87        virtual void setValue(const unsigned int& value)         = 0;
     88        virtual void setValue(const long& value)                 = 0;
     89        virtual void setValue(const unsigned long& value)        = 0;
     90        virtual void setValue(const long long& value)            = 0;
     91        virtual void setValue(const unsigned long long& value)   = 0;
     92        virtual void setValue(const float& value)                = 0;
     93        virtual void setValue(const double& value)               = 0;
     94        virtual void setValue(const long double& value)          = 0;
     95        virtual void setValue(const bool& value)                 = 0;
     96        virtual void setValue(      void* const& value)          = 0;
     97        virtual void setValue(const std::string& value)          = 0;
     98        virtual void setValue(const orxonox::Vector2& value)     = 0;
     99        virtual void setValue(const orxonox::Vector3& value)     = 0;
     100        virtual void setValue(const orxonox::Vector4& value)     = 0;
     101        virtual void setValue(const orxonox::ColourValue& value) = 0;
     102        virtual void setValue(const orxonox::Quaternion& value)  = 0;
     103        virtual void setValue(const orxonox::Radian& value)      = 0;
     104        virtual void setValue(const orxonox::Degree& value)      = 0;
     105
     106        virtual operator char()                 const = 0;
     107        virtual operator unsigned char()        const = 0;
     108        virtual operator short()                const = 0;
     109        virtual operator unsigned short()       const = 0;
     110        virtual operator int()                  const = 0;
     111        virtual operator unsigned int()         const = 0;
     112        virtual operator long()                 const = 0;
     113        virtual operator unsigned long()        const = 0;
     114        virtual operator long long()            const = 0;
     115        virtual operator unsigned long long()   const = 0;
     116        virtual operator float()                const = 0;
     117        virtual operator double()               const = 0;
     118        virtual operator long double()          const = 0;
     119        virtual operator bool()                 const = 0;
     120        virtual operator void*()                const = 0;
     121        virtual operator std::string()          const = 0;
     122        virtual operator orxonox::Vector2()     const = 0;
     123        virtual operator orxonox::Vector3()     const = 0;
     124        virtual operator orxonox::Vector4()     const = 0;
     125        virtual operator orxonox::ColourValue() const = 0;
     126        virtual operator orxonox::Quaternion()  const = 0;
     127        virtual operator orxonox::Radian()      const = 0;
     128        virtual operator orxonox::Degree()      const = 0;
     129
     130        virtual void toString(std::ostream& outstream) const = 0;
     131    };
     132
     133    public:
     134        inline                       MultiType()                       : value_(0), type_(MT_null) {}
     135        template <typename V> inline MultiType(const V& value)         : value_(0), type_(MT_null) { this->assignValue(value); }
     136        inline                       MultiType(const MultiType& other) : value_(0), type_(MT_null) { this->setValue(other); }
     137        inline                       MultiType(MT_Type type)           : value_(0), type_(MT_null) { this->setType(type); }
     138        ~MultiType() { if (this->value_) { delete this->value_; } }
     139
     140        template <typename V>             inline MultiType& operator=(const V& value)         { this->setValue(value);          return (*this); }
     141        template <typename T, typename V> inline MultiType& operator=(const V& value)         { this->assignValue((T)value);    return (*this); }
     142        inline                                   MultiType& operator=(const MultiType& other) { this->setValue(other);          return (*this); }
     143        inline                                   MultiType& operator=(MT_Type type)           { this->setType(type);            return (*this); }
     144
     145        template <typename V> inline void             setValue(const V& value)         { if (this->value_) { this->value_->setValue(value); } else { this->createNewValueContainer(value); } }
     146        template <typename V> inline void             setValue(V* value)               { if (this->value_) { this->value_->setValue((void*)value); } else { this->createNewValueContainer((void*)value); } }
     147        inline void                                   setValue(const char* value);
     148        inline void                                   setValue(const MultiType& other) { this->type_ = other.type_; this->value_ = (other.value_) ? other.value_->clone() : 0; }
     149        template <typename T, typename V> inline void setValue(const V& value)         { this->assignValue((T)value); }
     150
     151        template <typename T> inline void convert() { this->setValue<T>(this->operator T()); }
     152
     153        inline void                       reset() { if (this->value_) { delete this->value_; this->value_ = 0; } this->type_ = MT_null; }
     154
     155        template <typename T> inline void setType()                       { this->assignValue(T()); }
     156        inline void                       setType(const MultiType& other) { this->setType(other.type_); }
     157        void                              setType(MT_Type type);
     158
     159        operator char()                  const;
     160        operator unsigned char()         const;
     161        operator short()                 const;
     162        operator unsigned short()        const;
     163        operator int()                   const;
     164        operator unsigned int()          const;
     165        operator long()                  const;
     166        operator unsigned long()         const;
     167        operator long long()             const;
     168        operator unsigned long long()    const;
     169        operator float()                 const;
     170        operator double()                const;
     171        operator long double()           const;
     172        operator bool()                  const;
     173        operator void*()                 const;
     174        operator std::string()           const;
     175        operator orxonox::Vector2()      const;
     176        operator orxonox::Vector3()      const;
     177        operator orxonox::Vector4()      const;
     178        operator orxonox::ColourValue()  const;
     179        operator orxonox::Quaternion()   const;
     180        operator orxonox::Radian()       const;
     181        operator orxonox::Degree()       const;
     182        template <class T> operator T*() const { return ((T*)this->operator void*()); }
     183
     184        inline void getValue(char*                 value) const { if (this->value_) { (*value) = (*this->value_); } }
     185        inline void getValue(unsigned char*        value) const { if (this->value_) { (*value) = (*this->value_); } }
     186        inline void getValue(short*                value) const { if (this->value_) { (*value) = (*this->value_); } }
     187        inline void getValue(unsigned short*       value) const { if (this->value_) { (*value) = (*this->value_); } }
     188        inline void getValue(int*                  value) const { if (this->value_) { (*value) = (*this->value_); } }
     189        inline void getValue(unsigned int*         value) const { if (this->value_) { (*value) = (*this->value_); } }
     190        inline void getValue(long*                 value) const { if (this->value_) { (*value) = (*this->value_); } }
     191        inline void getValue(unsigned long*        value) const { if (this->value_) { (*value) = (*this->value_); } }
     192        inline void getValue(long long*            value) const { if (this->value_) { (*value) = (*this->value_); } }
     193        inline void getValue(unsigned long long*   value) const { if (this->value_) { (*value) = (*this->value_); } }
     194        inline void getValue(float*                value) const { if (this->value_) { (*value) = (*this->value_); } }
     195        inline void getValue(double*               value) const { if (this->value_) { (*value) = (*this->value_); } }
     196        inline void getValue(long double*          value) const { if (this->value_) { (*value) = (*this->value_); } }
     197        inline void getValue(bool*                 value) const { if (this->value_) { (*value) = (*this->value_); } }
     198        inline void getValue(void*                 value) const { if (this->value_) {   value  = (*this->value_); } }
     199        inline void getValue(std::string*          value) const { if (this->value_) { (*value) = this->value_->operator std::string();          } }
     200        inline void getValue(orxonox::Vector2*     value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Vector2();     } }
     201        inline void getValue(orxonox::Vector3*     value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Vector3();     } }
     202        inline void getValue(orxonox::Vector4*     value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Vector4();     } }
     203        inline void getValue(orxonox::ColourValue* value) const { if (this->value_) { (*value) = this->value_->operator orxonox::ColourValue(); } }
     204        inline void getValue(orxonox::Quaternion*  value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Quaternion();  } }
     205        inline void getValue(orxonox::Radian*      value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Radian();      } }
     206        inline void getValue(orxonox::Degree*      value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Degree();      } }
     207
     208        inline MT_Type                    getType()            const { return this->type_; }
     209        inline bool                       isType(MT_Type type) const { return (this->type_ == type); }
     210        template <typename T> inline bool isType()             const { return false; }
     211        std::string                       getTypename()        const;
     212
     213        inline std::string toString() const { return this->operator std::string(); }
     214
     215    private:
     216        inline void assignValue(const char& value)                 { if (this->value_ && this->type_ == MT_char)        { this->value_->setValue(value); } else { this->changeValueContainer<char>(value);                 this->type_ = MT_char;        } }
     217        inline void assignValue(const unsigned char& value)        { if (this->value_ && this->type_ == MT_uchar)       { this->value_->setValue(value); } else { this->changeValueContainer<unsigned char>(value);        this->type_ = MT_uchar;       } }
     218        inline void assignValue(const short& value)                { if (this->value_ && this->type_ == MT_short)       { this->value_->setValue(value); } else { this->changeValueContainer<short>(value);                this->type_ = MT_short;       } }
     219        inline void assignValue(const unsigned short& value)       { if (this->value_ && this->type_ == MT_ushort)      { this->value_->setValue(value); } else { this->changeValueContainer<unsigned short>(value);       this->type_ = MT_ushort;      } }
     220        inline void assignValue(const int& value)                  { if (this->value_ && this->type_ == MT_int)         { this->value_->setValue(value); } else { this->changeValueContainer<int>(value);                  this->type_ = MT_int;         } }
     221        inline void assignValue(const unsigned int& value)         { if (this->value_ && this->type_ == MT_uint)        { this->value_->setValue(value); } else { this->changeValueContainer<unsigned int>(value);         this->type_ = MT_uint;        } }
     222        inline void assignValue(const long& value)                 { if (this->value_ && this->type_ == MT_long)        { this->value_->setValue(value); } else { this->changeValueContainer<long>(value);                 this->type_ = MT_long;        } }
     223        inline void assignValue(const unsigned long& value)        { if (this->value_ && this->type_ == MT_ulong)       { this->value_->setValue(value); } else { this->changeValueContainer<unsigned long>(value);        this->type_ = MT_ulong;       } }
     224        inline void assignValue(const long long& value)            { if (this->value_ && this->type_ == MT_longlong)    { this->value_->setValue(value); } else { this->changeValueContainer<long long>(value);            this->type_ = MT_longlong;    } }
     225        inline void assignValue(const unsigned long long& value)   { if (this->value_ && this->type_ == MT_ulonglong)   { this->value_->setValue(value); } else { this->changeValueContainer<unsigned long long>(value);   this->type_ = MT_ulonglong;   } }
     226        inline void assignValue(const float& value)                { if (this->value_ && this->type_ == MT_float)       { this->value_->setValue(value); } else { this->changeValueContainer<float>(value);                this->type_ = MT_float;       } }
     227        inline void assignValue(const double& value)               { if (this->value_ && this->type_ == MT_double)      { this->value_->setValue(value); } else { this->changeValueContainer<double>(value);               this->type_ = MT_double;      } }
     228        inline void assignValue(const long double& value)          { if (this->value_ && this->type_ == MT_longdouble)  { this->value_->setValue(value); } else { this->changeValueContainer<long double>(value);          this->type_ = MT_longdouble;  } }
     229        inline void assignValue(const bool& value)                 { if (this->value_ && this->type_ == MT_bool)        { this->value_->setValue(value); } else { this->changeValueContainer<bool>(value);                 this->type_ = MT_bool;        } }
     230        inline void assignValue(      void* const& value)          { if (this->value_ && this->type_ == MT_void)        { this->value_->setValue(value); } else { this->changeValueContainer<void*>(value);                this->type_ = MT_void;        } }
     231        inline void assignValue(const std::string& value)          { if (this->value_ && this->type_ == MT_string)      { this->value_->setValue(value); } else { this->changeValueContainer<std::string>(value);          this->type_ = MT_string;      } }
     232        inline void assignValue(const orxonox::Vector2& value)     { if (this->value_ && this->type_ == MT_vector2)     { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector2>(value);     this->type_ = MT_vector2;     } }
     233        inline void assignValue(const orxonox::Vector3& value)     { if (this->value_ && this->type_ == MT_vector3)     { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector3>(value);     this->type_ = MT_vector3;     } }
     234        inline void assignValue(const orxonox::Vector4& value)     { if (this->value_ && this->type_ == MT_vector4)     { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector4>(value);     this->type_ = MT_vector4;     } }
     235        inline void assignValue(const orxonox::ColourValue& value) { if (this->value_ && this->type_ == MT_colourvalue) { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::ColourValue>(value); this->type_ = MT_colourvalue; } }
     236        inline void assignValue(const orxonox::Quaternion& value)  { if (this->value_ && this->type_ == MT_quaternion)  { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Quaternion>(value);  this->type_ = MT_quaternion;  } }
     237        inline void assignValue(const orxonox::Radian& value)      { if (this->value_ && this->type_ == MT_radian)      { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Radian>(value);      this->type_ = MT_radian;      } }
     238        inline void assignValue(const orxonox::Degree& value)      { if (this->value_ && this->type_ == MT_degree)      { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Degree>(value);      this->type_ = MT_degree;      } }
     239        template <typename T> inline void changeValueContainer(const T& value) { if (this->value_) { delete this->value_; } this->createNewValueContainer<T>(value); }
     240        template <typename T>        void createNewValueContainer(const T& value) { BOOST_STATIC_ASSERT(sizeof(T) == 0); }
     241
     242        MT_ValueBase* value_;
     243        MT_Type type_;
    78244};
    79245
     246_UtilExport inline std::ostream& operator<<(std::ostream& outstream, const MultiType& mt) { if (mt.value_) { mt.value_->toString(outstream); } return outstream; }
     247
     248template <> inline bool MultiType::isType<char>()                 const { return (this->type_ == MT_char);        }
     249template <> inline bool MultiType::isType<unsigned char>()        const { return (this->type_ == MT_uchar);       }
     250template <> inline bool MultiType::isType<short>()                const { return (this->type_ == MT_short);       }
     251template <> inline bool MultiType::isType<unsigned short>()       const { return (this->type_ == MT_ushort);      }
     252template <> inline bool MultiType::isType<int>()                  const { return (this->type_ == MT_int);         }
     253template <> inline bool MultiType::isType<unsigned int>()         const { return (this->type_ == MT_uint);        }
     254template <> inline bool MultiType::isType<long>()                 const { return (this->type_ == MT_long);        }
     255template <> inline bool MultiType::isType<unsigned long>()        const { return (this->type_ == MT_ulong);       }
     256template <> inline bool MultiType::isType<long long>()            const { return (this->type_ == MT_longlong);    }
     257template <> inline bool MultiType::isType<unsigned long long>()   const { return (this->type_ == MT_ulonglong);   }
     258template <> inline bool MultiType::isType<float>()                const { return (this->type_ == MT_float);       }
     259template <> inline bool MultiType::isType<double>()               const { return (this->type_ == MT_double);      }
     260template <> inline bool MultiType::isType<long double>()          const { return (this->type_ == MT_longdouble);  }
     261template <> inline bool MultiType::isType<bool>()                 const { return (this->type_ == MT_bool);        }
     262template <> inline bool MultiType::isType<void*>()                const { return (this->type_ == MT_void);        }
     263template <> inline bool MultiType::isType<std::string>()          const { return (this->type_ == MT_string);      }
     264template <> inline bool MultiType::isType<orxonox::Vector2>()     const { return (this->type_ == MT_vector2);     }
     265template <> inline bool MultiType::isType<orxonox::Vector3>()     const { return (this->type_ == MT_vector3);     }
     266template <> inline bool MultiType::isType<orxonox::Vector4>()     const { return (this->type_ == MT_vector4);     }
     267template <> inline bool MultiType::isType<orxonox::ColourValue>() const { return (this->type_ == MT_colourvalue); }
     268template <> inline bool MultiType::isType<orxonox::Quaternion>()  const { return (this->type_ == MT_quaternion);  }
     269template <> inline bool MultiType::isType<orxonox::Radian>()      const { return (this->type_ == MT_radian);      }
     270template <> inline bool MultiType::isType<orxonox::Degree>()      const { return (this->type_ == MT_degree);      }
     271
     272template <> inline void MultiType::convert<const std::string&>()          { this->convert<std::string>();          }
     273template <> inline void MultiType::convert<const orxonox::Vector2&>()     { this->convert<orxonox::Vector2>();     }
     274template <> inline void MultiType::convert<const orxonox::Vector3&>()     { this->convert<orxonox::Vector3>();     }
     275template <> inline void MultiType::convert<const orxonox::Vector4&>()     { this->convert<orxonox::Vector4>();     }
     276template <> inline void MultiType::convert<const orxonox::ColourValue&>() { this->convert<orxonox::ColourValue>(); }
     277template <> inline void MultiType::convert<const orxonox::Quaternion&>()  { this->convert<orxonox::Quaternion>();  }
     278template <> inline void MultiType::convert<const orxonox::Radian&>()      { this->convert<orxonox::Radian>();      }
     279template <> inline void MultiType::convert<const orxonox::Degree&>()      { this->convert<orxonox::Degree>();      }
     280
     281template <> void MultiType::createNewValueContainer(const char& value);
     282template <> void MultiType::createNewValueContainer(const unsigned char& value);
     283template <> void MultiType::createNewValueContainer(const short& value);
     284template <> void MultiType::createNewValueContainer(const unsigned short& value);
     285template <> void MultiType::createNewValueContainer(const int& value);
     286template <> void MultiType::createNewValueContainer(const unsigned int& value);
     287template <> void MultiType::createNewValueContainer(const long& value);
     288template <> void MultiType::createNewValueContainer(const unsigned long& value);
     289template <> void MultiType::createNewValueContainer(const long long& value);
     290template <> void MultiType::createNewValueContainer(const unsigned long long& value);
     291template <> void MultiType::createNewValueContainer(const float& value);
     292template <> void MultiType::createNewValueContainer(const double& value);
     293template <> void MultiType::createNewValueContainer(const bool& value);
     294template <> void MultiType::createNewValueContainer(const long double& value);
     295template <> void MultiType::createNewValueContainer(      void* const& value);
     296template <> void MultiType::createNewValueContainer(const std::string& value);
     297template <> void MultiType::createNewValueContainer(const orxonox::Vector2& value);
     298template <> void MultiType::createNewValueContainer(const orxonox::Vector3& value);
     299template <> void MultiType::createNewValueContainer(const orxonox::Vector4& value);
     300template <> void MultiType::createNewValueContainer(const orxonox::ColourValue& value);
     301template <> void MultiType::createNewValueContainer(const orxonox::Quaternion& value);
     302template <> void MultiType::createNewValueContainer(const orxonox::Radian& value);
     303template <> void MultiType::createNewValueContainer(const orxonox::Degree& value);
     304
     305inline void MultiType::setValue(const char* value) { if (this->value_) { this->value_->setValue(std::string(value)); } else { this->createNewValueContainer(std::string(value)); } }
     306
     307/*
     308
     309(*) = funktion 2x:
     310function(...) : bezieht sich auf aktuellen type
     311function<T>(...) : bezieht sich auf type T
     312
     313constructor(V value) : zuweisung
     314(*) operator=(V value) : zuweisung
     315(*) setValue(V value) : zuweisung
     316
     317(*) == != > < <= >= : template
     318
     319(*) reset() : zurück auf 0 (bzw "")
     320setType<T>() : setzt type und macht reset
     321convert<T>() : setzt type und konvertiert
     322
     323(T) : return konvertiert
     324
     325isType<T>() : return bool
     326getType() : return MT_Type
     327getTypename() : return string
     328
     329toString() : return string
     330(*) fromString(string value) : konvertiert string
     331operator<< : toString()
     332
     333*/
     334
     335#if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC
     336#pragma warning(pop)
     337#endif
     338
    80339#endif /* _MultiType_H__ */
  • code/branches/core3/src/util/OutputBuffer.h

    r1586 r1716  
    6666            inline OutputBuffer& operator<<(const OutputBuffer& object)
    6767            {
    68                 this->stream_ << object.stream_;
     68                this->stream_ << object.stream_.rdbuf();
    6969                this->callListeners();
    7070                return *this;
  • code/branches/core3/src/util/UtilPrereqs.h

    r1606 r1716  
    6363class Convert;
    6464class ExprParser;
    65 class MultiTypePrimitive;
    66 class MultiTypeString;
    67 class MultiTypeMath;
     65class MultiType;
    6866class SubString;
    6967
Note: See TracChangeset for help on using the changeset viewer.