Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 19, 2012, 11:27:07 AM (12 years ago)
Author:
landauf
Message:

renamed MT_Value as MultiType::Type and removed it from the public interface of MultiType
added MultiType::Null

Location:
code/branches/testing/src/libraries
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • code/branches/testing/src/libraries/core/CommandLineParser.cc

    r8858 r9222  
    5050    void CommandLineArgument::parse(const std::string& value)
    5151    {
    52         if (value_.getType() == MT_Type::Bool)
     52        if (value_.isType<bool>())
    5353        {
    5454            // simulate command line switch
     
    298298                infoStr << "      ";
    299299            infoStr << "--" << it->second->getName() << ' ';
    300             if (it->second->getValue().getType() != MT_Type::Bool)
     300            if (it->second->getValue().isType<bool>())
     301                infoStr << "    ";
     302            else
    301303                infoStr << "ARG ";
    302             else
    303                 infoStr << "    ";
    304304            // fill with the necessary amount of blanks
    305305            infoStr << std::string(maxNameSize - it->second->getName().size(), ' ');
  • code/branches/testing/src/libraries/core/CommandLineParser.h

    r8858 r9222  
    217217        OrxAssert(!_getInstance().existsArgument(name),
    218218            "Cannot add a command line argument with name '" + name + "' twice.");
    219         OrxAssert(MultiType(defaultValue).getType() != MT_Type::Bool || MultiType(defaultValue).getBool() != true,
     219        OrxAssert(!MultiType(defaultValue).isType<bool>() || MultiType(defaultValue).getBool() != true,
    220220               "Boolean command line arguments with positive default values are not supported." << endl
    221221            << "Please use SetCommandLineSwitch and adjust your argument: " << name);
  • code/branches/testing/src/libraries/core/ConfigValueContainer.cc

    r8858 r9222  
    8383        for (unsigned int i = 0; i < this->valueVector_.size(); i++)
    8484        {
    85             ConfigFileManager::getInstance().getConfigFile(this->type_)->getOrCreateValue(this->sectionname_, this->varname_, i, this->valueVector_[i], this->value_.isType(MT_Type::String));
     85            ConfigFileManager::getInstance().getConfigFile(this->type_)->getOrCreateValue(this->sectionname_, this->varname_, i, this->valueVector_[i], this->value_.isType<std::string>());
    8686            this->defvalueStringVector_.push_back(this->valueVector_[i]);
    8787        }
     
    118118            if (this->tset(input))
    119119            {
    120                 ConfigFileManager::getInstance().getConfigFile(this->type_)->setValue(this->sectionname_, this->varname_, input, this->value_.isType(MT_Type::String));
     120                ConfigFileManager::getInstance().getConfigFile(this->type_)->setValue(this->sectionname_, this->varname_, input, this->value_.isType<std::string>());
    121121                return true;
    122122            }
     
    137137            if (this->tset(index, input))
    138138            {
    139                 ConfigFileManager::getInstance().getConfigFile(this->type_)->setValue(this->sectionname_, this->varname_, index, input, this->value_.isType(MT_Type::String));
     139                ConfigFileManager::getInstance().getConfigFile(this->type_)->setValue(this->sectionname_, this->varname_, index, input, this->value_.isType<std::string>());
    140140                return true;
    141141            }
     
    236236                this->valueVector_.erase(this->valueVector_.begin() + index);
    237237                for (unsigned int i = index; i < this->valueVector_.size(); i++)
    238                     ConfigFileManager::getInstance().getConfigFile(this->type_)->setValue(this->sectionname_, this->varname_, i, this->valueVector_[i], this->value_.isType(MT_Type::String));
     238                    ConfigFileManager::getInstance().getConfigFile(this->type_)->setValue(this->sectionname_, this->varname_, i, this->valueVector_[i], this->value_.isType<std::string>());
    239239                ConfigFileManager::getInstance().getConfigFile(this->type_)->deleteVectorEntries(this->sectionname_, this->varname_, this->valueVector_.size());
    240240
     
    272272    {
    273273        if (!this->bIsVector_)
    274             this->value_ = ConfigFileManager::getInstance().getConfigFile(this->type_)->getOrCreateValue(this->sectionname_, this->varname_, this->defvalueString_, this->value_.isType(MT_Type::String));
     274            this->value_ = ConfigFileManager::getInstance().getConfigFile(this->type_)->getOrCreateValue(this->sectionname_, this->varname_, this->defvalueString_, this->value_.isType<std::string>());
    275275        else
    276276        {
     
    281281                if (i < this->defvalueStringVector_.size())
    282282                {
    283                     this->value_ = ConfigFileManager::getInstance().getConfigFile(this->type_)->getOrCreateValue(this->sectionname_, this->varname_, i, this->defvalueStringVector_[i], this->value_.isType(MT_Type::String));
     283                    this->value_ = ConfigFileManager::getInstance().getConfigFile(this->type_)->getOrCreateValue(this->sectionname_, this->varname_, i, this->defvalueStringVector_[i], this->value_.isType<std::string>());
    284284                }
    285285                else
    286286                {
    287                     this->value_ = ConfigFileManager::getInstance().getConfigFile(this->type_)->getOrCreateValue(this->sectionname_, this->varname_, i, MultiType(), this->value_.isType(MT_Type::String));
     287                    this->value_ = ConfigFileManager::getInstance().getConfigFile(this->type_)->getOrCreateValue(this->sectionname_, this->varname_, i, MultiType(), this->value_.isType<std::string>());
    288288                }
    289289
  • code/branches/testing/src/libraries/core/command/CommandEvaluation.cc

    r8858 r9222  
    119119        @brief Executes the command which was evaluated by this object and returns its return-value.
    120120        @param error A pointer to an integer (or NULL) which will be used to write error codes to (see @ref CommandExecutorErrorCodes "CommandExecutor error codes")
    121         @return Returns the result of the command (or MT_Type::Null if there is no return value)
     121        @return Returns the result of the command (or MultiType::Null if there is no return value)
    122122    */
    123123    MultiType CommandEvaluation::query(int* error)
     
    138138
    139139            if (*error != CommandExecutor::Success)
    140                 return MT_Type::Null;
     140                return MultiType::Null;
    141141        }
    142142
     
    170170
    171171        // return a null value in case of an error
    172         return MT_Type::Null;
     172        return MultiType::Null;
    173173    }
    174174
     
    225225            return this->arguments_[index];
    226226
    227         return MT_Type::Null;
     227        return MultiType::Null;
    228228    }
    229229
  • code/branches/testing/src/libraries/core/command/CommandExecutor.cc

    r8858 r9222  
    8383        @param error A pointer to a value (or NULL) where the error-code should be written to (see @ref CommandExecutorErrorCodes "error codes")
    8484        @param useTcl If true, the command is passed to tcl (see TclBind)
    85         @return Returns the return-value of the command (if any - MT_Type::Null otherwise)
     85        @return Returns the return-value of the command (if any - MultiType::Null otherwise)
    8686    */
    8787    /* static */ MultiType CommandExecutor::queryMT(const std::string& command, int* error, bool useTcl)
  • code/branches/testing/src/libraries/core/command/Executor.cc

    r8858 r9222  
    7979        @param delimiter The delimiter that is used to separate the arguments in the string @a arguments
    8080        @param bPrintError If true, errors are printed to the console if the function couldn't be executed with the given arguments
    81         @return Returns the return value of the function (or MT_Type::Null if there is no return value)
     81        @return Returns the return value of the function (or MultiType::Null if there is no return value)
    8282    */
    8383    MultiType Executor::parse(const std::string& arguments, int* error, const std::string& delimiter, bool bPrintError) const
     
    9292        @param delimiter The delimiter that was used to separate the arguments in the SubString @a arguments (used to join the surplus arguments)
    9393        @param bPrintError If true, errors are printed to the console if the function couldn't be executed with the given arguments
    94         @return Returns the return value of the function (or MT_Type::Null if there is no return value)
     94        @return Returns the return value of the function (or MultiType::Null if there is no return value)
    9595    */
    9696    MultiType Executor::parse(const SubString& arguments, int* error, const std::string& delimiter, bool bPrintError) const
     
    105105            if (bPrintError)
    106106                orxout(internal_warning) << "Can't call executor " << this->name_ << " through parser: Not enough arguments or default values given (input: " << arguments.join() << ")." << endl;
    107             return MT_Type::Null;
     107            return MultiType::Null;
    108108        }
    109109
  • code/branches/testing/src/libraries/core/command/Executor.h

    r8858 r9222  
    169169                    return this->defaultValue_[index];
    170170
    171                 return MT_Type::Null;
     171                return MultiType::Null;
    172172            }
    173173
  • code/branches/testing/src/libraries/core/command/Functor.h

    r8858 r9222  
    189189            virtual ~Functor() {}
    190190
    191             /// Calls the function-pointer with up to five arguments. In case of a member-function, the assigned object-pointer is used to call the function. @return Returns the return-value of the function (if any; MT_Type::Null otherwise)
    192             virtual MultiType operator()(const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) = 0;
     191            /// Calls the function-pointer with up to five arguments. In case of a member-function, the assigned object-pointer is used to call the function. @return Returns the return-value of the function (if any; MultiType::Null otherwise)
     192            virtual MultiType operator()(const MultiType& param1 = MultiType::Null, const MultiType& param2 = MultiType::Null, const MultiType& param3 = MultiType::Null, const MultiType& param4 = MultiType::Null, const MultiType& param5 = MultiType::Null) = 0;
    193193
    194194            /// Creates a new instance of Functor with the same values like this (used instead of a copy-constructor)
     
    245245            virtual ~FunctorMember() { if (this->bSafeMode_) { this->unregisterObject(this->object_); } }
    246246
    247             /// Calls the function-pointer with up to five arguments and an object. In case of a static-function, the object can be NULL. @return Returns the return-value of the function (if any; MT_Type::Null otherwise)
    248             virtual MultiType operator()(O* object, const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) = 0;
     247            /// Calls the function-pointer with up to five arguments and an object. In case of a static-function, the object can be NULL. @return Returns the return-value of the function (if any; MultiType::Null otherwise)
     248            virtual MultiType operator()(O* object, const MultiType& param1 = MultiType::Null, const MultiType& param2 = MultiType::Null, const MultiType& param3 = MultiType::Null, const MultiType& param4 = MultiType::Null, const MultiType& param5 = MultiType::Null) = 0;
    249249
    250250            // see Functor::operator()()
    251             MultiType operator()(const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null)
     251            MultiType operator()(const MultiType& param1 = MultiType::Null, const MultiType& param2 = MultiType::Null, const MultiType& param3 = MultiType::Null, const MultiType& param4 = MultiType::Null, const MultiType& param5 = MultiType::Null)
    252252            {
    253253                // call the function if an object was assigned
     
    257257                {
    258258                    orxout(internal_error) << "Can't execute FunctorMember, no object set." << endl;
    259                     return MT_Type::Null;
     259                    return MultiType::Null;
    260260                }
    261261            }
     
    324324            FunctorMember(void* object = 0) {}
    325325
    326             /// Calls the function-pointer with up to five arguments and an object. In case of a static-function, the object can be NULL. @return Returns the return-value of the function (if any; MT_Type::Null otherwise)
    327             virtual MultiType operator()(void* object, const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) = 0;
     326            /// Calls the function-pointer with up to five arguments and an object. In case of a static-function, the object can be NULL. @return Returns the return-value of the function (if any; MultiType::Null otherwise)
     327            virtual MultiType operator()(void* object, const MultiType& param1 = MultiType::Null, const MultiType& param2 = MultiType::Null, const MultiType& param3 = MultiType::Null, const MultiType& param4 = MultiType::Null, const MultiType& param5 = MultiType::Null) = 0;
    328328
    329329            // see Functor::operator()()
    330             MultiType operator()(const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null)
     330            MultiType operator()(const MultiType& param1 = MultiType::Null, const MultiType& param2 = MultiType::Null, const MultiType& param3 = MultiType::Null, const MultiType& param4 = MultiType::Null, const MultiType& param5 = MultiType::Null)
    331331            {
    332332                return (*this)((void*)0, param1, param2, param3, param4, param5);
     
    416416        template <class R, class O, bool isconst, class P1>                                         struct FunctorCaller<R, O, isconst, P1, void, void, void, void>   { static inline MultiType call(typename detail::FunctionPointer<R, O, isconst, P1, void, void, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType&, const MultiType&, const MultiType&, const MultiType&) { return (object->*functionPointer)(param1); } };
    417417        template <class R, class O, bool isconst>                                                   struct FunctorCaller<R, O, isconst, void, void, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<R, O, isconst, void, void, void, void, void>::Type functionPointer, O* object, const MultiType&, const MultiType&, const MultiType&, const MultiType&, const MultiType&) { return (object->*functionPointer)(); } };
    418         template <class O, bool isconst, class P1, class P2, class P3, class P4, class P5> struct FunctorCaller<void, O, isconst, P1, P2, P3, P4, P5>           { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, P1, P2, P3, P4, P5>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { (object->*functionPointer)(param1, param2, param3, param4, param5); return MT_Type::Null; } };
    419         template <class O, bool isconst, class P1, class P2, class P3, class P4>           struct FunctorCaller<void, O, isconst, P1, P2, P3, P4, void>         { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, P1, P2, P3, P4, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType&) { (object->*functionPointer)(param1, param2, param3, param4); return MT_Type::Null; } };
    420         template <class O, bool isconst, class P1, class P2, class P3>                     struct FunctorCaller<void, O, isconst, P1, P2, P3, void, void>       { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, P1, P2, P3, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType&, const MultiType&) { (object->*functionPointer)(param1, param2, param3); return MT_Type::Null; } };
    421         template <class O, bool isconst, class P1, class P2>                               struct FunctorCaller<void, O, isconst, P1, P2, void, void, void>     { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, P1, P2, void, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType&, const MultiType&, const MultiType&) { (object->*functionPointer)(param1, param2); return MT_Type::Null; } };
    422         template <class O, bool isconst, class P1>                                         struct FunctorCaller<void, O, isconst, P1, void, void, void, void>   { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, P1, void, void, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType&, const MultiType&, const MultiType&, const MultiType&) { (object->*functionPointer)(param1); return MT_Type::Null; } };
    423         template <class O, bool isconst>                                                   struct FunctorCaller<void, O, isconst, void, void, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, void, void, void, void, void>::Type functionPointer, O* object, const MultiType&, const MultiType&, const MultiType&, const MultiType&, const MultiType&) { (object->*functionPointer)(); return MT_Type::Null; } };
     418        template <class O, bool isconst, class P1, class P2, class P3, class P4, class P5> struct FunctorCaller<void, O, isconst, P1, P2, P3, P4, P5>           { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, P1, P2, P3, P4, P5>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { (object->*functionPointer)(param1, param2, param3, param4, param5); return MultiType::Null; } };
     419        template <class O, bool isconst, class P1, class P2, class P3, class P4>           struct FunctorCaller<void, O, isconst, P1, P2, P3, P4, void>         { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, P1, P2, P3, P4, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType&) { (object->*functionPointer)(param1, param2, param3, param4); return MultiType::Null; } };
     420        template <class O, bool isconst, class P1, class P2, class P3>                     struct FunctorCaller<void, O, isconst, P1, P2, P3, void, void>       { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, P1, P2, P3, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType&, const MultiType&) { (object->*functionPointer)(param1, param2, param3); return MultiType::Null; } };
     421        template <class O, bool isconst, class P1, class P2>                               struct FunctorCaller<void, O, isconst, P1, P2, void, void, void>     { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, P1, P2, void, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType&, const MultiType&, const MultiType&) { (object->*functionPointer)(param1, param2); return MultiType::Null; } };
     422        template <class O, bool isconst, class P1>                                         struct FunctorCaller<void, O, isconst, P1, void, void, void, void>   { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, P1, void, void, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType&, const MultiType&, const MultiType&, const MultiType&) { (object->*functionPointer)(param1); return MultiType::Null; } };
     423        template <class O, bool isconst>                                                   struct FunctorCaller<void, O, isconst, void, void, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, void, void, void, void, void>::Type functionPointer, O* object, const MultiType&, const MultiType&, const MultiType&, const MultiType&, const MultiType&) { (object->*functionPointer)(); return MultiType::Null; } };
    424424        template <class R, bool isconst, class P1, class P2, class P3, class P4, class P5> struct FunctorCaller<R, void, isconst, P1, P2, P3, P4, P5>           { static inline MultiType call(typename detail::FunctionPointer<R, void, isconst, P1, P2, P3, P4, P5>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { return (*functionPointer)(param1, param2, param3, param4, param5); } };
    425425        template <class R, bool isconst, class P1, class P2, class P3, class P4>           struct FunctorCaller<R, void, isconst, P1, P2, P3, P4, void>         { static inline MultiType call(typename detail::FunctionPointer<R, void, isconst, P1, P2, P3, P4, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType&) { return (*functionPointer)(param1, param2, param3, param4); } };
     
    428428        template <class R, bool isconst, class P1>                                         struct FunctorCaller<R, void, isconst, P1, void, void, void, void>   { static inline MultiType call(typename detail::FunctionPointer<R, void, isconst, P1, void, void, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType&, const MultiType&, const MultiType&, const MultiType&) { return (*functionPointer)(param1); } };
    429429        template <class R, bool isconst>                                                   struct FunctorCaller<R, void, isconst, void, void, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<R, void, isconst, void, void, void, void, void>::Type functionPointer, void*, const MultiType&, const MultiType&, const MultiType&, const MultiType&, const MultiType&) { return (*functionPointer)(); } };
    430         template <bool isconst, class P1, class P2, class P3, class P4, class P5> struct FunctorCaller<void, void, isconst, P1, P2, P3, P4, P5>           { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, P1, P2, P3, P4, P5>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { (*functionPointer)(param1, param2, param3, param4, param5); return MT_Type::Null; } };
    431         template <bool isconst, class P1, class P2, class P3, class P4>           struct FunctorCaller<void, void, isconst, P1, P2, P3, P4, void>         { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, P1, P2, P3, P4, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType&) { (*functionPointer)(param1, param2, param3, param4); return MT_Type::Null; } };
    432         template <bool isconst, class P1, class P2, class P3>                     struct FunctorCaller<void, void, isconst, P1, P2, P3, void, void>       { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, P1, P2, P3, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType&, const MultiType&) { (*functionPointer)(param1, param2, param3); return MT_Type::Null; } };
    433         template <bool isconst, class P1, class P2>                               struct FunctorCaller<void, void, isconst, P1, P2, void, void, void>     { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, P1, P2, void, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType&, const MultiType&, const MultiType&) { (*functionPointer)(param1, param2); return MT_Type::Null; } };
    434         template <bool isconst, class P1>                                         struct FunctorCaller<void, void, isconst, P1, void, void, void, void>   { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, P1, void, void, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType&, const MultiType&, const MultiType&, const MultiType&) { (*functionPointer)(param1); return MT_Type::Null; } };
    435         template <bool isconst>                                                   struct FunctorCaller<void, void, isconst, void, void, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, void, void, void, void, void>::Type functionPointer, void*, const MultiType&, const MultiType&, const MultiType&, const MultiType&, const MultiType&) { (*functionPointer)(); return MT_Type::Null; } };
     430        template <bool isconst, class P1, class P2, class P3, class P4, class P5> struct FunctorCaller<void, void, isconst, P1, P2, P3, P4, P5>           { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, P1, P2, P3, P4, P5>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { (*functionPointer)(param1, param2, param3, param4, param5); return MultiType::Null; } };
     431        template <bool isconst, class P1, class P2, class P3, class P4>           struct FunctorCaller<void, void, isconst, P1, P2, P3, P4, void>         { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, P1, P2, P3, P4, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType&) { (*functionPointer)(param1, param2, param3, param4); return MultiType::Null; } };
     432        template <bool isconst, class P1, class P2, class P3>                     struct FunctorCaller<void, void, isconst, P1, P2, P3, void, void>       { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, P1, P2, P3, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType&, const MultiType&) { (*functionPointer)(param1, param2, param3); return MultiType::Null; } };
     433        template <bool isconst, class P1, class P2>                               struct FunctorCaller<void, void, isconst, P1, P2, void, void, void>     { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, P1, P2, void, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType&, const MultiType&, const MultiType&) { (*functionPointer)(param1, param2); return MultiType::Null; } };
     434        template <bool isconst, class P1>                                         struct FunctorCaller<void, void, isconst, P1, void, void, void, void>   { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, P1, void, void, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType&, const MultiType&, const MultiType&, const MultiType&) { (*functionPointer)(param1); return MultiType::Null; } };
     435        template <bool isconst>                                                   struct FunctorCaller<void, void, isconst, void, void, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, void, void, void, void, void>::Type functionPointer, void*, const MultiType&, const MultiType&, const MultiType&, const MultiType&, const MultiType&) { (*functionPointer)(); return MultiType::Null; } };
    436436
    437437        // Helper class, used to identify the header of a function-pointer (independent of its class)
     
    497497
    498498            // see FunctorMember::operator()()
    499             MultiType operator()(O* object, const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null)
     499            MultiType operator()(O* object, const MultiType& param1 = MultiType::Null, const MultiType& param2 = MultiType::Null, const MultiType& param3 = MultiType::Null, const MultiType& param4 = MultiType::Null, const MultiType& param5 = MultiType::Null)
    500500            {
    501501                return detail::FunctorCaller<R, O, isconst, P1, P2, P3, P4, P5>::call(this->functionPointer_, object, param1, param2, param3, param4, param5);
  • code/branches/testing/src/libraries/tools/Shader.cc

    r8858 r9222  
    161161    void Shader::setParameter(size_t technique, size_t pass, const std::string& parameter, int value)
    162162    {
    163         ParameterContainer container = {technique, pass, parameter, value, 0.0f, MT_Type::Int};
     163        ParameterContainer container = {technique, pass, parameter, value};
    164164        this->parameters_.push_back(container);
    165165        this->addAsListener();
     
    171171    void Shader::setParameter(size_t technique, size_t pass, const std::string& parameter, float value)
    172172    {
    173         ParameterContainer container = {technique, pass, parameter, 0, value, MT_Type::Float};
     173        ParameterContainer container = {technique, pass, parameter, value};
    174174        this->parameters_.push_back(container);
    175175        this->addAsListener();
     
    204204                {
    205205                    // change the value of the parameter depending on its type
    206                     switch (it->valueType_)
    207                     {
    208                         case MT_Type::Int:
    209                             passPtr->getFragmentProgramParameters()->setNamedConstant(it->parameter_, it->valueInt_);
    210                             break;
    211                         case MT_Type::Float:
    212                             passPtr->getFragmentProgramParameters()->setNamedConstant(it->parameter_, it->valueFloat_);
    213                             break;
    214                         default:
    215                             break;
    216                     }
     206                    if (it->value_.isType<int>())
     207                        passPtr->getFragmentProgramParameters()->setNamedConstant(it->parameter_, it->value_.getInt());
     208                    else if (it->value_.isType<float>())
     209                        passPtr->getFragmentProgramParameters()->setNamedConstant(it->parameter_, it->value_.getFloat());
    217210                }
    218211                else
  • code/branches/testing/src/libraries/tools/Shader.h

    r8729 r9222  
    114114                std::string parameter_;     ///< The name of the parameter
    115115
    116                 int valueInt_;              ///< The desired int value of the parameter
    117                 float valueFloat_;          ///< The desired float value of the parameter
    118 
    119                 MT_Type::Value valueType_;  ///< The type of the parameter (currently only int or float)
     116                MultiType value_;           ///< The desired value of the parameter
    120117            };
    121118
  • code/branches/testing/src/libraries/util/MultiType.cc

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

    r9221 r9222  
    111111{
    112112    /**
    113         @brief Enum of all possible types of a MultiType.
    114     */
    115     namespace MT_Type
    116     {
    117         enum Value
    118         {
    119             Null,
    120             Char,
    121             UnsignedChar,
    122             Short,
    123             UnsignedShort,
    124             Int,
    125             UnsignedInt,
    126             Long,
    127             UnsignedLong,
    128             LongLong,
    129             UnsignedLongLong,
    130             Float,
    131             Double,
    132             LongDouble,
    133             Bool,
    134             VoidPointer,
    135             String,
    136             Vector2,
    137             Vector3,
    138             Vector4,
    139             ColourValue,
    140             Quaternion,
    141             Radian,
    142             Degree
    143         };
    144     }
    145 
    146     /**
    147113        @brief The MultiType can hold a value of many possible types and convert them to other types.
    148114
     
    165131        template <typename T> friend class MT_Value;
    166132
     133        struct Type
     134        {
     135            /**
     136                @brief Enum of all possible types of a MultiType.
     137            */
     138            enum Enum
     139            {
     140                Null,
     141                Char,
     142                UnsignedChar,
     143                Short,
     144                UnsignedShort,
     145                Int,
     146                UnsignedInt,
     147                Long,
     148                UnsignedLong,
     149                LongLong,
     150                UnsignedLongLong,
     151                Float,
     152                Double,
     153                LongDouble,
     154                Bool,
     155                VoidPointer,
     156                String,
     157                Vector2,
     158                Vector3,
     159                Vector4,
     160                ColourValue,
     161                Quaternion,
     162                Radian,
     163                Degree
     164            };
     165        };
     166
    167167    public:
    168168        /**
     
    173173        {
    174174        public:
    175             MT_ValueBase(MT_Type::Value type) : type_(type), bHasDefaultValue_(false) {}
     175            MT_ValueBase(Type::Enum type) : type_(type), bHasDefaultValue_(false) {}
    176176            virtual ~MT_ValueBase() {}
    177177
     
    182182
    183183            /// Returns the type of the current value.
    184             const MT_Type::Value& getType() const { return this->type_; }
     184            const Type::Enum& getType() const { return this->type_; }
    185185
    186186            /// Checks whether the value is a default one.
     
    265265            virtual uint8_t getSize() const=0;
    266266
    267             MT_Type::Value type_;   ///< The type of the current value
     267            Type::Enum type_;       ///< The type of the current value
    268268            bool bHasDefaultValue_; ///< True if the last conversion wasn't successful
    269269        };
    270270
    271271        public:
     272            static const MultiType Null;
     273
    272274            inline MultiType()                                  : value_(0) {}                                      ///< Default constructor: Assigns no value and no type. The type will be determined by the first assignment of a value.
    273275            inline MultiType(const char& value)                 : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
     
    297299            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.
    298300            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.
    300301
    301302            /// Destructor: Deletes the MT_Value.
     
    305306            template <typename V> inline MultiType& operator=(V* value)               { this->setValue(value); return (*this); } ///< Assigns a pointer.
    306307            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.
    308308
    309309            inline bool                                   setValue(const char& value);
     
    346346
    347347            /// Copies the other MultiType by assigning value and type.
    348             inline void                       copy(const MultiType& other)    { if (this == &other) { return; } if (this->value_) { delete this->value_; } this->value_ = (other.value_) ? other.value_->clone() : 0; }
     348            inline void                       copy(const MultiType& other) { if (this == &other) { return; } if (this->value_) { delete this->value_; } this->value_ = (other.value_) ? other.value_->clone() : 0; }
    349349
    350350            /// 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()); }
    354             bool                              convert(MT_Type::Value type);
    355 
    356             /// Current content gets deleted. New type is MT_Type::Null
    357             inline void                       reset()                         { if (this->value_) delete this->value_; this->value_ = 0; }
     351            template <typename T> inline bool convert()                    { return this->setValue<T>((typename Loki::TypeTraits<T>::UnqualifiedReferredType)(*this));  }
     352
     353            /// Resets value and type. Type will be void afterwards and null() returns true.
     354            inline void                       reset()                      { if (this->value_) delete this->value_; this->value_ = 0; }
    358355            /// Current content gets overridden with default zero value
    359             inline void                       resetValue()                    { if (this->value_) this->value_->reset(); }
     356            inline void                       resetValue()                 { if (this->value_) this->value_->reset(); }
    360357
    361358            /// 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.
    369             inline MT_Type::Value             getType()                   const { return (this->value_) ? this->value_->type_ : MT_Type::Null; }
    370             /// Returns true if the current type equals the given type.
    371             inline bool                       isType(MT_Type::Value type) const { return (this->value_) ? (this->value_->type_ == type) : (type == MT_Type::Null); }
     359            template <typename T> inline void setType()                    { this->assignValue(typename Loki::TypeTraits<T>::UnqualifiedReferredType()); }
     360
    372361            /// Returns true if the current type is T.
    373             template <typename T> inline bool isType()                    const { return false; } // Only works for specialized values - see below
    374             std::string                       getTypename()               const;
     362            template <typename T> inline bool isType()               const { return false; } // Only works for specialized values - see below
     363            std::string                       getTypename()          const;
    375364
    376365            /// Saves the value of the MT to a bytestream (pointed at by mem) and increases mem pointer by size of MT
    377             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); }
     366            inline void                       exportData(uint8_t*& mem) const { assert(sizeof(Type::Enum)<=8); *static_cast<uint8_t*>(mem) = this->getType(); mem+=sizeof(uint8_t); this->value_->exportData(mem); }
    378367            /// Loads the value of the MT from a bytestream (pointed at by mem) and increases mem pointer by size of MT
    379             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); }
     368            inline void                       importData(uint8_t*& mem) { assert(sizeof(Type::Enum)<=8); this->setType(static_cast<Type::Enum>(*static_cast<uint8_t*>(mem))); mem+=sizeof(uint8_t); this->value_->importData(mem); }
    380369            /// Saves the value of the MT to a bytestream and increases pointer to bytestream by size of MT
    381370            inline uint8_t*&                  operator << (uint8_t*& mem) { importData(mem); return mem; }
     
    466455
    467456        private:
    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.
     457            inline bool assignValue(const char& value)                 { if (this->value_ && this->value_->type_ == Type::Char)             { return this->value_->setValue(value); } else { this->changeValueContainer<char>(value);                 return true; } } ///< Assigns a new value by changing type and creating a new container.
     458            inline bool assignValue(const unsigned char& value)        { if (this->value_ && this->value_->type_ == Type::UnsignedChar)     { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned char>(value);        return true; } } ///< Assigns a new value by changing type and creating a new container.
     459            inline bool assignValue(const short& value)                { if (this->value_ && this->value_->type_ == Type::Short)            { return this->value_->setValue(value); } else { this->changeValueContainer<short>(value);                return true; } } ///< Assigns a new value by changing type and creating a new container.
     460            inline bool assignValue(const unsigned short& value)       { if (this->value_ && this->value_->type_ == Type::UnsignedShort)    { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned short>(value);       return true; } } ///< Assigns a new value by changing type and creating a new container.
     461            inline bool assignValue(const int& value)                  { if (this->value_ && this->value_->type_ == Type::Int)              { return this->value_->setValue(value); } else { this->changeValueContainer<int>(value);                  return true; } } ///< Assigns a new value by changing type and creating a new container.
     462            inline bool assignValue(const unsigned int& value)         { if (this->value_ && this->value_->type_ == Type::UnsignedInt)      { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned int>(value);         return true; } } ///< Assigns a new value by changing type and creating a new container.
     463            inline bool assignValue(const long& value)                 { if (this->value_ && this->value_->type_ == Type::Long)             { return this->value_->setValue(value); } else { this->changeValueContainer<long>(value);                 return true; } } ///< Assigns a new value by changing type and creating a new container.
     464            inline bool assignValue(const unsigned long& value)        { if (this->value_ && this->value_->type_ == Type::UnsignedLong)     { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned long>(value);        return true; } } ///< Assigns a new value by changing type and creating a new container.
     465            inline bool assignValue(const long long& value)            { if (this->value_ && this->value_->type_ == Type::LongLong)         { return this->value_->setValue(value); } else { this->changeValueContainer<long long>(value);            return true; } } ///< Assigns a new value by changing type and creating a new container.
     466            inline bool assignValue(const unsigned long long& value)   { if (this->value_ && this->value_->type_ == Type::UnsignedLongLong) { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned long long>(value);   return true; } } ///< Assigns a new value by changing type and creating a new container.
     467            inline bool assignValue(const float& value)                { if (this->value_ && this->value_->type_ == Type::Float)            { return this->value_->setValue(value); } else { this->changeValueContainer<float>(value);                return true; } } ///< Assigns a new value by changing type and creating a new container.
     468            inline bool assignValue(const double& value)               { if (this->value_ && this->value_->type_ == Type::Double)           { return this->value_->setValue(value); } else { this->changeValueContainer<double>(value);               return true; } } ///< Assigns a new value by changing type and creating a new container.
     469            inline bool assignValue(const long double& value)          { if (this->value_ && this->value_->type_ == Type::LongDouble)       { return this->value_->setValue(value); } else { this->changeValueContainer<long double>(value);          return true; } } ///< Assigns a new value by changing type and creating a new container.
     470            inline bool assignValue(const bool& value)                 { if (this->value_ && this->value_->type_ == Type::Bool)             { return this->value_->setValue(value); } else { this->changeValueContainer<bool>(value);                 return true; } } ///< Assigns a new value by changing type and creating a new container.
     471            inline bool assignValue(      void* const& value)          { if (this->value_ && this->value_->type_ == Type::VoidPointer)      { return this->value_->setValue(value); } else { this->changeValueContainer<void*>(value);                return true; } } ///< Assigns a new value by changing type and creating a new container.
     472            inline bool assignValue(const std::string& value)          { if (this->value_ && this->value_->type_ == Type::String)           { return this->value_->setValue(value); } else { this->changeValueContainer<std::string>(value);          return true; } } ///< Assigns a new value by changing type and creating a new container.
     473            inline bool assignValue(const orxonox::Vector2& value)     { if (this->value_ && this->value_->type_ == Type::Vector2)          { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector2>(value);     return true; } } ///< Assigns a new value by changing type and creating a new container.
     474            inline bool assignValue(const orxonox::Vector3& value)     { if (this->value_ && this->value_->type_ == Type::Vector3)          { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector3>(value);     return true; } } ///< Assigns a new value by changing type and creating a new container.
     475            inline bool assignValue(const orxonox::Vector4& value)     { if (this->value_ && this->value_->type_ == Type::Vector4)          { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector4>(value);     return true; } } ///< Assigns a new value by changing type and creating a new container.
     476            inline bool assignValue(const orxonox::ColourValue& value) { if (this->value_ && this->value_->type_ == Type::ColourValue)      { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::ColourValue>(value); return true; } } ///< Assigns a new value by changing type and creating a new container.
     477            inline bool assignValue(const orxonox::Quaternion& value)  { if (this->value_ && this->value_->type_ == Type::Quaternion)       { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Quaternion>(value);  return true; } } ///< Assigns a new value by changing type and creating a new container.
     478            inline bool assignValue(const orxonox::Radian& value)      { if (this->value_ && this->value_->type_ == Type::Radian)           { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Radian>(value);      return true; } } ///< Assigns a new value by changing type and creating a new container.
     479            inline bool assignValue(const orxonox::Degree& value)      { if (this->value_ && this->value_->type_ == Type::Degree)           { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Degree>(value);      return true; } } ///< Assigns a new value by changing type and creating a new container.
     480
     481            /// Resets the value and changes the internal type to the given type.
     482            inline void       setType(Type::Enum type) { this->reset(); this->convert(type); this->resetValue(); }
     483            /// Returns the current type.
     484            inline Type::Enum getType()          const { return (this->value_) ? this->value_->type_ : Type::Null; }
     485            /// Converts the current value to the given type.
     486            bool              convert(Type::Enum type);
    491487
    492488            /// Changes the value container.
     
    502498
    503499    template <> inline bool MultiType::isType<void>()                 const { return this->null();                                                       } ///< Returns true if the current type equals the given type.
    504     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.
    505     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.
    506     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.
    507     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.
    508     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.
    509     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.
    510     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.
    511     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.
    512     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.
    513     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.
    514     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.
    515     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.
    516     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.
    517     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.
    518     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.
    519     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.
    520     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.
    521     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.
    522     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.
    523     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.
    524     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.
    525     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.
    526     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.
    527 
    528     /// Deletes the content, type becomes MT_Type::Null.
     500    template <> inline bool MultiType::isType<char>()                 const { return (this->value_ && this->value_->type_ == Type::Char);             } ///< Returns true if the current type equals the given type.
     501    template <> inline bool MultiType::isType<unsigned char>()        const { return (this->value_ && this->value_->type_ == Type::UnsignedChar);     } ///< Returns true if the current type equals the given type.
     502    template <> inline bool MultiType::isType<short>()                const { return (this->value_ && this->value_->type_ == Type::Short);            } ///< Returns true if the current type equals the given type.
     503    template <> inline bool MultiType::isType<unsigned short>()       const { return (this->value_ && this->value_->type_ == Type::UnsignedShort);    } ///< Returns true if the current type equals the given type.
     504    template <> inline bool MultiType::isType<int>()                  const { return (this->value_ && this->value_->type_ == Type::Int);              } ///< Returns true if the current type equals the given type.
     505    template <> inline bool MultiType::isType<unsigned int>()         const { return (this->value_ && this->value_->type_ == Type::UnsignedInt);      } ///< Returns true if the current type equals the given type.
     506    template <> inline bool MultiType::isType<long>()                 const { return (this->value_ && this->value_->type_ == Type::Long);             } ///< Returns true if the current type equals the given type.
     507    template <> inline bool MultiType::isType<unsigned long>()        const { return (this->value_ && this->value_->type_ == Type::UnsignedLong);     } ///< Returns true if the current type equals the given type.
     508    template <> inline bool MultiType::isType<long long>()            const { return (this->value_ && this->value_->type_ == Type::LongLong);         } ///< Returns true if the current type equals the given type.
     509    template <> inline bool MultiType::isType<unsigned long long>()   const { return (this->value_ && this->value_->type_ == Type::UnsignedLongLong); } ///< Returns true if the current type equals the given type.
     510    template <> inline bool MultiType::isType<float>()                const { return (this->value_ && this->value_->type_ == Type::Float);            } ///< Returns true if the current type equals the given type.
     511    template <> inline bool MultiType::isType<double>()               const { return (this->value_ && this->value_->type_ == Type::Double);           } ///< Returns true if the current type equals the given type.
     512    template <> inline bool MultiType::isType<long double>()          const { return (this->value_ && this->value_->type_ == Type::LongDouble);       } ///< Returns true if the current type equals the given type.
     513    template <> inline bool MultiType::isType<bool>()                 const { return (this->value_ && this->value_->type_ == Type::Bool);             } ///< Returns true if the current type equals the given type.
     514    template <> inline bool MultiType::isType<void*>()                const { return (this->value_ && this->value_->type_ == Type::VoidPointer);      } ///< Returns true if the current type equals the given type.
     515    template <> inline bool MultiType::isType<std::string>()          const { return (this->value_ && this->value_->type_ == Type::String);           } ///< Returns true if the current type equals the given type.
     516    template <> inline bool MultiType::isType<orxonox::Vector2>()     const { return (this->value_ && this->value_->type_ == Type::Vector2);          } ///< Returns true if the current type equals the given type.
     517    template <> inline bool MultiType::isType<orxonox::Vector3>()     const { return (this->value_ && this->value_->type_ == Type::Vector3);          } ///< Returns true if the current type equals the given type.
     518    template <> inline bool MultiType::isType<orxonox::Vector4>()     const { return (this->value_ && this->value_->type_ == Type::Vector4);          } ///< Returns true if the current type equals the given type.
     519    template <> inline bool MultiType::isType<orxonox::ColourValue>() const { return (this->value_ && this->value_->type_ == Type::ColourValue);      } ///< Returns true if the current type equals the given type.
     520    template <> inline bool MultiType::isType<orxonox::Quaternion>()  const { return (this->value_ && this->value_->type_ == Type::Quaternion);       } ///< Returns true if the current type equals the given type.
     521    template <> inline bool MultiType::isType<orxonox::Radian>()      const { return (this->value_ && this->value_->type_ == Type::Radian);           } ///< Returns true if the current type equals the given type.
     522    template <> inline bool MultiType::isType<orxonox::Degree>()      const { return (this->value_ && this->value_->type_ == Type::Degree);           } ///< Returns true if the current type equals the given type.
     523
     524    /// Deletes the content, type becomes void.
    529525    template <> inline bool MultiType::convert<void>()                 { this->reset(); return true; }
    530526
  • code/branches/testing/src/libraries/util/MultiTypeValue.h

    r8706 r9222  
    5555    public:
    5656        /// Constructor: Assigns the value and the type identifier.
    57         MT_Value(const T& value, MT_Type::Value type) : MT_ValueBase(type), value_(value) {}
     57        MT_Value(const T& value, MultiType::Type::Enum type) : MT_ValueBase(type), value_(value) {}
    5858
    5959        /// Creates a copy of itself.
Note: See TracChangeset for help on using the changeset viewer.