Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

Location:
code/trunk
Files:
45 edited
1 copied

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/libraries/core/CommandLineParser.cc

    r8858 r9550  
    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
     
    6969        else
    7070        {
    71             if (!value_.setValue(value))
    72             {
    73                 value_.setValue(defaultValue_);
     71            if (!value_.set(value))
     72            {
     73                value_.set(defaultValue_);
    7474                ThrowException(Argument, "Could not read command line argument '" + getName() + "'.");
    7575            }
     
    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/trunk/src/libraries/core/CommandLineParser.h

    r8858 r9550  
    200200    inline void CommandLineParser::getValue<std::string>(const std::string& name, std::string* value)
    201201    {
    202         *value = getArgument(name)->getValue().getString();
     202        *value = getArgument(name)->getValue().get<std::string>();
    203203    }
    204204
     
    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).get<bool>() != true,
    220220               "Boolean command line arguments with positive default values are not supported." << endl
    221221            << "Please use SetCommandLineSwitch and adjust your argument: " << name);
  • code/trunk/src/libraries/core/ConfigValueContainer.cc

    r8858 r9550  
    7070        this->bIsVector_ = false;
    7171
    72         this->defvalueString_ = this->value_.getString();
     72        this->defvalueString_ = this->value_.get<std::string>();
    7373        this->update();
    7474    }
     
    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/trunk/src/libraries/core/Core.cc

    r8858 r9550  
    5555#include "util/Exception.h"
    5656#include "util/output/LogWriter.h"
     57#include "util/output/OutputManager.h"
    5758#include "util/Scope.h"
    5859#include "util/ScopedSingletonManager.h"
     
    167168        this->configFileManager_ = new ConfigFileManager();
    168169        this->configFileManager_->setFilename(ConfigFileType::Settings,
    169             CommandLineParser::getValue("settingsFile").getString());
     170            CommandLineParser::getValue("settingsFile").get<std::string>());
    170171
    171172        // Required as well for the config values
     
    180181
    181182        // Set the correct log path and rewrite the log file with the correct log levels
    182         LogWriter::getInstance().setLogPath(PathConfig::getLogPathString());
     183        OutputManager::getInstance().getLogWriter()->setLogDirectory(PathConfig::getLogPathString());
    183184
    184185#if !defined(ORXONOX_PLATFORM_APPLE) && !defined(ORXONOX_USE_WINMAIN)
    185186        // Create persistent IO console
    186         if (CommandLineParser::getValue("noIOConsole").getBool())
     187        if (CommandLineParser::getValue("noIOConsole").get<bool>())
    187188        {
    188189            ModifyConfigValue(bStartIOConsole_, tset, false);
     
    258259    void Core::setConfigValues()
    259260    {
    260         SetConfigValueExternal(LogWriter::getInstance().configurableMaxLevel_,
    261                                LogWriter::getInstance().getConfigurableSectionName(),
    262                                LogWriter::getInstance().getConfigurableMaxLevelName(),
    263                                LogWriter::getInstance().configurableMaxLevel_)
     261        SetConfigValueExternal(OutputManager::getInstance().getLogWriter()->configurableMaxLevel_,
     262                               OutputManager::getInstance().getLogWriter()->getConfigurableSectionName(),
     263                               OutputManager::getInstance().getLogWriter()->getConfigurableMaxLevelName(),
     264                               OutputManager::getInstance().getLogWriter()->configurableMaxLevel_)
    264265            .description("The maximum level of output shown in the log file")
    265             .callback(static_cast<BaseWriter*>(&LogWriter::getInstance()), &BaseWriter::changedConfigurableLevel);
    266         SetConfigValueExternal(LogWriter::getInstance().configurableAdditionalContextsMaxLevel_,
    267                                LogWriter::getInstance().getConfigurableSectionName(),
    268                                LogWriter::getInstance().getConfigurableAdditionalContextsMaxLevelName(),
    269                                LogWriter::getInstance().configurableAdditionalContextsMaxLevel_)
     266            .callback(static_cast<BaseWriter*>(OutputManager::getInstance().getLogWriter()), &BaseWriter::changedConfigurableLevel);
     267        SetConfigValueExternal(OutputManager::getInstance().getLogWriter()->configurableAdditionalContextsMaxLevel_,
     268                               OutputManager::getInstance().getLogWriter()->getConfigurableSectionName(),
     269                               OutputManager::getInstance().getLogWriter()->getConfigurableAdditionalContextsMaxLevelName(),
     270                               OutputManager::getInstance().getLogWriter()->configurableAdditionalContextsMaxLevel_)
    270271            .description("The maximum level of output shown in the log file for additional contexts")
    271             .callback(static_cast<BaseWriter*>(&LogWriter::getInstance()), &BaseWriter::changedConfigurableAdditionalContextsLevel);
    272         SetConfigValueExternal(LogWriter::getInstance().configurableAdditionalContexts_,
    273                                LogWriter::getInstance().getConfigurableSectionName(),
    274                                LogWriter::getInstance().getConfigurableAdditionalContextsName(),
    275                                LogWriter::getInstance().configurableAdditionalContexts_)
     272            .callback(static_cast<BaseWriter*>(OutputManager::getInstance().getLogWriter()), &BaseWriter::changedConfigurableAdditionalContextsLevel);
     273        SetConfigValueExternal(OutputManager::getInstance().getLogWriter()->configurableAdditionalContexts_,
     274                               OutputManager::getInstance().getLogWriter()->getConfigurableSectionName(),
     275                               OutputManager::getInstance().getLogWriter()->getConfigurableAdditionalContextsName(),
     276                               OutputManager::getInstance().getLogWriter()->configurableAdditionalContexts_)
    276277            .description("Additional output contexts shown in the log file")
    277             .callback(static_cast<BaseWriter*>(&LogWriter::getInstance()), &BaseWriter::changedConfigurableAdditionalContexts);
     278            .callback(static_cast<BaseWriter*>(OutputManager::getInstance().getLogWriter()), &BaseWriter::changedConfigurableAdditionalContexts);
    278279
    279280        SetConfigValue(bDevMode_, PathConfig::buildDirectoryRun())
     
    337338    {
    338339        orxout(internal_info) << "loading graphics in Core" << endl;
    339        
     340
    340341        // Any exception should trigger this, even in upgradeToGraphics (see its remarks)
    341342        Loki::ScopeGuard unloader = Loki::MakeObjGuard(*this, &Core::unloadGraphics);
  • code/trunk/src/libraries/core/PathConfig.cc

    r8858 r9550  
    188188            // Check for data path override by the command line
    189189            if (!CommandLineParser::getArgument("externalDataPath")->hasDefaultValue())
    190                 externalDataPath_ = CommandLineParser::getValue("externalDataPath").getString();
     190                externalDataPath_ = CommandLineParser::getValue("externalDataPath").get<std::string>();
    191191            else
    192192                externalDataPath_ = specialConfig::externalDataDevDirectory;
     
    227227        if (!CommandLineParser::getArgument("writingPathSuffix")->hasDefaultValue())
    228228        {
    229             const std::string& directory(CommandLineParser::getValue("writingPathSuffix").getString());
     229            const std::string& directory(CommandLineParser::getValue("writingPathSuffix").get<std::string>());
    230230            configPath_ = configPath_ / directory;
    231231            logPath_    = logPath_    / directory;
  • code/trunk/src/libraries/core/command/CommandEvaluation.cc

    r8858 r9550  
    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
     
    600600            // print the default value if available
    601601            if (command->getExecutor()->defaultValueSet(i))
    602                 output += '=' + command->getExecutor()->getDefaultValue(i).getString() + ']';
     602                output += '=' + command->getExecutor()->getDefaultValue(i).get<std::string>() + ']';
    603603            else
    604604                output += '}';
  • code/trunk/src/libraries/core/command/CommandExecutor.cc

    r8858 r9550  
    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)
     
    133133    /* static */ std::string CommandExecutor::query(const std::string& command, int* error, bool useTcl)
    134134    {
    135         return CommandExecutor::queryMT(command, error, useTcl).getString();
     135        return CommandExecutor::queryMT(command, error, useTcl).get<std::string>();
    136136    }
    137137
  • code/trunk/src/libraries/core/command/ConsoleCommand.h

    r9348 r9550  
    222222#include <stack>
    223223#include <vector>
    224 #include <boost/preprocessor/cat.hpp>
    225 #include <boost/preprocessor/facilities/expand.hpp>
    226224
    227225#include "util/VA_NARGS.h"
  • code/trunk/src/libraries/core/command/Executor.cc

    r8858 r9550  
    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/trunk/src/libraries/core/command/Executor.h

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

    r8858 r9550  
    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/trunk/src/libraries/core/command/IOConsolePOSIX.cc

    r8858 r9550  
    3838#include "util/Math.h"
    3939#include "util/output/ConsoleWriter.h"
     40#include "util/output/OutputManager.h"
    4041#include "core/Game.h"
    4142#include "core/input/InputBuffer.h"
     
    7576
    7677        // Disable standard std::cout logging
    77         ConsoleWriter::getInstance().disable();
     78        OutputManager::getInstance().getConsoleWriter()->disable();
    7879        // Redirect std::cout to an ostringstream
    7980        // (Other part is in the initialiser list)
     
    103104        std::cout.rdbuf(this->cout_.rdbuf());
    104105        // Enable standard std::cout logging again
    105         ConsoleWriter::getInstance().enable();
     106        OutputManager::getInstance().getConsoleWriter()->enable();
    106107    }
    107108
  • code/trunk/src/libraries/core/command/IOConsoleWindows.cc

    r8858 r9550  
    3535#include "util/Math.h"
    3636#include "util/output/ConsoleWriter.h"
     37#include "util/output/OutputManager.h"
    3738#include "core/Game.h"
    3839#include "core/input/InputBuffer.h"
     
    5354    {
    5455        // Disable standard this->cout_ logging
    55         ConsoleWriter::getInstance().disable();
     56        OutputManager::getInstance().getConsoleWriter()->disable();
    5657        // Redirect std::cout to an ostringstream
    5758        // (Other part is in the initialiser list)
     
    109110        std::cout.rdbuf(this->cout_.rdbuf());
    110111        // Enable standard this->cout_ logging again
    111         ConsoleWriter::getInstance().enable();
     112        OutputManager::getInstance().getConsoleWriter()->enable();
    112113
    113114        resetTerminalMode();
  • code/trunk/src/libraries/core/command/Shell.cc

    r8858 r9550  
    8888
    8989        // Get the previous output and add it to the Shell
    90         MemoryWriter::getInstance().resendOutput(this);
     90        OutputManager::getInstance().getMemoryWriter()->resendOutput(this);
    9191    }
    9292
     
    170170        {
    171171            OutputLevel level = (value ? DefaultLogLevel::Dev : DefaultLogLevel::User);
    172             ModifyConfigValueExternal(this->configurableMaxLevel_, this->getConfigurableMaxLevelName(), tset, level);
     172            ModifyConfigValueExternal(this->configurableMaxLevel_, this->getConfigurableMaxLevelName(), tset, static_cast<int>(level));
    173173        }
    174174    }
  • code/trunk/src/libraries/core/command/TclBind.cc

    r8858 r9550  
    183183
    184184        if (bQuery)
    185             result = evaluation.query(&error).getString();
     185            result = evaluation.query(&error).get<std::string>();
    186186        else
    187187            error = evaluation.execute();
  • code/trunk/src/libraries/core/input/InputManager.cc

    r8858 r9550  
    176176        if (exclusiveMouse_ || GraphicsManager::getInstance().isFullScreen())
    177177        {
    178             if (CommandLineParser::getValue("keyboard_no_grab").getBool())
     178            if (CommandLineParser::getValue("keyboard_no_grab").get<bool>())
    179179                paramList.insert(StringPair("x11_keyboard_grab", "false"));
    180180            else
  • code/trunk/src/libraries/network/Client.cc

    r8858 r9550  
    6868      timeSinceLastUpdate_(0)
    6969  {
    70     this->setDestination( CommandLineParser::getValue("dest").getString(), CommandLineParser::getValue("port") );
     70    this->setDestination( CommandLineParser::getValue("dest").get<std::string>(), CommandLineParser::getValue("port") );
    7171  }
    7272
  • code/trunk/src/libraries/tools/Shader.cc

    r8858 r9550  
    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_.get<int>());
     208                    else if (it->value_.isType<float>())
     209                        passPtr->getFragmentProgramParameters()->setNamedConstant(it->parameter_, it->value_.get<float>());
    217210                }
    218211                else
  • code/trunk/src/libraries/tools/Shader.h

    r8729 r9550  
    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/trunk/src/libraries/util/Math.h

    r8729 r9550  
    139139    {
    140140        return x*x*x;
    141     }
    142 
    143     /**
    144         @brief Rounds the value to the nearest integer.
    145     */
    146     template <typename T>
    147     inline int round(T x)
    148     {
    149         return static_cast<int>(x + 0.5);
    150141    }
    151142
     
    247238    inline T interpolate(float time, const T& start, const T& end)
    248239    {
    249         return time * (end - start) + start;
     240        return static_cast<T>(time * (end - start) + start);
    250241    }
    251242
     
    260251    inline T interpolateSmooth(float time, const T& start, const T& end)
    261252    {
    262         return (-2 * (end - start) * cube(time)) + (3 * (end - start) * square(time)) + start;
     253        return static_cast<T>((-2 * (end - start) * cube(time)) + (3 * (end - start) * square(time)) + start);
    263254    }
    264255
  • code/trunk/src/libraries/util/MultiType.cc

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

    r8858 r9550  
    5151     - @ref orxonox::MultiType::MultiType "The constructor"
    5252     - The assignment operator= (orxonox::MultiType::operator=())
    53      - @ref orxonox::MultiType::setValue() "setValue(value)"
     53     - @ref orxonox::MultiType::set() "set(value)"
    5454
    5555    If you assign another value of another type, the MultiType keeps "its" type and
     
    5858    If you want to change the type, there are three possibilities:
    5959     - @ref orxonox::MultiType::convert "convert<T>()" sets the type to T and converts the currently assigned value
    60      - @ref orxonox::MultiType::setType "setType<T>()" sets the type to T and resets the value to zero using zeroise<T>()
    61      - setValue<T>(value) assigns a new value and changes the type to T.
     60     - @ref orxonox::MultiType::reset "reset<T>()" sets the type to T and resets the value to zero using zeroise<T>()
     61     - force<T>(value) assigns a new value and changes the type to T.
    6262
    6363    Examples:
    6464    @code
    65     MultiType a = 10;          // a has now the type int and the value 10
    66     a.setValue("3.14");        // a has still the type int and "3.14" gets converted, therefore the value is now 3
    67     a.setValue<float>("3.14"); // a has now the type float and "3.14" gets converted to 3.14f
    68     a.convert<bool>();         // converts 3.14f to bool, which is true
    69     a = false;                 // assigns false, this is equivalent to a.setValue(false)
     65    MultiType a = 10;       // a has now the type int and the value 10
     66    a.set("3.14");          // a has still the type int and "3.14" gets converted, therefore the value is now 3
     67    a.force<float>("3.14"); // a has now the type float and "3.14" gets converted to 3.14f
     68    a.convert<bool>();      // converts 3.14f to bool, which is true
     69    a = false;              // assigns false, this is equivalent to a.setValue(false)
    7070    @endcode
    7171
     
    106106#include <OgreColourValue.h>
    107107#include <loki/TypeTraits.h>
     108#include "Math.h"
    108109#include "mbool.h"
    109110
    110111namespace orxonox
    111112{
    112     /**
    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 
    146113    /**
    147114        @brief The MultiType can hold a value of many possible types and convert them to other types.
     
    165132        template <typename T> friend class MT_Value;
    166133
     134        struct Type
     135        {
     136            /**
     137                @brief Enum of all possible types of a MultiType.
     138            */
     139            enum Enum
     140            {
     141                Null,
     142                Char,
     143                UnsignedChar,
     144                Short,
     145                UnsignedShort,
     146                Int,
     147                UnsignedInt,
     148                Long,
     149                UnsignedLong,
     150                LongLong,
     151                UnsignedLongLong,
     152                Float,
     153                Double,
     154                LongDouble,
     155                Bool,
     156                VoidPointer,
     157                String,
     158                Vector2,
     159                Vector3,
     160                Vector4,
     161                ColourValue,
     162                Quaternion,
     163                Radian,
     164                Degree
     165            };
     166        };
     167
    167168    public:
    168169        /**
     
    173174        {
    174175        public:
    175             MT_ValueBase(MT_Type::Value type) : type_(type), bHasDefaultValue_(false) {}
    176             virtual ~MT_ValueBase() {}
     176            inline MT_ValueBase(void* data, Type::Enum type) : type_(type), bLastConversionSuccessful(true), data_(data) {}
     177            inline virtual ~MT_ValueBase() {}
    177178
    178179            virtual MT_ValueBase* clone() const = 0;
    179180
    180181            virtual void reset() = 0;
    181             virtual bool assimilate(const MultiType& other) = 0;
    182182
    183183            /// Returns the type of the current value.
    184             const MT_Type::Value& getType() const { return this->type_; }
     184            inline const Type::Enum& getType() const { return this->type_; }
     185            /// Returns true if the type of the stored value is T.
     186            template <typename T> inline bool isType() const { return false; }
    185187
    186188            /// Checks whether the value is a default one.
    187             bool hasDefaultValue()   const { return this->bHasDefaultValue_; }
     189            inline bool lastConversionSuccessful()   const { return this->bLastConversionSuccessful; }
    188190
    189191            virtual bool setValue(const char& value)                 = 0;
     
    211213            virtual bool setValue(const orxonox::Degree& value)      = 0;
    212214
     215            virtual bool setValue(const MultiType& other)            = 0;
     216
    213217            virtual bool getValue(char*                 value) const = 0;
    214218            virtual bool getValue(unsigned char*        value) const = 0;
     
    235239            virtual bool getValue(orxonox::Degree*      value) const = 0;
    236240
    237             virtual operator char()                 const = 0;
    238             virtual operator unsigned char()        const = 0;
    239             virtual operator short()                const = 0;
    240             virtual operator unsigned short()       const = 0;
    241             virtual operator int()                  const = 0;
    242             virtual operator unsigned int()         const = 0;
    243             virtual operator long()                 const = 0;
    244             virtual operator unsigned long()        const = 0;
    245             virtual operator long long()            const = 0;
    246             virtual operator unsigned long long()   const = 0;
    247             virtual operator float()                const = 0;
    248             virtual operator double()               const = 0;
    249             virtual operator long double()          const = 0;
    250             virtual operator bool()                 const = 0;
    251             virtual operator void*()                const = 0;
    252             virtual operator std::string()          const = 0;
    253             virtual operator orxonox::Vector2()     const = 0;
    254             virtual operator orxonox::Vector3()     const = 0;
    255             virtual operator orxonox::Vector4()     const = 0;
    256             virtual operator orxonox::ColourValue() const = 0;
    257             virtual operator orxonox::Quaternion()  const = 0;
    258             virtual operator orxonox::Radian()      const = 0;
    259             virtual operator orxonox::Degree()      const = 0;
     241            template <typename T> T get() const
     242            {
     243                if (this->isType<T>())
     244                    return *reinterpret_cast<const T*>(this->data_);
     245                else
     246                {
     247                    T value;
     248                    this->getValue(&value);
     249                    return value;
     250                }
     251            }
    260252
    261253            virtual void toString(std::ostream& outstream) const = 0;
    262254
    263             virtual void importData( uint8_t*& mem )=0;
    264             virtual void exportData( uint8_t*& mem ) const=0;
    265             virtual uint8_t getSize() const=0;
    266 
    267             MT_Type::Value type_;   ///< The type of the current value
    268             bool bHasDefaultValue_; ///< True if the last conversion wasn't successful
     255            virtual void importData(uint8_t*& mem) = 0;
     256            virtual void exportData(uint8_t*& mem) const = 0;
     257            virtual uint8_t getSize() const = 0;
     258
     259            Type::Enum type_;               ///< The type of the current value
     260            bool bLastConversionSuccessful; ///< True if the last conversion was successful
     261            void* data_;                    ///< For direct access to the value if the type is known
    269262        };
    270263
    271264        public:
    272             inline MultiType()                                  : value_(0) {}                                      ///< Default constructor: Assigns no value and no type. The type will be determined by the first assignment of a value.
    273             inline MultiType(const char& value)                 : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    274             inline MultiType(const unsigned char& value)        : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    275             inline MultiType(const short& value)                : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    276             inline MultiType(const unsigned short& value)       : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    277             inline MultiType(const int& value)                  : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    278             inline MultiType(const unsigned int& value)         : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    279             inline MultiType(const long& value)                 : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    280             inline MultiType(const unsigned long& value)        : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    281             inline MultiType(const long long& value)            : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    282             inline MultiType(const unsigned long long& value)   : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    283             inline MultiType(const float& value)                : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    284             inline MultiType(const double& value)               : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    285             inline MultiType(const long double& value)          : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    286             inline MultiType(const bool& value)                 : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    287             inline MultiType(      void* const& value)          : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    288             inline MultiType(const std::string& value)          : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    289             inline MultiType(const orxonox::Vector2& value)     : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    290             inline MultiType(const orxonox::Vector3& value)     : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    291             inline MultiType(const orxonox::Vector4& value)     : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    292             inline MultiType(const orxonox::ColourValue& value) : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    293             inline MultiType(const orxonox::Quaternion& value)  : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    294             inline MultiType(const orxonox::Radian& value)      : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    295             inline MultiType(const orxonox::Degree& value)      : value_(0) { this->assignValue(value); }           ///< Constructor: Assigns the given value and sets the type.
    296             inline MultiType(const orxonox::mbool& value)       : value_(0) { this->assignValue((bool)value); }     ///< Constructor: Assigns the given mbool and converts it to bool.
    297             inline MultiType(const char* value)                 : value_(0) { this->setValue(std::string(value)); } ///< Constructor: Converts the char array to a std::string, assigns the value and sets the type.
    298             inline MultiType(const MultiType& other)            : value_(0) { this->setValue(other); }              ///< Copyconstructor: Assigns value and type of the other MultiType.
    299             inline MultiType(MT_Type::Value type)               : value_(0) { this->setType(type); }                ///< Constructor: Sets the type, the next assignment will determine the value.
     265            static const MultiType Null;
     266
     267            /// Default constructor: Assigns no value and no type. The type will be determined by the first assignment of a value.
     268            inline MultiType()                       : value_(0) { }
     269            /// Constructor: Assigns the given value and sets the type.
     270            template <typename V>
     271            inline MultiType(const V& value)         : value_(0) { this->set(value); }
     272            /// Copyconstructor: Assigns value and type of the other MultiType.
     273            inline MultiType(const MultiType& other) : value_(0) { this->set(other); }
    300274
    301275            /// Destructor: Deletes the MT_Value.
    302276            inline ~MultiType() { if (this->value_) { delete this->value_; } }
    303277
    304             template <typename V> inline MultiType& operator=(const V& value)         { this->setValue(value); return (*this); } ///< Assigns a new value. The value will be converted to the current type of the MultiType.
    305             template <typename V> inline MultiType& operator=(V* value)               { this->setValue(value); return (*this); } ///< Assigns a pointer.
    306             inline                       MultiType& operator=(const MultiType& other) { this->setValue(other); return (*this); } ///< Assigns the value of the other MultiType and converts it to the current type of the MultiType.
    307             inline                       MultiType& operator=(MT_Type::Value type)    { this->setType(type);   return (*this); } ///< Resets the value and changes the type.
    308 
    309             inline bool                                   setValue(const char& value);
    310             inline bool                                   setValue(const unsigned char& value);
    311             inline bool                                   setValue(const short& value);
    312             inline bool                                   setValue(const unsigned short& value);
    313             inline bool                                   setValue(const int& value);
    314             inline bool                                   setValue(const unsigned int& value);
    315             inline bool                                   setValue(const long& value);
    316             inline bool                                   setValue(const unsigned long& value);
    317             inline bool                                   setValue(const long long& value);
    318             inline bool                                   setValue(const unsigned long long& value);
    319             inline bool                                   setValue(const float& value);
    320             inline bool                                   setValue(const double& value);
    321             inline bool                                   setValue(const long double& value);
    322             inline bool                                   setValue(const bool& value);
    323             inline bool                                   setValue(      void* const& value);
    324             inline bool                                   setValue(const std::string& value);
    325             inline bool                                   setValue(const orxonox::Vector2& value);
    326             inline bool                                   setValue(const orxonox::Vector3& value);
    327             inline bool                                   setValue(const orxonox::Vector4& value);
    328             inline bool                                   setValue(const orxonox::ColourValue& value);
    329             inline bool                                   setValue(const orxonox::Quaternion& value);
    330             inline bool                                   setValue(const orxonox::Radian& value);
    331             inline bool                                   setValue(const orxonox::Degree& value);
    332             inline bool                                   setValue(const char* value);
     278            /// Assigns a new value. The value will be converted to the current type of the MultiType.
     279            template <typename V> inline MultiType& operator=(const V& value)         { this->set(value); return (*this); }
    333280            /// Assigns a pointer.
    334             template <typename V> inline bool setValue(V* value)
     281            template <typename V> inline MultiType& operator=(V* value)               { this->set(value); return (*this); }
     282            /// Assigns the value of the other MultiType and converts it to the current type of the MultiType.
     283            inline                       MultiType& operator=(const MultiType& other) { this->set(other); return (*this); }
     284
     285            /// Assigns the given value and converts it to the current type.
     286            template <typename V> inline bool set(const V& value)
     287            {
     288                if (this->value_)
     289                    return this->value_->setValue(value);
     290
     291                this->assignValue(value);
     292                return true;
     293            }
     294            /// Assigns a pointer.
     295            template <typename V> inline bool set(V* value)
    335296            {
    336297                if (this->value_)
    337298                    return this->value_->setValue(static_cast<void*>(const_cast<typename Loki::TypeTraits<V>::UnqualifiedType*>(value)));
    338                 else
    339                     return this->assignValue     (static_cast<void*>(const_cast<typename Loki::TypeTraits<V>::UnqualifiedType*>(value)));
     299
     300                this->assignValue(static_cast<void*>(const_cast<typename Loki::TypeTraits<V>::UnqualifiedType*>(value)));
     301                return true;
    340302            }
    341303            /// Assigns the value of the other MultiType and converts it to the current type.
    342             bool                                          setValue(const MultiType& other) { if (this->value_) { return this->value_->assimilate(other); } else { if (other.value_) { this->value_ = other.value_->clone(); } return true; } }
     304            inline bool set(const MultiType& other)
     305            {
     306                if (this->value_)
     307                    return this->value_->setValue(other);
     308                else if (other.value_)
     309                    this->value_ = other.value_->clone();
     310                return true;
     311            }
     312
    343313            /// Changes the type to T and assigns the new value (which might be of another type than T - it gets converted).
    344             template <typename T, typename V> inline bool setValue(const V& value) { this->setType<T>(); return this->setValue(value); }
    345 
     314            template <typename T, typename V> inline bool force(const V& value)
     315            {
     316                this->reset<T>();
     317                return this->set(value);
     318            }
    346319
    347320            /// 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; }
     321            inline void copy(const MultiType& other)
     322            {
     323                if (this == &other)
     324                    return;
     325                if (this->value_)
     326                    delete this->value_;
     327                this->value_ = (other.value_) ? other.value_->clone() : 0;
     328            }
    349329
    350330            /// 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; }
    358             /// Current content gets overridden with default zero value
    359             inline void                       resetValue()                    { if (this->value_) this->value_->reset(); }
    360 
     331            template <typename T> inline bool convert() { return this->force<T>(MultiType(*this)); }
     332
     333            /// Resets value and type. Type will be void afterwards and null() returns true.
     334            inline void reset() { if (this->value_) delete this->value_; this->value_ = 0; }
    361335            /// 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); }
    372             /// 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;
    375 
    376             /// 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); }
    378             /// 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); }
    380             /// Saves the value of the MT to a bytestream and increases pointer to bytestream by size of MT
    381             inline uint8_t*&                  operator << (uint8_t*& mem) { importData(mem); return mem; }
    382             /// Loads the value of the MT to a bytestream and increases pointer to bytestream by size of MT
    383             inline void                       operator >> (uint8_t*& mem) const { exportData(mem); }
    384             inline uint32_t                   getNetworkSize() const { assert(this->value_); return this->value_->getSize() + sizeof(uint8_t); }
    385 
    386             /// Checks whether the value is a default one (assigned after a failed conversion)
    387             bool                              hasDefaultValue() const { return this->value_->hasDefaultValue(); }
     336            template <typename T> inline void reset() { this->assignValue(typename Loki::TypeTraits<T>::UnqualifiedReferredType()); }
     337            /// Current value gets overridden with default zero value
     338            inline void resetValue() { if (this->value_) this->value_->reset(); }
     339
     340            /// Returns true if the type of the current value is T.
     341            template <typename T> inline bool isType() const { return (this->value_ ? this->value_->isType<T>() : false); }
     342            std::string getTypename() const;
     343
     344            /// Checks whether the last conversion was successful
     345            inline bool lastConversionSuccessful() const { return !this->value_ || this->value_->lastConversionSuccessful(); }
    388346
    389347            /// Checks if the MT contains no value.
    390             bool                              null() const { return (!this->value_); }
    391 
    392             operator char()                  const;
    393             operator unsigned char()         const;
    394             operator short()                 const;
    395             operator unsigned short()        const;
    396             operator int()                   const;
    397             operator unsigned int()          const;
    398             operator long()                  const;
    399             operator unsigned long()         const;
    400             operator long long()             const;
    401             operator unsigned long long()    const;
    402             operator float()                 const;
    403             operator double()                const;
    404             operator long double()           const;
    405             operator bool()                  const;
    406             operator void*()                 const;
    407             operator std::string()           const;
    408             operator orxonox::Vector2()      const;
    409             operator orxonox::Vector3()      const;
    410             operator orxonox::Vector4()      const;
    411             operator orxonox::ColourValue()  const;
    412             operator orxonox::Quaternion()   const;
    413             operator orxonox::Radian()       const;
    414             operator orxonox::Degree()       const;
     348            inline bool null() const { return !this->value_; }
     349
     350            inline operator char()                 const { return (this->value_ ? this->value_->get<char>()                 : 0); }
     351            inline operator unsigned char()        const { return (this->value_ ? this->value_->get<unsigned char>()        : 0); }
     352            inline operator short()                const { return (this->value_ ? this->value_->get<short>()                : 0); }
     353            inline operator unsigned short()       const { return (this->value_ ? this->value_->get<unsigned short>()       : 0); }
     354            inline operator int()                  const { return (this->value_ ? this->value_->get<int>()                  : 0); }
     355            inline operator unsigned int()         const { return (this->value_ ? this->value_->get<unsigned int>()         : 0); }
     356            inline operator long()                 const { return (this->value_ ? this->value_->get<long>()                 : 0); }
     357            inline operator unsigned long()        const { return (this->value_ ? this->value_->get<unsigned long>()        : 0); }
     358            inline operator long long()            const { return (this->value_ ? this->value_->get<long long>()            : 0); }
     359            inline operator unsigned long long()   const { return (this->value_ ? this->value_->get<unsigned long long>()   : 0); }
     360            inline operator float()                const { return (this->value_ ? this->value_->get<float>()                : 0); }
     361            inline operator double()               const { return (this->value_ ? this->value_->get<double>()               : 0); }
     362            inline operator long double()          const { return (this->value_ ? this->value_->get<long double>()          : 0); }
     363            inline operator bool()                 const { return (this->value_ ? this->value_->get<bool>()                 : 0); }
     364            inline operator void*()                const { return (this->value_ ? this->value_->get<void*>()                : 0); }
     365            inline operator std::string()          const { return (this->value_ ? this->value_->get<std::string>()          : NilValue<std::string>()); }
     366            inline operator orxonox::Vector2()     const { return (this->value_ ? this->value_->get<orxonox::Vector2>()     : NilValue<orxonox::Vector2>()); }
     367            inline operator orxonox::Vector3()     const { return (this->value_ ? this->value_->get<orxonox::Vector3>()     : NilValue<orxonox::Vector3>()); }
     368            inline operator orxonox::Vector4()     const { return (this->value_ ? this->value_->get<orxonox::Vector4>()     : NilValue<orxonox::Vector4>()); }
     369            inline operator orxonox::ColourValue() const { return (this->value_ ? this->value_->get<orxonox::ColourValue>() : NilValue<orxonox::ColourValue>()); }
     370            inline operator orxonox::Quaternion()  const { return (this->value_ ? this->value_->get<orxonox::Quaternion>()  : NilValue<orxonox::Quaternion>()); }
     371            inline operator orxonox::Radian()      const { return (this->value_ ? this->value_->get<orxonox::Radian>()      : NilValue<orxonox::Radian>()); }
     372            inline operator orxonox::Degree()      const { return (this->value_ ? this->value_->get<orxonox::Degree>()      : NilValue<orxonox::Degree>()); }
    415373            /// Returns the current value, converted to a T* pointer.
    416374            template <class T> operator T*() const { return (static_cast<T*>(this->operator void*())); }
    417375
    418             inline bool getValue(char*                 value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    419             inline bool getValue(unsigned char*        value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    420             inline bool getValue(short*                value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    421             inline bool getValue(unsigned short*       value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    422             inline bool getValue(int*                  value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    423             inline bool getValue(unsigned int*         value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    424             inline bool getValue(long*                 value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    425             inline bool getValue(unsigned long*        value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    426             inline bool getValue(long long*            value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    427             inline bool getValue(unsigned long long*   value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    428             inline bool getValue(float*                value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    429             inline bool getValue(double*               value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    430             inline bool getValue(long double*          value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    431             inline bool getValue(bool*                 value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    432             inline bool getValue(void**                value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    433             inline bool getValue(std::string*          value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    434             inline bool getValue(orxonox::Vector2*     value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    435             inline bool getValue(orxonox::Vector3*     value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    436             inline bool getValue(orxonox::Vector4*     value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    437             inline bool getValue(orxonox::ColourValue* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    438             inline bool getValue(orxonox::Quaternion*  value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    439             inline bool getValue(orxonox::Radian*      value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    440             inline bool getValue(orxonox::Degree*      value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    441 
    442             inline char                     getChar()             const { return this->operator char();                 } ///< Returns the current value, converted to the requested type.
    443             inline unsigned char            getUnsignedChar()     const { return this->operator unsigned char();        } ///< Returns the current value, converted to the requested type.
    444             inline short                    getShort()            const { return this->operator short();                } ///< Returns the current value, converted to the requested type.
    445             inline unsigned short           getUnsignedShort()    const { return this->operator unsigned short();       } ///< Returns the current value, converted to the requested type.
    446             inline int                      getInt()              const { return this->operator int();                  } ///< Returns the current value, converted to the requested type.
    447             inline unsigned int             getUnsignedInt()      const { return this->operator unsigned int();         } ///< Returns the current value, converted to the requested type.
    448             inline long                     getLong()             const { return this->operator long();                 } ///< Returns the current value, converted to the requested type.
    449             inline unsigned long            getUnsignedLong()     const { return this->operator unsigned long();        } ///< Returns the current value, converted to the requested type.
    450             inline long long                getLongLong()         const { return this->operator long long();            } ///< Returns the current value, converted to the requested type.
    451             inline unsigned long long       getUnsignedLongLong() const { return this->operator unsigned long long();   } ///< Returns the current value, converted to the requested type.
    452             inline float                    getFloat()            const { return this->operator float();                } ///< Returns the current value, converted to the requested type.
    453             inline double                   getDouble()           const { return this->operator double();               } ///< Returns the current value, converted to the requested type.
    454             inline long double              getLongDouble()       const { return this->operator long double();          } ///< Returns the current value, converted to the requested type.
    455             inline bool                     getBool()             const { return this->operator bool();                 } ///< Returns the current value, converted to the requested type.
    456             inline void*                    getVoid()             const { return this->operator void*();                } ///< Returns the current value, converted to the requested type.
    457             inline std::string              getString()           const { return this->operator std::string();          } ///< Returns the current value, converted to the requested type.
    458             inline orxonox::Vector2         getVector2()          const { return this->operator orxonox::Vector2();     } ///< Returns the current value, converted to the requested type.
    459             inline orxonox::Vector3         getVector3()          const { return this->operator orxonox::Vector3();     } ///< Returns the current value, converted to the requested type.
    460             inline orxonox::Vector4         getVector4()          const { return this->operator orxonox::Vector4();     } ///< Returns the current value, converted to the requested type.
    461             inline orxonox::ColourValue     getColourValue()      const { return this->operator orxonox::ColourValue(); } ///< Returns the current value, converted to the requested type.
    462             inline orxonox::Quaternion      getQuaternion()       const { return this->operator orxonox::Quaternion();  } ///< Returns the current value, converted to the requested type.
    463             inline orxonox::Radian          getRadian()           const { return this->operator orxonox::Radian();      } ///< Returns the current value, converted to the requested type.
    464             inline orxonox::Degree          getDegree()           const { return this->operator orxonox::Degree();      } ///< Returns the current value, converted to the requested type.
    465             template <typename T> inline T* getPointer()          const { return static_cast<T*>(this->getVoid());      } ///< Returns the current value, converted to a T* pointer.
     376            /// Assigns the value to the given pointer. The value gets converted if the types don't match.
     377            template <typename T> inline bool getValue(T* value) const { if (this->value_) { return this->value_->getValue(value); } return false; }
     378
     379            /// Returns the current value, converted to the requested type.
     380            template <typename T> inline T get() const { return *this; }
     381
     382
     383            ///////////////////////////////
     384            // network-related functions //
     385            ///////////////////////////////
     386            /// Saves the value of the MT to a bytestream (pointed at by mem) and increases mem pointer by size of MT
     387            inline void exportData(uint8_t*& mem) const
     388            {
     389                assert(sizeof(Type::Enum) <= 8);
     390                *static_cast<uint8_t*>(mem) = this->getType();
     391                mem += sizeof(uint8_t);
     392                this->value_->exportData(mem);
     393            }
     394            /// Loads the value of the MT from a bytestream (pointed at by mem) and increases mem pointer by size of MT
     395            inline void importData(uint8_t*& mem)
     396            {
     397                assert(sizeof(Type::Enum) <= 8);
     398                this->setType(static_cast<Type::Enum>(*static_cast<uint8_t*>(mem)));
     399                mem += sizeof(uint8_t);
     400                this->value_->importData(mem);
     401            }
     402            /// Saves the value of the MT to a bytestream and increases pointer to bytestream by size of MT
     403            inline uint8_t*& operator<<(uint8_t*& mem)
     404            {
     405                importData(mem);
     406                return mem;
     407            }
     408            /// Loads the value of the MT to a bytestream and increases pointer to bytestream by size of MT
     409            inline void operator>>(uint8_t*& mem) const
     410            {
     411                exportData(mem);
     412            }
     413            inline uint32_t getNetworkSize() const
     414            {
     415                assert(this->value_);
     416                return this->value_->getSize() + sizeof(uint8_t);
     417            }
    466418
    467419        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.
     420            /// Assigns a new value by changing type and creating a new container.
     421            template <typename T> inline void assignValue(const T& value)
     422            {
     423                if (this->isType<T>())
     424                    this->value_->setValue(value);
     425                else
     426                    this->changeValueContainer(value);
     427            }
     428            /// Assigns a new value by changing type and creating a new container (overload for pointers).
     429            template <typename T> inline void assignValue(T* const& value)
     430            {
     431                if (this->isType<void*>())
     432                    this->value_->setValue(static_cast<void*>(value));
     433                else
     434                    this->changeValueContainer<void*>(value);
     435            }
     436
     437            /// Resets the value and changes the internal type to the given type.
     438            inline void setType(Type::Enum type) { this->reset(); this->convert(type); this->resetValue(); }
     439            /// Returns the current type.
     440            inline Type::Enum getType() const { return (this->value_) ? this->value_->type_ : Type::Null; }
     441            /// Converts the current value to the given type.
     442            bool convert(Type::Enum type);
    491443
    492444            /// Changes the value container.
    493             template <typename T> inline void changeValueContainer(const T& value) { if (this->value_) { delete this->value_; } this->createNewValueContainer<T>(value); }
     445            template <typename T> inline void changeValueContainer(const T& value)
     446            {
     447                if (this->value_)
     448                    delete this->value_;
     449                this->createNewValueContainer(value);
     450            }
    494451            /// Creates a new value container (works only with specialized types).
    495             template <typename T>       void createNewValueContainer(const T& value) { /* STATIC ASSERT */ *****value; return false; }
     452            template <typename T> inline void createNewValueContainer(const T& value) { /* STATIC ASSERT */ *****value; return false; }
    496453
    497454            MT_ValueBase* value_; //!< A pointer to the value container
     
    499456
    500457    /// Puts the MultiType on a stream by using the native << operator of the current type.
    501     _UtilExport inline std::ostream& operator<<(std::ostream& outstream, const MultiType& mt) { if (mt.value_) { mt.value_->toString(outstream); } return outstream; }
    502 
    503     template <> inline bool MultiType::isType<char>()                 const { return (this->value_ && this->value_->type_ == MT_Type::Char);             } ///< Returns true if the current type equals the given type.
    504     template <> inline bool MultiType::isType<unsigned char>()        const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedChar);     } ///< Returns true if the current type equals the given type.
    505     template <> inline bool MultiType::isType<short>()                const { return (this->value_ && this->value_->type_ == MT_Type::Short);            } ///< Returns true if the current type equals the given type.
    506     template <> inline bool MultiType::isType<unsigned short>()       const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedShort);    } ///< Returns true if the current type equals the given type.
    507     template <> inline bool MultiType::isType<int>()                  const { return (this->value_ && this->value_->type_ == MT_Type::Int);              } ///< Returns true if the current type equals the given type.
    508     template <> inline bool MultiType::isType<unsigned int>()         const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedInt);      } ///< Returns true if the current type equals the given type.
    509     template <> inline bool MultiType::isType<long>()                 const { return (this->value_ && this->value_->type_ == MT_Type::Long);             } ///< Returns true if the current type equals the given type.
    510     template <> inline bool MultiType::isType<unsigned long>()        const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedLong);     } ///< Returns true if the current type equals the given type.
    511     template <> inline bool MultiType::isType<long long>()            const { return (this->value_ && this->value_->type_ == MT_Type::LongLong);         } ///< Returns true if the current type equals the given type.
    512     template <> inline bool MultiType::isType<unsigned long long>()   const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedLongLong); } ///< Returns true if the current type equals the given type.
    513     template <> inline bool MultiType::isType<float>()                const { return (this->value_ && this->value_->type_ == MT_Type::Float);            } ///< Returns true if the current type equals the given type.
    514     template <> inline bool MultiType::isType<double>()               const { return (this->value_ && this->value_->type_ == MT_Type::Double);           } ///< Returns true if the current type equals the given type.
    515     template <> inline bool MultiType::isType<long double>()          const { return (this->value_ && this->value_->type_ == MT_Type::LongDouble);       } ///< Returns true if the current type equals the given type.
    516     template <> inline bool MultiType::isType<bool>()                 const { return (this->value_ && this->value_->type_ == MT_Type::Bool);             } ///< Returns true if the current type equals the given type.
    517     template <> inline bool MultiType::isType<void*>()                const { return (this->value_ && this->value_->type_ == MT_Type::VoidPointer);      } ///< Returns true if the current type equals the given type.
    518     template <> inline bool MultiType::isType<std::string>()          const { return (this->value_ && this->value_->type_ == MT_Type::String);           } ///< Returns true if the current type equals the given type.
    519     template <> inline bool MultiType::isType<orxonox::Vector2>()     const { return (this->value_ && this->value_->type_ == MT_Type::Vector2);          } ///< Returns true if the current type equals the given type.
    520     template <> inline bool MultiType::isType<orxonox::Vector3>()     const { return (this->value_ && this->value_->type_ == MT_Type::Vector3);          } ///< Returns true if the current type equals the given type.
    521     template <> inline bool MultiType::isType<orxonox::Vector4>()     const { return (this->value_ && this->value_->type_ == MT_Type::Vector4);          } ///< Returns true if the current type equals the given type.
    522     template <> inline bool MultiType::isType<orxonox::ColourValue>() const { return (this->value_ && this->value_->type_ == MT_Type::ColourValue);      } ///< Returns true if the current type equals the given type.
    523     template <> inline bool MultiType::isType<orxonox::Quaternion>()  const { return (this->value_ && this->value_->type_ == MT_Type::Quaternion);       } ///< Returns true if the current type equals the given type.
    524     template <> inline bool MultiType::isType<orxonox::Radian>()      const { return (this->value_ && this->value_->type_ == MT_Type::Radian);           } ///< Returns true if the current type equals the given type.
    525     template <> inline bool MultiType::isType<orxonox::Degree>()      const { return (this->value_ && this->value_->type_ == MT_Type::Degree);           } ///< Returns true if the current type equals the given type.
    526 
    527     /// Deletes the content, type becomes MT_Type::Null.
    528     template <> inline bool MultiType::convert<void>()                 { this->reset(); return true; }
    529 
    530     // Specialization to avoid ambiguities with the conversion operator
    531     template <> inline bool MultiType::convert<std::string>()          { return this->setValue<std::string>         (this->operator std::string());          } ///< Converts the current value to the given type.
    532     template <> inline bool MultiType::convert<orxonox::Vector2>()     { return this->setValue<orxonox::Vector2>    (this->operator orxonox::Vector2());     } ///< Converts the current value to the given type.
    533     template <> inline bool MultiType::convert<orxonox::Vector3>()     { return this->setValue<orxonox::Vector3>    (this->operator orxonox::Vector3());     } ///< Converts the current value to the given type.
    534     template <> inline bool MultiType::convert<orxonox::Vector4>()     { return this->setValue<orxonox::Vector4>    (this->operator orxonox::Vector4());     } ///< Converts the current value to the given type.
    535     template <> inline bool MultiType::convert<orxonox::ColourValue>() { return this->setValue<orxonox::ColourValue>(this->operator orxonox::ColourValue()); } ///< Converts the current value to the given type.
    536     template <> inline bool MultiType::convert<orxonox::Quaternion>()  { return this->setValue<orxonox::Quaternion> (this->operator orxonox::Quaternion());  } ///< Converts the current value to the given type.
    537     template <> inline bool MultiType::convert<orxonox::Radian>()      { return this->setValue<orxonox::Radian>     (this->operator orxonox::Radian());      } ///< Converts the current value to the given type.
    538     template <> inline bool MultiType::convert<orxonox::Degree>()      { return this->setValue<orxonox::Degree>     (this->operator orxonox::Degree());      } ///< Converts the current value to the given type.
    539 
    540     // Specialization to avoid ambiguities with the conversion operator
    541     template <> inline bool MultiType::convert<const std::string&>()          { return this->convert<std::string>();          } ///< Converts the current value to the given type.
    542     template <> inline bool MultiType::convert<const orxonox::Vector2&>()     { return this->convert<orxonox::Vector2>();     } ///< Converts the current value to the given type.
    543     template <> inline bool MultiType::convert<const orxonox::Vector3&>()     { return this->convert<orxonox::Vector3>();     } ///< Converts the current value to the given type.
    544     template <> inline bool MultiType::convert<const orxonox::Vector4&>()     { return this->convert<orxonox::Vector4>();     } ///< Converts the current value to the given type.
    545     template <> inline bool MultiType::convert<const orxonox::ColourValue&>() { return this->convert<orxonox::ColourValue>(); } ///< Converts the current value to the given type.
    546     template <> inline bool MultiType::convert<const orxonox::Quaternion&>()  { return this->convert<orxonox::Quaternion>();  } ///< Converts the current value to the given type.
    547     template <> inline bool MultiType::convert<const orxonox::Radian&>()      { return this->convert<orxonox::Radian>();      } ///< Converts the current value to the given type.
    548     template <> inline bool MultiType::convert<const orxonox::Degree&>()      { return this->convert<orxonox::Degree>();      } ///< Converts the current value to the given type.
     458    _UtilExport inline std::ostream& operator<<(std::ostream& outstream, const MultiType& mt)
     459    {
     460        if (mt.value_)
     461            mt.value_->toString(outstream);
     462        return outstream;
     463    }
     464
     465    template <> inline bool MultiType::MT_ValueBase::isType<char>()                 const { return this->type_ == Type::Char;             }
     466    template <> inline bool MultiType::MT_ValueBase::isType<unsigned char>()        const { return this->type_ == Type::UnsignedChar;     }
     467    template <> inline bool MultiType::MT_ValueBase::isType<short>()                const { return this->type_ == Type::Short;            }
     468    template <> inline bool MultiType::MT_ValueBase::isType<unsigned short>()       const { return this->type_ == Type::UnsignedShort;    }
     469    template <> inline bool MultiType::MT_ValueBase::isType<int>()                  const { return this->type_ == Type::Int;              }
     470    template <> inline bool MultiType::MT_ValueBase::isType<unsigned int>()         const { return this->type_ == Type::UnsignedInt;      }
     471    template <> inline bool MultiType::MT_ValueBase::isType<long>()                 const { return this->type_ == Type::Long;             }
     472    template <> inline bool MultiType::MT_ValueBase::isType<unsigned long>()        const { return this->type_ == Type::UnsignedLong;     }
     473    template <> inline bool MultiType::MT_ValueBase::isType<long long>()            const { return this->type_ == Type::LongLong;         }
     474    template <> inline bool MultiType::MT_ValueBase::isType<unsigned long long>()   const { return this->type_ == Type::UnsignedLongLong; }
     475    template <> inline bool MultiType::MT_ValueBase::isType<float>()                const { return this->type_ == Type::Float;            }
     476    template <> inline bool MultiType::MT_ValueBase::isType<double>()               const { return this->type_ == Type::Double;           }
     477    template <> inline bool MultiType::MT_ValueBase::isType<long double>()          const { return this->type_ == Type::LongDouble;       }
     478    template <> inline bool MultiType::MT_ValueBase::isType<bool>()                 const { return this->type_ == Type::Bool;             }
     479    template <> inline bool MultiType::MT_ValueBase::isType<void*>()                const { return this->type_ == Type::VoidPointer;      }
     480    template <> inline bool MultiType::MT_ValueBase::isType<std::string>()          const { return this->type_ == Type::String;           }
     481    template <> inline bool MultiType::MT_ValueBase::isType<orxonox::Vector2>()     const { return this->type_ == Type::Vector2;          }
     482    template <> inline bool MultiType::MT_ValueBase::isType<orxonox::Vector3>()     const { return this->type_ == Type::Vector3;          }
     483    template <> inline bool MultiType::MT_ValueBase::isType<orxonox::Vector4>()     const { return this->type_ == Type::Vector4;          }
     484    template <> inline bool MultiType::MT_ValueBase::isType<orxonox::ColourValue>() const { return this->type_ == Type::ColourValue;      }
     485    template <> inline bool MultiType::MT_ValueBase::isType<orxonox::Quaternion>()  const { return this->type_ == Type::Quaternion;       }
     486    template <> inline bool MultiType::MT_ValueBase::isType<orxonox::Radian>()      const { return this->type_ == Type::Radian;           }
     487    template <> inline bool MultiType::MT_ValueBase::isType<orxonox::Degree>()      const { return this->type_ == Type::Degree;           }
     488
     489    template <> inline bool MultiType::set(const char* value)  { return this->set(std::string(value)); }
     490    template <> inline bool MultiType::set(const mbool& value) { return this->set((bool)value); }
     491
     492    // Spezializations for void
     493    template <> inline bool MultiType::isType<void>() const { return this->null(); }
     494    template <> inline bool MultiType::convert<void>() { this->reset(); return true; }
    549495
    550496    template <> _UtilExport void MultiType::createNewValueContainer(const char& value);
     
    571517    template <> _UtilExport void MultiType::createNewValueContainer(const orxonox::Radian& value);
    572518    template <> _UtilExport void MultiType::createNewValueContainer(const orxonox::Degree& value);
    573 
    574     inline bool MultiType::setValue(const char& value)                  { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
    575     inline bool MultiType::setValue(const unsigned char& value)         { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
    576     inline bool MultiType::setValue(const short& value)                 { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
    577     inline bool MultiType::setValue(const unsigned short& value)        { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
    578     inline bool MultiType::setValue(const int& value)                   { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
    579     inline bool MultiType::setValue(const unsigned int& value)          { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
    580     inline bool MultiType::setValue(const long& value)                  { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
    581     inline bool MultiType::setValue(const unsigned long& value)         { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
    582     inline bool MultiType::setValue(const long long& value)             { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
    583     inline bool MultiType::setValue(const unsigned long long& value)    { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
    584     inline bool MultiType::setValue(const float& value)                 { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
    585     inline bool MultiType::setValue(const double& value)                { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
    586     inline bool MultiType::setValue(const long double& value)           { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
    587     inline bool MultiType::setValue(const bool& value)                  { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
    588     inline bool MultiType::setValue(      void* const& value)           { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
    589     inline bool MultiType::setValue(const std::string& value)           { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
    590     inline bool MultiType::setValue(const orxonox::Vector2& value)      { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
    591     inline bool MultiType::setValue(const orxonox::Vector3& value)      { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
    592     inline bool MultiType::setValue(const orxonox::Vector4& value)      { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
    593     inline bool MultiType::setValue(const orxonox::ColourValue& value)  { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
    594     inline bool MultiType::setValue(const orxonox::Quaternion& value)   { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
    595     inline bool MultiType::setValue(const orxonox::Radian& value)       { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
    596     inline bool MultiType::setValue(const orxonox::Degree& value)       { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
    597 
    598     /// Assigns the given value and converts it to the current type.
    599     inline bool MultiType::setValue(const char* value)                  { if (this->value_) { return this->value_->setValue(std::string(value)); } else { return this->assignValue(std::string(value)); } }
    600519}
    601520
  • code/trunk/src/libraries/util/MultiTypeValue.h

    r8706 r9550  
    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(&this->value_, type), value_(value) {}
    5858
    5959        /// Creates a copy of itself.
     
    6161
    6262        /// Resets the current value to the default.
    63         inline void reset() { this->value_ = zeroise<T>(); bHasDefaultValue_ = true; }
    64 
    65         /**
    66             @brief Assigns the value of the other MultiType, converted to T.
    67             @param other The other MultiType
    68         */
    69         inline bool assimilate(const MultiType& other)
    70         {
    71             if (other.value_)
    72             {
    73                 return !(bHasDefaultValue_ = !other.value_->getValue(&value_));
    74             }
    75             else
    76             {
    77                 this->value_ = zeroise<T>();
    78                 return !(bHasDefaultValue_ = true);
    79             }
    80         }
     63        inline void reset() { this->value_ = zeroise<T>(); bLastConversionSuccessful = true; }
    8164
    8265        inline bool getValue(char*                 value) const { return convertValue<T, char                >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     
    9578        inline bool getValue(bool*                 value) const { return convertValue<T, bool                >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    9679        inline bool getValue(void**                value) const { return convertValue<T, void*               >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    97         inline bool getValue(std::string*          value) const { return convertValue<T, std::string         >(value, value_, zeroise<std::string>         ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    98         inline bool getValue(orxonox::Vector2*     value) const { return convertValue<T, orxonox::Vector2    >(value, value_, zeroise<orxonox::Vector2>    ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    99         inline bool getValue(orxonox::Vector3*     value) const { return convertValue<T, orxonox::Vector3    >(value, value_, zeroise<orxonox::Vector3>    ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    100         inline bool getValue(orxonox::Vector4*     value) const { return convertValue<T, orxonox::Vector4    >(value, value_, zeroise<orxonox::Vector4>    ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    101         inline bool getValue(orxonox::ColourValue* value) const { return convertValue<T, orxonox::ColourValue>(value, value_, zeroise<orxonox::ColourValue>()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    102         inline bool getValue(orxonox::Quaternion*  value) const { return convertValue<T, orxonox::Quaternion >(value, value_, zeroise<orxonox::Quaternion> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    103         inline bool getValue(orxonox::Radian*      value) const { return convertValue<T, orxonox::Radian     >(value, value_, zeroise<orxonox::Radian>     ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    104         inline bool getValue(orxonox::Degree*      value) const { return convertValue<T, orxonox::Degree     >(value, value_, zeroise<orxonox::Degree>     ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
    105 
    106         inline bool setValue(const char& value)                 { return !(bHasDefaultValue_ = !convertValue<char                , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
    107         inline bool setValue(const unsigned char& value)        { return !(bHasDefaultValue_ = !convertValue<unsigned char       , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
    108         inline bool setValue(const short& value)                { return !(bHasDefaultValue_ = !convertValue<short               , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
    109         inline bool setValue(const unsigned short& value)       { return !(bHasDefaultValue_ = !convertValue<unsigned short      , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
    110         inline bool setValue(const int& value)                  { return !(bHasDefaultValue_ = !convertValue<int                 , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
    111         inline bool setValue(const unsigned int& value)         { return !(bHasDefaultValue_ = !convertValue<unsigned int        , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
    112         inline bool setValue(const long& value)                 { return !(bHasDefaultValue_ = !convertValue<long                , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
    113         inline bool setValue(const unsigned long& value)        { return !(bHasDefaultValue_ = !convertValue<unsigned long       , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
    114         inline bool setValue(const long long& value)            { return !(bHasDefaultValue_ = !convertValue<long long           , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
    115         inline bool setValue(const unsigned long long& value)   { return !(bHasDefaultValue_ = !convertValue<unsigned long long  , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
    116         inline bool setValue(const float& value)                { return !(bHasDefaultValue_ = !convertValue<float               , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
    117         inline bool setValue(const double& value)               { return !(bHasDefaultValue_ = !convertValue<double              , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
    118         inline bool setValue(const long double& value)          { return !(bHasDefaultValue_ = !convertValue<long double         , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
    119         inline bool setValue(const bool& value)                 { return !(bHasDefaultValue_ = !convertValue<bool                , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
    120         inline bool setValue(      void* const& value)          { return !(bHasDefaultValue_ = !convertValue<void*               , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
    121         inline bool setValue(const std::string& value)          { return !(bHasDefaultValue_ = !convertValue<std::string         , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
    122         inline bool setValue(const orxonox::Vector2& value)     { return !(bHasDefaultValue_ = !convertValue<orxonox::Vector2    , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
    123         inline bool setValue(const orxonox::Vector3& value)     { return !(bHasDefaultValue_ = !convertValue<orxonox::Vector3    , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
    124         inline bool setValue(const orxonox::Vector4& value)     { return !(bHasDefaultValue_ = !convertValue<orxonox::Vector4    , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
    125         inline bool setValue(const orxonox::ColourValue& value) { return !(bHasDefaultValue_ = !convertValue<orxonox::ColourValue, T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
    126         inline bool setValue(const orxonox::Quaternion& value)  { return !(bHasDefaultValue_ = !convertValue<orxonox::Quaternion , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
    127         inline bool setValue(const orxonox::Radian& value)      { return !(bHasDefaultValue_ = !convertValue<orxonox::Radian     , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
    128         inline bool setValue(const orxonox::Degree& value)      { return !(bHasDefaultValue_ = !convertValue<orxonox::Degree     , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
    129 
    130         inline operator char()                 const { return getConvertedValue<T, char>                (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
    131         inline operator unsigned char()        const { return getConvertedValue<T, unsigned char>       (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
    132         inline operator short()                const { return getConvertedValue<T, short>               (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
    133         inline operator unsigned short()       const { return getConvertedValue<T, unsigned short>      (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
    134         inline operator int()                  const { return getConvertedValue<T, int>                 (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
    135         inline operator unsigned int()         const { return getConvertedValue<T, unsigned int>        (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
    136         inline operator long()                 const { return getConvertedValue<T, long>                (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
    137         inline operator unsigned long()        const { return getConvertedValue<T, unsigned long>       (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
    138         inline operator long long()            const { return getConvertedValue<T, long long>           (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
    139         inline operator unsigned long long()   const { return getConvertedValue<T, unsigned long long>  (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
    140         inline operator float()                const { return getConvertedValue<T, float>               (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
    141         inline operator double()               const { return getConvertedValue<T, double>              (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
    142         inline operator long double()          const { return getConvertedValue<T, long double>         (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
    143         inline operator bool()                 const { return getConvertedValue<T, bool>                (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
    144         inline operator void*()                const { return getConvertedValue<T, void*>               (this->value_, 0); }     ///< Returns the current value, converted to the requested type.
    145         inline operator std::string()          const { return getConvertedValue<T, std::string>         (this->value_, NilValue<std::string         >()); } ///< Returns the current value, converted to the requested type.
    146         inline operator orxonox::Vector2()     const { return getConvertedValue<T, orxonox::Vector2>    (this->value_, NilValue<orxonox::Vector2    >()); } ///< Returns the current value, converted to the requested type.
    147         inline operator orxonox::Vector3()     const { return getConvertedValue<T, orxonox::Vector3>    (this->value_, NilValue<orxonox::Vector3    >()); } ///< Returns the current value, converted to the requested type.
    148         inline operator orxonox::Vector4()     const { return getConvertedValue<T, orxonox::Vector4>    (this->value_, NilValue<orxonox::Vector4    >()); } ///< Returns the current value, converted to the requested type.
    149         inline operator orxonox::ColourValue() const { return getConvertedValue<T, orxonox::ColourValue>(this->value_, NilValue<orxonox::ColourValue>()); } ///< Returns the current value, converted to the requested type.
    150         inline operator orxonox::Quaternion()  const { return getConvertedValue<T, orxonox::Quaternion> (this->value_, NilValue<orxonox::Quaternion >()); } ///< Returns the current value, converted to the requested type.
    151         inline operator orxonox::Radian()      const { return getConvertedValue<T, orxonox::Radian>     (this->value_, NilValue<orxonox::Radian     >()); } ///< Returns the current value, converted to the requested type.
    152         inline operator orxonox::Degree()      const { return getConvertedValue<T, orxonox::Degree>     (this->value_, NilValue<orxonox::Degree     >()); } ///< Returns the current value, converted to the requested type.
     80        inline bool getValue(std::string*          value) const { return convertValue<T, std::string         >(value, value_, NilValue<std::string>         ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     81        inline bool getValue(orxonox::Vector2*     value) const { return convertValue<T, orxonox::Vector2    >(value, value_, NilValue<orxonox::Vector2>    ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     82        inline bool getValue(orxonox::Vector3*     value) const { return convertValue<T, orxonox::Vector3    >(value, value_, NilValue<orxonox::Vector3>    ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     83        inline bool getValue(orxonox::Vector4*     value) const { return convertValue<T, orxonox::Vector4    >(value, value_, NilValue<orxonox::Vector4>    ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     84        inline bool getValue(orxonox::ColourValue* value) const { return convertValue<T, orxonox::ColourValue>(value, value_, NilValue<orxonox::ColourValue>()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     85        inline bool getValue(orxonox::Quaternion*  value) const { return convertValue<T, orxonox::Quaternion >(value, value_, NilValue<orxonox::Quaternion> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     86        inline bool getValue(orxonox::Radian*      value) const { return convertValue<T, orxonox::Radian     >(value, value_, NilValue<orxonox::Radian>     ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     87        inline bool getValue(orxonox::Degree*      value) const { return convertValue<T, orxonox::Degree     >(value, value_, NilValue<orxonox::Degree>     ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
     88
     89        /**
     90            @brief Assigns the value of the other MultiType, converted to T.
     91            @param other The other MultiType
     92        */
     93        inline bool setValue(const MultiType& other)
     94        {
     95            if (other.value_)
     96            {
     97                return (this->bLastConversionSuccessful = other.value_->getValue(&value_));
     98            }
     99            else
     100            {
     101                this->value_ = zeroise<T>();
     102                return (bLastConversionSuccessful = false);
     103            }
     104        }
     105
     106        inline bool setValue(const char& value)                 { return (bLastConversionSuccessful = convertValue<char                , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
     107        inline bool setValue(const unsigned char& value)        { return (bLastConversionSuccessful = convertValue<unsigned char       , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
     108        inline bool setValue(const short& value)                { return (bLastConversionSuccessful = convertValue<short               , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
     109        inline bool setValue(const unsigned short& value)       { return (bLastConversionSuccessful = convertValue<unsigned short      , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
     110        inline bool setValue(const int& value)                  { return (bLastConversionSuccessful = convertValue<int                 , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
     111        inline bool setValue(const unsigned int& value)         { return (bLastConversionSuccessful = convertValue<unsigned int        , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
     112        inline bool setValue(const long& value)                 { return (bLastConversionSuccessful = convertValue<long                , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
     113        inline bool setValue(const unsigned long& value)        { return (bLastConversionSuccessful = convertValue<unsigned long       , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
     114        inline bool setValue(const long long& value)            { return (bLastConversionSuccessful = convertValue<long long           , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
     115        inline bool setValue(const unsigned long long& value)   { return (bLastConversionSuccessful = convertValue<unsigned long long  , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
     116        inline bool setValue(const float& value)                { return (bLastConversionSuccessful = convertValue<float               , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
     117        inline bool setValue(const double& value)               { return (bLastConversionSuccessful = convertValue<double              , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
     118        inline bool setValue(const long double& value)          { return (bLastConversionSuccessful = convertValue<long double         , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
     119        inline bool setValue(const bool& value)                 { return (bLastConversionSuccessful = convertValue<bool                , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
     120        inline bool setValue(      void* const& value)          { return (bLastConversionSuccessful = convertValue<void*               , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
     121        inline bool setValue(const std::string& value)          { return (bLastConversionSuccessful = convertValue<std::string         , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
     122        inline bool setValue(const orxonox::Vector2& value)     { return (bLastConversionSuccessful = convertValue<orxonox::Vector2    , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
     123        inline bool setValue(const orxonox::Vector3& value)     { return (bLastConversionSuccessful = convertValue<orxonox::Vector3    , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
     124        inline bool setValue(const orxonox::Vector4& value)     { return (bLastConversionSuccessful = convertValue<orxonox::Vector4    , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
     125        inline bool setValue(const orxonox::ColourValue& value) { return (bLastConversionSuccessful = convertValue<orxonox::ColourValue, T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
     126        inline bool setValue(const orxonox::Quaternion& value)  { return (bLastConversionSuccessful = convertValue<orxonox::Quaternion , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
     127        inline bool setValue(const orxonox::Radian& value)      { return (bLastConversionSuccessful = convertValue<orxonox::Radian     , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
     128        inline bool setValue(const orxonox::Degree& value)      { return (bLastConversionSuccessful = convertValue<orxonox::Degree     , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
    153129
    154130        /// Puts the current value on the stream
  • code/trunk/src/libraries/util/SignalHandler.cc

    r9016 r9550  
    2121 *
    2222 *   Author:
    23  *      Christoph Renner
     23 *      Christoph Renner (Linux implementation)
     24 *      Fabian 'x3n' Landau (Windows implementation)
    2425 *   Co-authors:
    2526 *      ...
     
    139140      orxout(user_error) << "Received signal " << sigName.c_str() << endl << "Try to write backtrace to file orxonox_crash.log" << endl;
    140141
    141      
     142
    142143      // First start GDB which will be attached to this process later on
    143      
     144
    144145      int gdbIn[2];
    145146      int gdbOut[2];
    146147      int gdbErr[2];
    147      
     148
    148149      if ( pipe(gdbIn) == -1 || pipe(gdbOut) == -1 || pipe(gdbErr) == -1 )
    149150      {
     
    151152        exit(EXIT_FAILURE);
    152153      }
    153      
     154
    154155      int gdbPid = fork();
    155156      // this process will run gdb
    156      
     157
    157158      if ( gdbPid == -1 )
    158159      {
     
    160161        exit(EXIT_FAILURE);
    161162      }
    162      
     163
    163164      if ( gdbPid == 0 )
    164165      {
    165166        // start gdb
    166        
     167
    167168        close(gdbIn[1]);
    168169        close(gdbOut[0]);
    169170        close(gdbErr[0]);
    170        
     171
    171172        dup2( gdbIn[0], STDIN_FILENO );
    172173        dup2( gdbOut[1], STDOUT_FILENO );
    173174        dup2( gdbErr[1], STDERR_FILENO );
    174        
     175
    175176        execlp( "sh", "sh", "-c", "gdb", static_cast<void*>(NULL));
    176177      }
    177      
    178      
     178
     179
    179180      // Now start a fork of this process on which GDB will be attached on
    180      
     181
    181182      int sigPipe[2];
    182183      if ( pipe(sigPipe) == -1 )
     
    202203      {
    203204        getInstance().dontCatch();
    204        
     205
    205206        // make sure gdb is allowed to attach to our PID even if there are some system restrictions
    206207#ifdef PR_SET_PTRACER
     
    208209          orxout(user_error) << "could not set proper permissions for GDB to attach to process..." << endl;
    209210#endif
    210        
     211
    211212        // wait for message from parent when it has attached gdb
    212213        int someData;
  • code/trunk/src/libraries/util/SignalHandler.h

    r8351 r9550  
    2121 *
    2222 *   Author:
    23  *      Christoph Renner
     23 *      Christoph Renner (Linux implementation)
     24 *      Fabian 'x3n' Landau (Windows implementation)
    2425 *   Co-authors:
    2526 *      ...
  • code/trunk/src/libraries/util/StringUtils.cc

    r8858 r9550  
    8181    }
    8282
    83     /// Splits a given string by a delimiter and stores it in an output vector
     83    /// Splits a given string by a delimiter and stores it in an output vector. See @ref SubString for a more sophisticated implementation.
    8484    void vectorize(const std::string& str, char delimiter, std::vector<std::string>* output)
    8585    {
     86        output->clear();
    8687        for (size_t start = 0, end = 0; end != std::string::npos; start = end + 1)
    8788        {
     
    9293
    9394    /**
    94         @brief Returns the position of the next quotation mark in the string, starting with start.
     95        @brief Returns the position of the next quotation mark in the string, starting with start. Escaped quotation marks (with \ in front) are not considered.
    9596        @param str The string
    9697        @param start The first position to look at
     
    130131        size_t quote = static_cast<size_t>(-1);
    131132        while ((quote = getNextQuote(str, quote + 1)) < pos)
    132         {
    133             if (quote == pos)
    134                 return false;
    135133            quotecount++;
    136         }
    137 
     134
     135        if (quote == pos)
     136            return false;
    138137        if (quote == std::string::npos)
    139138            return false;
     
    156155        size_t pos2 = getNextQuote(str, pos1 + 1);
    157156        if (pos1 != std::string::npos && pos2 != std::string::npos)
    158             return str.substr(pos1, pos2 - pos1 + 1);
     157            return str.substr(pos1 + 1, pos2 - pos1 - 1);
    159158        else
    160159            return "";
     
    247246    {
    248247        return getStripped(str).empty();
    249     }
    250 
    251     /// Determines if a string contains only numbers and maximal one '.'.
    252     bool isNumeric(const std::string& str)
    253     {
    254         bool foundPoint = false;
    255 
    256         for (std::string::const_iterator it = str.begin(); it != str.end(); ++it)
    257         {
    258             if (((*it) < '0' || (*it) > '9'))
    259             {
    260                 if ((*it) != '.' && !foundPoint)
    261                     foundPoint = true;
    262                 else
    263                     return false;
    264             }
    265         }
    266 
    267         return true;
    268248    }
    269249
     
    444424    bool hasComment(const std::string& str)
    445425    {
    446         return (getCommentPosition(str) != std::string::npos);
    447     }
    448 
    449     /// If the string contains a comment, the comment gets returned (including the comment symbol), an empty string otherwise.
     426        return (getNextCommentPosition(str) != std::string::npos);
     427    }
     428
     429    /// If the string contains a comment, the comment gets returned (including the comment symbol and white spaces in front of it), an empty string otherwise.
    450430    std::string getComment(const std::string& str)
    451431    {
    452         return str.substr(getCommentPosition(str));
    453     }
    454 
    455     /// If the string contains a comment, the position of the comment-symbol gets returned, @c std::string::npos otherwise.
    456     size_t getCommentPosition(const std::string& str)
    457     {
    458         return getNextCommentPosition(str, 0);
    459     }
    460 
    461     /**
    462         @brief Returns the position of the next comment-symbol, starting with @a start.
     432        size_t pos = getNextCommentPosition(str);
     433        if (pos == std::string::npos)
     434            return "";
     435        else
     436            return str.substr(pos);
     437    }
     438
     439    /**
     440        @brief Returns the beginning of the next comment including whitespaces in front of the comment symbol.
    463441        @param str The string
    464442        @param start The first position to look at
  • code/trunk/src/libraries/util/StringUtils.h

    r8858 r9550  
    5858    _UtilExport void         vectorize(const std::string& str, char delimiter, std::vector<std::string>* output);
    5959
    60     _UtilExport size_t       getNextQuote(const std::string& str, size_t start);
     60    _UtilExport size_t       getNextQuote(const std::string& str, size_t start = 0);
    6161    _UtilExport bool         isBetweenQuotes(const std::string& str, size_t pos);
    6262
     
    6969    _UtilExport bool         isEmpty(const std::string& str);
    7070    _UtilExport bool         isComment(const std::string& str);
    71     _UtilExport bool         isNumeric(const std::string& str);
    7271
    7372    _UtilExport std::string  addSlashes(const std::string& str);
     
    8584    _UtilExport bool         hasComment(const std::string& str);
    8685    _UtilExport std::string  getComment(const std::string& str);
    87     _UtilExport size_t       getCommentPosition(const std::string& str);
    8886    _UtilExport size_t       getNextCommentPosition(const std::string& str, size_t start = 0);
    8987
  • code/trunk/src/libraries/util/SubString.cc

    r8858 r9550  
    8787        @param other The other SubString
    8888        @param begin The beginning of the subset
    89 
    90         The subset ranges from the token with index @a begin to the end of the tokens.
    91         If @a begin is greater than the greatest index, the new SubString will be empty.
    92     */
    93     SubString::SubString(const SubString& other, unsigned int begin)
    94     {
    95         for (unsigned int i = begin; i < other.size(); ++i)
    96         {
    97             this->tokens_.push_back(other[i]);
    98             this->bTokenInSafemode_.push_back(other.isInSafemode(i));
    99         }
    100     }
    101 
    102     /**
    103         @brief creates a new SubString based on a subset of an other SubString.
    104         @param other The other SubString
    105         @param begin The beginning of the subset
    106         @param end The end of the subset
    107 
    108         The subset ranges from the token with index @a begin until (but not including) the token with index @a end.
    109         If @a begin or @a end are beyond the allowed index, the resulting SubString will be empty.
    110     */
    111     SubString::SubString(const SubString& other, unsigned int begin, unsigned int end)
    112     {
    113         for (unsigned int i = begin; i < std::min(other.size(), end); ++i)
    114         {
    115             this->tokens_.push_back(other[i]);
    116             this->bTokenInSafemode_.push_back(other.isInSafemode(i));
     89        @param length The length of the subset
     90
     91        The subset ranges from the token with index @a begin and contains @a length elements.
     92    */
     93    SubString::SubString(const SubString& other, size_t begin, size_t length)
     94    {
     95        for (size_t i = 0; i < length; ++i)
     96        {
     97            if (begin + i >= other.size())
     98                break;
     99
     100            this->tokens_.push_back(other[begin + i]);
     101            this->bTokenInSafemode_.push_back(other.isInSafemode(begin + i));
    117102        }
    118103    }
     
    123108        @param argv An array of pointers to the arguments
    124109    */
    125     SubString::SubString(unsigned int argc, const char** argv)
    126     {
    127         for(unsigned int i = 0; i < argc; ++i)
     110    SubString::SubString(size_t argc, const char** argv)
     111    {
     112        for (size_t i = 0; i < argc; ++i)
    128113        {
    129114            this->tokens_.push_back(std::string(argv[i]));
     
    158143
    159144    /**
    160         @copydoc operator==
    161     */
    162     bool SubString::compare(const SubString& other) const
    163     {
    164         return (*this == other);
    165     }
    166 
    167     /**
    168145        @brief Compares this SubString to another SubString and returns true if the first @a length values match.
    169146        @param other The other SubString
    170147        @param length How many tokens to compare
    171148    */
    172     bool SubString::compare(const SubString& other, unsigned int length) const
    173     {
    174         if (length > this->size() || length > other.size())
     149    bool SubString::compare(const SubString& other, size_t length) const
     150    {
     151        if (std::min(length, this->size()) != std::min(length, other.size()))
    175152            return false;
    176153
    177         for (unsigned int i = 0; i < length; ++i)
     154        for (size_t i = 0; i < std::min(length, this->size()); ++i)
    178155            if ((this->tokens_[i] != other.tokens_[i]) || (this->bTokenInSafemode_[i] != other.bTokenInSafemode_[i]))
    179156                return false;
     157
    180158        return true;
    181159    }
     
    196174    SubString& SubString::operator+=(const SubString& other)
    197175    {
    198         for (unsigned int i = 0; i < other.size(); ++i)
     176        for (size_t i = 0; i < other.size(); ++i)
    199177        {
    200178            this->tokens_.push_back(other[i]);
     
    207185        @copydoc SubString(const std::string&,const std::string&,const std::string&,bool,char,bool,char,bool,char,char,bool,char)
    208186    */
    209     unsigned int SubString::split(const std::string& line,
    210                                   const std::string& delimiters, const std::string& delimiterNeighbours, bool bAllowEmptyEntries,
    211                                   char escapeChar, bool bRemoveEscapeChar, char safemodeChar, bool bRemoveSafemodeChar,
    212                                   char openparenthesisChar, char closeparenthesisChar, bool bRemoveParenthesisChars, char commentChar)
     187    size_t SubString::split(const std::string& line,
     188                            const std::string& delimiters, const std::string& delimiterNeighbours, bool bAllowEmptyEntries,
     189                            char escapeChar, bool bRemoveEscapeChar, char safemodeChar, bool bRemoveSafemodeChar,
     190                            char openparenthesisChar, char closeparenthesisChar, bool bRemoveParenthesisChars, char commentChar)
    213191    {
    214192        this->tokens_.clear();
     
    228206        {
    229207            std::string retVal = this->tokens_[0];
    230             for (unsigned int i = 1; i < this->tokens_.size(); ++i)
     208            for (size_t i = 1; i < this->tokens_.size(); ++i)
    231209                retVal += delimiter + this->tokens_[i];
    232210            return retVal;
     
    239217        @brief Creates a subset of this SubString.
    240218        @param begin The beginning of the subset
     219        @param length The length of the subset
    241220        @return A new SubString containing the defined subset.
    242221
    243         The subset ranges from the token with index @a begin to the end of the tokens.
    244         If @a begin is greater than the greatest index, the new SubString will be empty.
     222        The subset ranges from the token with index @a begin and contains @a length elements.
    245223
    246224        This function is added for your convenience, and does the same as
    247         SubString::SubString(const SubString& other, unsigned int begin)
    248     */
    249     SubString SubString::subSet(unsigned int begin) const
    250     {
    251         return SubString(*this, begin);
    252     }
    253 
    254     /**
    255         @brief Creates a subset of this SubString.
    256         @param begin The beginning of the subset
    257         @param end The ending of the subset
    258         @return A new SubString containing the defined subset.
    259 
    260         The subset ranges from the token with index @a begin until (but not including) the token with index @a end.
    261         If @a begin or @a end are beyond the allowed index, the resulting SubString will be empty.
    262 
    263         This function is added for your convenience, and does the same as
    264         SubString::SubString(const SubString& other, unsigned int begin, unsigned int end)
    265     */
    266     SubString SubString::subSet(unsigned int begin, unsigned int end) const
    267     {
    268         return SubString(*this, begin, end);
     225        SubString::SubString(const SubString& other, size_t begin, size_t length)
     226    */
     227    SubString SubString::subSet(size_t begin, size_t length) const
     228    {
     229        return SubString(*this, begin, length);
    269230    }
    270231
     
    298259    {
    299260        SPLIT_LINE_STATE state = start_state;
    300         unsigned int i = 0;
    301         unsigned int fallBackNeighbours = 0;
     261        size_t i = 0;
     262        size_t fallBackNeighbours = 0;
    302263
    303264        std::string token;
     
    514475    {
    515476        orxout(debug_output) << "Substring-information::count=" << this->tokens_.size() << " ::";
    516         for (unsigned int i = 0; i < this->tokens_.size(); ++i)
     477        for (size_t i = 0; i < this->tokens_.size(); ++i)
    517478            orxout(debug_output) << "s" << i << "='" << this->tokens_[i].c_str() << "'::";
    518479        orxout(debug_output) << endl;
  • code/trunk/src/libraries/util/SubString.h

    r8858 r9550  
    5858    SubString tokens(text, SubString::WhiteSpaces, "", false, '\\', true, '"', true, '{', '}', true, '\0');
    5959
    60     for (unsigned int i = 0; i < tokens.size(); ++i)
     60    for (size_t i = 0; i < tokens.size(); ++i)
    6161        orxout() << i << ": " << tokens[i] << endl;
    6262    @endcode
     
    127127                  bool bRemoveParenthesisChars = true,
    128128                  char commentChar = '\0');
    129         SubString(unsigned int argc, const char** argv);
    130         SubString(const SubString& other, unsigned int begin);
    131         SubString(const SubString& other, unsigned int begin, unsigned int end);
     129        SubString(size_t argc, const char** argv);
     130        SubString(const SubString& other, size_t begin, size_t length = std::string::npos);
    132131        ~SubString();
    133132
     
    135134        SubString& operator=(const SubString& other);
    136135        bool operator==(const SubString& other) const;
    137         bool compare(const SubString& other) const;
    138         bool compare(const SubString& other, unsigned int length) const;
     136        bool compare(const SubString& other, size_t length = std::string::npos) const;
    139137        SubString operator+(const SubString& other) const;
    140138        SubString& operator+=(const SubString& other);
     
    144142        /////////////////////////////////////////
    145143        // Split and Join the any String. ///////
    146         unsigned int split(const std::string& line,
    147                            const std::string& delimiters = SubString::WhiteSpaces,
    148                            const std::string& delimiterNeighbours = "",
    149                            bool bAllowEmptyEntries = false,
    150                            char escapeChar ='\\',
    151                            bool bRemoveEscapeChar = true,
    152                            char safemodeChar = '"',
    153                            bool bRemoveSafemodeChar = true,
    154                            char openparenthesisChar = '{',
    155                            char closeparenthesisChar = '}',
    156                            bool bRemoveParenthesisChars = true,
    157                            char commentChar = '\0');
     144        size_t split(const std::string& line,
     145                     const std::string& delimiters = SubString::WhiteSpaces,
     146                     const std::string& delimiterNeighbours = "",
     147                     bool bAllowEmptyEntries = false,
     148                     char escapeChar ='\\',
     149                     bool bRemoveEscapeChar = true,
     150                     char safemodeChar = '"',
     151                     bool bRemoveSafemodeChar = true,
     152                     char openparenthesisChar = '{',
     153                     char closeparenthesisChar = '}',
     154                     bool bRemoveParenthesisChars = true,
     155                     char commentChar = '\0');
    158156
    159157        std::string join(const std::string& delimiter = " ") const;
     
    161159
    162160        // retrieve a SubSet from the String
    163         SubString subSet(unsigned int begin) const;
    164         SubString subSet(unsigned int begin, unsigned int end) const;
     161        SubString subSet(size_t begin, size_t length = std::string::npos) const;
    165162
    166163        // retrieve Information from within
     
    168165        inline bool empty() const { return this->tokens_.empty(); }
    169166        /// Returns the number of tokens stored in this SubString
    170         inline unsigned int size() const { return this->tokens_.size(); }
     167        inline size_t size() const { return this->tokens_.size(); }
    171168        /// Returns the i'th token from the subset of strings @param index The index of the requested token
    172         inline const std::string& operator[](unsigned int index) const { return this->tokens_[index]; }
     169        inline const std::string& operator[](size_t index) const { return this->tokens_[index]; }
    173170        /// Returns the i'th token from the subset of strings @param index The index of the requested token
    174         inline const std::string& getString(unsigned int index) const { return (*this)[index]; }
     171        inline const std::string& getString(size_t index) const { return (*this)[index]; }
    175172        /// Returns all tokens as std::vector
    176173        inline const std::vector<std::string>& getAllStrings() const { return this->tokens_; }
    177174        /// Returns true if the token is in safemode. @param index The index of the token
    178         inline bool isInSafemode(unsigned int index) const { return this->bTokenInSafemode_[index]; }
     175        inline bool isInSafemode(size_t index) const { return this->bTokenInSafemode_[index]; }
    179176        /// Returns the front of the list of tokens.
    180177        inline const std::string& front() const { return this->tokens_.front(); }
  • code/trunk/src/libraries/util/UtilPrereqs.h

    r8858 r9550  
    8484namespace orxonox
    8585{
     86    class AdditionalContextListener;
     87    class BaseWriter;
    8688    class Clock;
     89    class ConsoleWriter;
    8790    class Exception;
    8891    class ExprParser;
     92    class LogWriter;
     93    class MemoryWriter;
    8994    class MultiType;
    9095    class OutputListener;
     
    96101    class ScopedSingleton;
    97102    class ScopeListener;
     103    template <class T>
     104    class SharedPtr;
    98105    class SignalHandler;
    99106    template <class T>
    100107    class Singleton;
     108    class SubcontextOutputListener;
    101109    class SubString;
    102110}
  • code/trunk/src/libraries/util/VA_NARGS.h

    r7401 r9550  
    3636    type aware, but for different numbers of arguments is still very powerful).
    3737
     38    Important: The macro can not be overloaded for 0 arguments: ORXONOX_VA_NARGS() returns 1!
     39
    3840    Example: A macro to call functions
    3941    @code
     
    6466*/
    6567
     68#include <boost/preprocessor/cat.hpp>
    6669#include <boost/preprocessor/facilities/expand.hpp>
    6770
  • code/trunk/src/libraries/util/output/ConsoleWriter.cc

    r9348 r9550  
    3434#include "ConsoleWriter.h"
    3535
    36 #include <iostream>
    3736
    3837#include "OutputManager.h"
     
    4847        After creation, the instance is enabled.
    4948    */
    50     ConsoleWriter::ConsoleWriter() : BaseWriter("Console")
     49    ConsoleWriter::ConsoleWriter(std::ostream& outputStream) : BaseWriter("Console"), outputStream_(outputStream)
    5150    {
    5251#ifdef ORXONOX_RELEASE
     
    6665
    6766    /**
    68         @brief Returns the only existing instance of this class.
    69     */
    70     /*static*/ ConsoleWriter& ConsoleWriter::getInstance()
    71     {
    72         static ConsoleWriter instance;
    73         return instance;
    74     }
    75 
    76     /**
    7767        @brief Inherited function from BaseWriter, writes output to the console using std::cout.
    7868    */
    7969    void ConsoleWriter::printLine(const std::string& line, OutputLevel)
    8070    {
    81         std::cout << line << std::endl;
     71        this->outputStream_ << line << std::endl;
    8272    }
    8373
  • code/trunk/src/libraries/util/output/ConsoleWriter.h

    r8858 r9550  
    3737
    3838#include "util/UtilPrereqs.h"
     39
     40#include <ostream>
     41
    3942#include "BaseWriter.h"
    4043
     
    4447        @brief ConsoleWriter inherits from BaseWriter and writes output to the console.
    4548
    46         This class can be seen as an equivalent to std::cout within the output
    47         system. It is implemented as a singleton for static acces.
     49        This class can be seen as an equivalent to std::cout within the output system.
    4850    */
    4951    class _UtilExport ConsoleWriter : public BaseWriter
    5052    {
    5153        public:
    52             static ConsoleWriter& getInstance();
     54            ConsoleWriter(std::ostream& outputStream);
     55            ConsoleWriter(const ConsoleWriter&);
     56            virtual ~ConsoleWriter();
    5357
    5458            void enable();
    5559            void disable();
     60
     61            inline const std::ostream& getOutputStream() const
     62                { return this->outputStream_; }
    5663
    5764        protected:
     
    5966
    6067        private:
    61             ConsoleWriter();
    62             ConsoleWriter(const ConsoleWriter&);
    63             virtual ~ConsoleWriter();
    64 
    65             bool bEnabled_; ///< If false, the instance will not write output to the console.
     68            std::ostream& outputStream_; ///< The ostream to which the console writer writes its output
     69            bool bEnabled_;              ///< If false, the instance will not write output to the console.
    6670    };
    6771}
  • code/trunk/src/libraries/util/output/LogWriter.cc

    r8858 r9550  
    3939#include "OutputManager.h"
    4040#include "MemoryWriter.h"
     41#include "util/Convert.h"
    4142
    4243namespace orxonox
    4344{
     45    static const int MAX_ARCHIVED_FILES = 9;
     46
    4447    /**
    4548        @brief Constructor, initializes the desired output levels and the name and path of the log-file, and opens the log-file.
     
    5861        // get the path for a temporary file, depending on the system
    5962#ifdef ORXONOX_PLATFORM_WINDOWS
    60         this->path_ = getenv("TEMP");
     63        this->directory_ = getenv("TEMP");
    6164#else
    62         this->path_ = "/tmp";
     65        this->directory_ = "/tmp";
    6366#endif
    64         this->bDefaultPath_ = true;
     67
     68        // send a message to the user so that he can find the file in the case of a crash.
     69        OutputManager::getInstance().pushMessage(level::user_info, context::undefined(), "Opening log file " + this->getPath());
    6570
    6671        this->openFile();
     
    7681
    7782    /**
    78         @brief Returns the only existing instance of this class.
    79     */
    80     /*static*/ LogWriter& LogWriter::getInstance()
    81     {
    82         static LogWriter instance;
    83         return instance;
    84     }
    85 
    86     /**
    8783        @brief Opens the log-file in order to write output to it.
    8884    */
    8985    void LogWriter::openFile()
    9086    {
    91         // get the full file-name
    92         std::string name = this->path_ + '/' + this->filename_;
    93 
    94         // if we open the log file in the default directory, send a message to the user so that he can find the file in the case of a crash.
    95         if (this->bDefaultPath_)
    96             OutputManager::getInstance().pushMessage(level::user_info, context::undefined(), "Opening log file " + name);
     87        // archive the old log file
     88        this->archive();
    9789
    9890        // open the file
    99         this->file_.open(name.c_str(), std::fstream::out);
     91        this->file_.open(this->getPath().c_str(), std::fstream::out);
    10092
    10193        // check if it worked and print some output
     
    119111
    120112    /**
     113     * @brief Archives old copies of the log file by adding increasing numbers to the filename.
     114     */
     115    void LogWriter::archive(int index)
     116    {
     117        std::string oldPath = this->getArchivedPath(index);
     118
     119        // see if the file already exists, otherwise return
     120        std::ifstream stream(oldPath.c_str());
     121        bool exists = stream.is_open();
     122        stream.close();
     123
     124        if (!exists)
     125            return;
     126
     127        if (index < MAX_ARCHIVED_FILES)
     128        {
     129            // increment the index and archive the file with the next higher index
     130            this->archive(++index);
     131
     132            // create the new path based on the incremented index
     133            std::string newPath = this->getArchivedPath(index);
     134
     135            // move the file
     136            std::rename(oldPath.c_str(), newPath.c_str());
     137        }
     138        else
     139        {
     140            // delete the file
     141            std::remove(oldPath.c_str());
     142        }
     143    }
     144   
     145    /**
     146     * @brief Returns the path for archived copies of the logfile (based on the archive index)
     147     */
     148    std::string LogWriter::getArchivedPath(int index) const
     149    {
     150        std::string path = this->getPath();
     151        if (index > 0)
     152            path += '.' + multi_cast<std::string>(index);
     153        return path;
     154    }
     155
     156    /**
    121157        @brief Changes the path of the log-file. Re-writes the log-file by using MemoryWriter.
    122158    */
    123     void LogWriter::setLogPath(const std::string& path)
     159    void LogWriter::setLogDirectory(const std::string& directory)
    124160    {
    125161        // notify about the change of the log-file (because the old file will no longer be updated)
    126         OutputManager::getInstance().pushMessage(level::internal_info, context::undefined(), "Migrating log file from " + this->path_ + "\nto " + path);
     162        OutputManager::getInstance().pushMessage(level::internal_info, context::undefined(), "Migrating log file from " + this->directory_ + "\nto " + directory);
    127163
    128164        // close the old file, update the path and open the new file
    129165        this->closeFile();
    130         this->path_ = path;
    131         this->bDefaultPath_ = false;
     166        this->directory_ = directory;
    132167        this->openFile();
    133168
    134169        // request old output from MemoryWriter
    135         MemoryWriter::getInstance().resendOutput(this);
     170        if (OutputManager::getInstance().getMemoryWriter())
     171            OutputManager::getInstance().getMemoryWriter()->resendOutput(this);
    136172    }
    137173
  • code/trunk/src/libraries/util/output/LogWriter.h

    r8858 r9550  
    4747        @brief The LogWriter class inherits from BaseWriter and writes output to a log-file.
    4848
    49         It is implemented as singleton because we (currently) use only one
    50         log-file. The path of the file can be changed, in which case the file
     49        The path of the file can be changed, in which case the file
    5150        is rewritten by using the output stored by MemoryWriter. This adds the
    5251        possibility to change the desired output levels before changing the
     
    5756    {
    5857        public:
    59             static LogWriter& getInstance();
     58            LogWriter();
     59            LogWriter(const LogWriter&);
     60            virtual ~LogWriter();
    6061
    61             void setLogPath(const std::string& path);
     62            void setLogDirectory(const std::string& directory);
     63
     64            /** @brief Returns the path to the logfile. */
     65            inline std::string getPath() const
     66                { return this->directory_ + '/' + this->filename_; }
     67            /** @brief Returns the open file stream. */
     68            inline const std::ofstream& getFile() const
     69                { return this->file_; }
    6270
    6371        protected:
     
    6573
    6674        private:
    67             LogWriter();
    68             LogWriter(const LogWriter&);
    69             virtual ~LogWriter();
    70 
    7175            void openFile();
    7276            void closeFile();
    7377
    74             std::string filename_;  ///< The name of the log-file (without directories)
    75             std::string path_;      ///< The path of the log-file (without file-name)
    76             bool bDefaultPath_;     ///< If true, the log-file resides at the default path (which is usually a temporary directory)
     78            void archive(int index = 0);
     79            std::string getArchivedPath(int index) const;
    7780
     81            std::string filename_;  ///< The name of the log-file (without directory)
     82            std::string directory_; ///< The directory where the log-file resided (without file-name)
    7883            std::ofstream file_;    ///< The output file stream.
    7984    };
  • code/trunk/src/libraries/util/output/MemoryWriter.cc

    r8858 r9550  
    5353
    5454    /**
    55         @brief Returns the only existing instance of this singleton class.
    56     */
    57     /*static*/ MemoryWriter& MemoryWriter::getInstance()
    58     {
    59         static MemoryWriter instance;
    60         return instance;
    61     }
    62 
    63     /**
    6455        @brief Implementation of the output() function inherited from OutputListener, stores the received output in memory.
    6556    */
  • code/trunk/src/libraries/util/output/MemoryWriter.h

    r8858 r9550  
    6767
    6868        public:
    69             static MemoryWriter& getInstance();
     69            MemoryWriter();
     70            MemoryWriter(const MemoryWriter&);
     71            virtual ~MemoryWriter();
    7072
    7173            void resendOutput(OutputListener* listener) const;
     
    7678
    7779        private:
    78             MemoryWriter();
    79             MemoryWriter(const MemoryWriter&);
    80             virtual ~MemoryWriter();
    81 
    8280            std::vector<Message> messages_; ///< Stores all output messages from the creation of this instance until disable() is called.
    8381    };
  • code/trunk/src/libraries/util/output/OutputDefinitions.h

    r8879 r9550  
    4747    context argument.
    4848*/
    49 #define REGISTER_OUTPUT_CONTEXT(name) \
    50     const OutputContextContainer& name() { static const OutputContextContainer& context = registerContext(#name); return context; }
     49#ifndef DISABLE_OUTPUT_CONTEXT_STATIC_CACHE
     50    #define REGISTER_OUTPUT_CONTEXT(name) \
     51        const OutputContextContainer& name() { static OutputContextContainer context = registerContext(#name); return context; }
     52#else
     53    #define REGISTER_OUTPUT_CONTEXT(name) \
     54        const OutputContextContainer& name() { return registerContext(#name); }
     55#endif
    5156
    5257/**
     
    6065    individually by derivatives of orxonox::SubcontextOutputListener.
    6166*/
    62 #define REGISTER_OUTPUT_SUBCONTEXT(name, subname) \
    63     const OutputContextContainer& subname() { static const OutputContextContainer& context = registerContext(#name, #subname); return context; }
     67#ifndef DISABLE_OUTPUT_CONTEXT_STATIC_CACHE
     68    #define REGISTER_OUTPUT_SUBCONTEXT(name, subname) \
     69        const OutputContextContainer& subname() { static const OutputContextContainer context = registerContext(#name, #subname); return context; }
     70#else
     71    #define REGISTER_OUTPUT_SUBCONTEXT(name, subname) \
     72        const OutputContextContainer& subname() { return registerContext(#name, #subname); }
     73#endif
    6474
    6575// tolua_begin
     
    105115        OutputContextSubID sub_id;  ///< The id of the sub-context (or context::no_subcontext if this container doesn't define a sub-context)
    106116        std::string name;           ///< The name of this context
     117
     118        inline bool operator==(const OutputContextContainer& other) const
     119        {
     120            return this->mask == other.mask && this->sub_id == other.sub_id && this->name == other.name;
     121        }
    107122    };
    108123
  • code/trunk/src/libraries/util/output/OutputListener.cc

    r8858 r9550  
    6262
    6363    /**
     64        @brief Adds a listener to the list.
     65    */
     66    void OutputListener::registerListener(AdditionalContextListener* listener)
     67    {
     68        this->listeners_.push_back(listener);
     69    }
     70
     71    /**
     72        @brief Removes a listener from the list.
     73    */
     74    void OutputListener::unregisterListener(AdditionalContextListener* listener)
     75    {
     76        for (std::vector<AdditionalContextListener*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
     77        {
     78            if (*it == listener)
     79            {
     80                this->listeners_.erase(it);
     81                break;
     82            }
     83        }
     84    }
     85
     86    /**
    6487        @brief Defines the level mask in a way which accepts all output up to the level \c max.
    6588    */
     
    88111        this->levelMask_ = mask;
    89112
    90         OutputManager::getInstance().updateCombinedLevelMask();
     113        for (size_t i = 0; i < this->listeners_.size(); ++i)
     114            this->listeners_[i]->updatedLevelMask(this);
    91115    }
    92116
     
    118142        this->additionalContextsLevelMask_ = mask;
    119143
    120         OutputManager::getInstance().updateCombinedAdditionalContextsLevelMask();
     144        for (size_t i = 0; i < this->listeners_.size(); ++i)
     145            this->listeners_[i]->updatedAdditionalContextsLevelMask(this);
    121146    }
    122147
     
    128153        this->additionalContextsMask_ = mask;
    129154
    130         OutputManager::getInstance().updateCombinedAdditionalContextsMask();
     155        for (size_t i = 0; i < this->listeners_.size(); ++i)
     156            this->listeners_[i]->updatedAdditionalContextsMask(this);
    131157    }
    132158
  • code/trunk/src/libraries/util/output/OutputListener.h

    r8858 r9550  
    5555            virtual ~OutputListener();
    5656
     57            void registerListener(AdditionalContextListener* listener);
     58            void unregisterListener(AdditionalContextListener* listener);
     59
    5760            void setLevelMax(OutputLevel max);
    5861            void setLevelRange(OutputLevel min, OutputLevel max);
     
    6366            void setAdditionalContextsLevelMask(OutputLevel mask);
    6467
    65             void setAdditionalContextsMask(OutputContextMask mask);
     68            virtual void setAdditionalContextsMask(OutputContextMask mask);
    6669
    6770            /// @brief Returns the level mask.
     
    7881
    7982            /// @brief Called by OutputManager for each line of output, checks if this listener actually accepts this output before it calls the output() function.
    80             inline void unfilteredOutput(OutputLevel level, const OutputContextContainer& context, const std::vector<std::string>& lines)
     83            virtual void unfilteredOutput(OutputLevel level, const OutputContextContainer& context, const std::vector<std::string>& lines)
    8184                { if (this->acceptsOutput(level, context)) this->output(level, context, lines); }
    8285
     
    8588            virtual void output(OutputLevel level, const OutputContextContainer& context, const std::vector<std::string>& lines) = 0;
    8689
     90            inline const std::vector<AdditionalContextListener*>& getListeners() const
     91                { return this->listeners_; }
     92
    8793        private:
    88             OutputLevel       levelMask_;                   ///< Mask of accepted output levels, independent of contexts
    89             OutputContextMask additionalContextsMask_;      ///< Mask of accepted additional contexts
    90             OutputLevel       additionalContextsLevelMask_; ///< Mask of accepted output levels of the additional contexts
     94            std::vector<AdditionalContextListener*> listeners_; ///< List of all registered additional context listeners
     95
     96            OutputLevel       levelMask_;                       ///< Mask of accepted output levels, independent of contexts
     97            OutputContextMask additionalContextsMask_;          ///< Mask of accepted additional contexts
     98            OutputLevel       additionalContextsLevelMask_;     ///< Mask of accepted output levels of the additional contexts
    9199    };
    92100
  • code/trunk/src/libraries/util/output/OutputManager.cc

    r8858 r9550  
    3333
    3434#include "OutputManager.h"
     35
     36#include <iostream>
    3537
    3638#include "MemoryWriter.h"
     
    3941#include "util/Output.h"
    4042#include "util/StringUtils.h"
     43#include "util/SharedPtr.h"
    4144
    4245namespace orxonox
     
    5255
    5356        this->subcontextCounter_ = 0;
     57
     58        this->isInitialized_ = false;
     59        this->memoryWriterInstance_ = 0;
     60        this->consoleWriterInstance_ = 0;
     61        this->logWriterInstance_ = 0;
     62
     63        // register 'undefined' context in order to give it always the first context-ID
     64        this->registerContext("undefined");
    5465    }
    5566
     
    5970    OutputManager::~OutputManager()
    6071    {
     72        while (!this->listeners_.empty())
     73            this->unregisterListener(this->listeners_[0]);
     74
     75        if (this->memoryWriterInstance_)
     76            delete this->memoryWriterInstance_;
     77        if (this->consoleWriterInstance_)
     78            delete this->consoleWriterInstance_;
     79        if (this->logWriterInstance_)
     80            delete this->logWriterInstance_;
     81    }
     82
     83    /*static*/ SharedPtr<OutputManager>& OutputManager::Testing::getInstancePointer()
     84    {
     85        static SharedPtr<OutputManager> instance(new OutputManager());
     86        return instance;
    6187    }
    6288
     
    6692    /*static*/ OutputManager& OutputManager::getInstance()
    6793    {
    68         static OutputManager instance;
    69         return instance;
     94        return *OutputManager::Testing::getInstancePointer();
    7095    }
    7196
     
    80105    /*static*/ OutputManager& OutputManager::getInstanceAndCreateListeners()
    81106    {
    82         static OutputManager& instance = OutputManager::getInstance();
    83 
    84         static MemoryWriter& memoryWriterInstance = MemoryWriter::getInstance(); (void)memoryWriterInstance;
    85         static ConsoleWriter& consoleWriterInstance = ConsoleWriter::getInstance(); (void)consoleWriterInstance;
    86         static LogWriter& logWriterInstance = LogWriter::getInstance(); (void)logWriterInstance;
     107        OutputManager& instance = *OutputManager::Testing::getInstancePointer();
     108
     109        if (!instance.isInitialized_) {
     110            instance.isInitialized_ = true;
     111            instance.memoryWriterInstance_ = new MemoryWriter();
     112            instance.consoleWriterInstance_ = new ConsoleWriter(std::cout);
     113            instance.logWriterInstance_ = new LogWriter();
     114        }
    87115
    88116        return instance;
     
    113141    void OutputManager::registerListener(OutputListener* listener)
    114142    {
     143        listener->registerListener(this);
    115144        this->listeners_.push_back(listener);
    116145        this->updateMasks();
     
    122151    void OutputManager::unregisterListener(OutputListener* listener)
    123152    {
     153        listener->unregisterListener(this);
    124154        for (std::vector<OutputListener*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
    125155        {
     
    267297    {
    268298        // "undefined" context is ignored because it's used implicitly if no explicit context is defined
    269         static OutputContextMask undefined_mask = context::undefined().mask;
     299        OutputContextMask undefined_mask = context::undefined().mask;
    270300
    271301        std::string prefix = this->getLevelName(level) + ": ";
  • code/trunk/src/libraries/util/output/OutputManager.h

    r8858 r9550  
    4343
    4444#include "OutputDefinitions.h"
     45#include "AdditionalContextListener.h"
    4546
    4647namespace orxonox
     
    6162        Additionally OutputManager is used to register output contexts.
    6263    */
    63     class _UtilExport OutputManager
     64    class _UtilExport OutputManager : public AdditionalContextListener
    6465    {
    6566        public:
     67            OutputManager();
     68            OutputManager(const OutputManager&);
     69            virtual ~OutputManager();
     70
    6671            static OutputManager& getInstance();
    6772            static OutputManager& getInstanceAndCreateListeners();
    6873
    69             void pushMessage(OutputLevel level, const OutputContextContainer& context, const std::string& message);
     74            inline MemoryWriter* getMemoryWriter()   { return this->memoryWriterInstance_; }
     75            inline ConsoleWriter* getConsoleWriter() { return this->consoleWriterInstance_; }
     76            inline LogWriter* getLogWriter()         { return this->logWriterInstance_; }
    7077
    71             void registerListener(OutputListener* listener);
    72             void unregisterListener(OutputListener* listener);
     78            virtual void pushMessage(OutputLevel level, const OutputContextContainer& context, const std::string& message);
    7379
    74             void updateMasks();
    75             void updateCombinedLevelMask();
    76             void updateCombinedAdditionalContextsLevelMask();
    77             void updateCombinedAdditionalContextsMask();
     80            virtual void registerListener(OutputListener* listener);
     81            virtual void unregisterListener(OutputListener* listener);
     82
     83            virtual void updatedLevelMask(const OutputListener* listener)
     84                { this->updateCombinedLevelMask(); }
     85            virtual void updatedAdditionalContextsLevelMask(const OutputListener* listener)
     86                { this->updateCombinedAdditionalContextsLevelMask(); }
     87            virtual void updatedAdditionalContextsMask(const OutputListener* listener)
     88                { this->updateCombinedAdditionalContextsMask(); }
    7889
    7990            /**
     
    95106            std::string getDefaultPrefix(OutputLevel level, const OutputContextContainer& context) const;
    96107
     108            inline const std::vector<OutputListener*>& getListeners() const
     109                { return this->listeners_; }
     110
     111            inline OutputLevel getCombinedLevelMask() const { return this->combinedLevelMask_; }
     112            inline OutputLevel getCombinedAdditionalContextsLevelMask() const { return this->combinedAdditionalContextsLevelMask_; }
     113            inline OutputContextMask getCombinedAdditionalContextsMask() const { return this->combinedAdditionalContextsMask_; }
     114
    97115        private:
    98             OutputManager();
    99             OutputManager(const OutputManager&);
    100             ~OutputManager();
     116            void updateMasks();
     117            void updateCombinedLevelMask();
     118            void updateCombinedAdditionalContextsLevelMask();
     119            void updateCombinedAdditionalContextsMask();
    101120
    102121            std::vector<OutputListener*> listeners_;                            ///< List of all registered output listeners
     
    109128            std::map<std::string, OutputContextContainer> contextContainers_;   ///< Contains all contexts including sub-contexts and their containers
    110129            OutputContextSubID subcontextCounter_;                              ///< Counts the number of sub-contexts (and generates their IDs)
     130
     131            bool isInitialized_;                                                ///< Becomes true once the following instances were created
     132            MemoryWriter*  memoryWriterInstance_;                               ///< The main instance of MemoryWriter, managed by OutputManager
     133            ConsoleWriter* consoleWriterInstance_;                              ///< The main instance of ConsoleWriter, managed by OutputManager
     134            LogWriter*     logWriterInstance_;                                  ///< The main instance of LogWriter, managed by OutputManager
     135
     136        public:
     137            struct _UtilExport Testing
     138            {
     139                static SharedPtr<OutputManager>& getInstancePointer();
     140            };
    111141    };
    112142}
  • code/trunk/src/libraries/util/output/OutputStream.h

    r8858 r9550  
    102102            }
    103103
     104            inline const OutputLevel getOutputLevel() const { return this->level_; }
     105            inline const OutputContextContainer* getOutputContext() const { return this->context_; }
     106            inline bool acceptsOutput() const { return this->bAcceptsOutput_; }
     107
    104108        private:
    105109            /// @brief Generic function to add values to the output stream, using the inherited << operator from std::ostringstream.
  • code/trunk/src/libraries/util/output/SubcontextOutputListener.h

    r8858 r9550  
    7373            virtual ~SubcontextOutputListener();
    7474
    75             void setAdditionalContextsMask(OutputContextMask mask);
     75            virtual void setAdditionalContextsMask(OutputContextMask mask);
    7676            void setAdditionalSubcontexts(const std::set<const OutputContextContainer*>& subcontexts);
    7777
    7878            virtual bool acceptsOutput(OutputLevel level, const OutputContextContainer& context) const;
     79
     80            inline const std::set<OutputContextSubID>& getSubcontexts() const
     81                { return this->subcontexts_; }
    7982
    8083        private:
Note: See TracChangeset for help on using the changeset viewer.