Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 17, 2016, 10:29:21 PM (9 years ago)
Author:
landauf
Message:

merged branch cpp11_v3 back to trunk

Location:
code/trunk
Files:
29 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/libraries/core/command/ArgumentCompletionFunctions.cc

    r10624 r11071  
    7777            bool groupIsVisible(const std::map<std::string, ConsoleCommand*>& group, bool bOnlyShowHidden)
    7878            {
    79                 for (std::map<std::string, ConsoleCommand*>::const_iterator it_command = group.begin(); it_command != group.end(); ++it_command)
    80                     if (it_command->second->isActive() && it_command->second->hasAccess() && (!it_command->second->isHidden())^bOnlyShowHidden)
     79                for (const auto& mapEntry : group)
     80                    if (mapEntry.second->isActive() && mapEntry.second->hasAccess() && (!mapEntry.second->isHidden())^bOnlyShowHidden)
    8181                        return true;
    8282
     
    9999
    100100                // get all the groups that are visible (except the shortcut group "")
    101                 const std::map<std::string, std::map<std::string, ConsoleCommand*> >& commands = ConsoleCommandManager::getInstance().getCommands();
    102                 for (std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = commands.begin(); it_group != commands.end(); ++it_group)
    103                     if (groupIsVisible(it_group->second, bOnlyShowHidden) && it_group->first != "" && (fragmentLC == "" || getLowercase(it_group->first).find(fragmentLC) == 0))
    104                         groupList.push_back(ArgumentCompletionListElement(it_group->first, getLowercase(it_group->first)));
     101                const std::map<std::string, std::map<std::string, ConsoleCommand*>>& commands = ConsoleCommandManager::getInstance().getCommands();
     102                for (const auto& mapEntry : commands)
     103                    if (groupIsVisible(mapEntry.second, bOnlyShowHidden) && mapEntry.first != "" && (fragmentLC == "" || getLowercase(mapEntry.first).find(fragmentLC) == 0))
     104                        groupList.emplace_back(mapEntry.first, getLowercase(mapEntry.first));
    105105
    106106                // now add all shortcuts (in group "")
    107                 std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = commands.find("");
     107                std::map<std::string, std::map<std::string, ConsoleCommand*>>::const_iterator it_group = commands.find("");
    108108                if (it_group != commands.end())
    109109                {
    110110                    // add a line-break if the list isn't empty
    111111                    if (!groupList.empty())
    112                         groupList.push_back(ArgumentCompletionListElement("", "", "\n"));
     112                        groupList.emplace_back("", "", "\n");
    113113
    114114                    // add the shortcuts
    115                     for (std::map<std::string, ConsoleCommand*>::const_iterator it_command = it_group->second.begin(); it_command != it_group->second.end(); ++it_command)
    116                         if (it_command->second->isActive() && it_command->second->hasAccess() && (!it_command->second->isHidden())^bOnlyShowHidden && (fragmentLC == "" || getLowercase(it_command->first).find(fragmentLC) == 0))
    117                             groupList.push_back(ArgumentCompletionListElement(it_command->first, getLowercase(it_command->first)));
     115                    for (const auto& mapEntry : it_group->second)
     116                        if (mapEntry.second->isActive() && mapEntry.second->hasAccess() && (!mapEntry.second->isHidden())^bOnlyShowHidden && (fragmentLC == "" || getLowercase(mapEntry.first).find(fragmentLC) == 0))
     117                            groupList.emplace_back(mapEntry.first, getLowercase(mapEntry.first));
    118118                }
    119119
     
    138138
    139139                // find the iterator of the given group
    140                 std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommandManager::getInstance().getCommands().begin();
     140                std::map<std::string, std::map<std::string, ConsoleCommand*>>::const_iterator it_group = ConsoleCommandManager::getInstance().getCommands().begin();
    141141                for ( ; it_group != ConsoleCommandManager::getInstance().getCommands().end(); ++it_group)
    142142                    if (getLowercase(it_group->first) == groupLC)
     
    146146                if (it_group != ConsoleCommandManager::getInstance().getCommands().end())
    147147                {
    148                     for (std::map<std::string, ConsoleCommand*>::const_iterator it_command = it_group->second.begin(); it_command != it_group->second.end(); ++it_command)
    149                         if (it_command->second->isActive() && it_command->second->hasAccess() && (!it_command->second->isHidden())^bOnlyShowHidden)
    150                             commandList.push_back(ArgumentCompletionListElement(it_command->first, getLowercase(it_command->first)));
     148                    for (const auto& mapEntry : it_group->second)
     149                        if (mapEntry.second->isActive() && mapEntry.second->hasAccess() && (!mapEntry.second->isHidden())^bOnlyShowHidden)
     150                            commandList.emplace_back(mapEntry.first, getLowercase(mapEntry.first));
    151151                }
    152152
     
    188188            {
    189189                ArgumentCompletionList list;
    190                 list.push_back(ArgumentCompletionListElement("", "", hint));
     190                list.emplace_back("", "", hint);
    191191                return list;
    192192            }
     
    212212            if (tokens.size() == 1)
    213213            {
    214                 std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommandManager::getInstance().getCommands().find(tokens[0]);
     214                std::map<std::string, std::map<std::string, ConsoleCommand*>>::const_iterator it_group = ConsoleCommandManager::getInstance().getCommands().find(tokens[0]);
    215215                if (it_group != ConsoleCommandManager::getInstance().getCommands().end())
    216216                    return detail::_subcommands(fragment, tokens[0], true);
     
    261261                {
    262262                    if (boost::filesystem::is_directory(*file))
    263                         dirlist.push_back(ArgumentCompletionListElement(file->BF_DICTIONARY_ENTRY_NAME() + '/', getLowercase(file->BF_DICTIONARY_ENTRY_NAME()) + '/', file->BF_LEAF() + '/'));
     263                        dirlist.emplace_back(file->BF_DICTIONARY_ENTRY_NAME() + '/', getLowercase(file->BF_DICTIONARY_ENTRY_NAME()) + '/', file->BF_LEAF() + '/');
    264264                    else
    265                         filelist.push_back(ArgumentCompletionListElement(file->BF_DICTIONARY_ENTRY_NAME(), getLowercase(file->BF_DICTIONARY_ENTRY_NAME()), file->BF_LEAF()));
     265                        filelist.emplace_back(file->BF_DICTIONARY_ENTRY_NAME(), getLowercase(file->BF_DICTIONARY_ENTRY_NAME()), file->BF_LEAF());
    266266                    ++file;
    267267                }
     
    281281
    282282            const std::set<std::string>& names = SettingsConfigFile::getInstance().getSectionNames();
    283             for (std::set<std::string>::const_iterator it = names.begin(); it != names.end(); ++it)
    284                 sectionList.push_back(ArgumentCompletionListElement(*it, getLowercase(*it)));
     283            for (const std::string& name : names)
     284                sectionList.emplace_back(name, getLowercase(name));
    285285
    286286            return sectionList;
     
    298298            SettingsConfigFile::ContainerMap::const_iterator upper = settings.getContainerUpperBound(sectionLC);
    299299            for (SettingsConfigFile::ContainerMap::const_iterator it = settings.getContainerLowerBound(sectionLC); it != upper; ++it)
    300                 entryList.push_back(ArgumentCompletionListElement(it->second.second->getName(), it->second.first));
     300                entryList.emplace_back(it->second.second->getName(), it->second.first);
    301301
    302302            return entryList;
     
    319319                {
    320320                    const std::string& valuestring = it->second.second->toString();
    321                     oldValue.push_back(ArgumentCompletionListElement(valuestring, getLowercase(valuestring), "Old value: " + valuestring));
     321                    oldValue.emplace_back(valuestring, getLowercase(valuestring), "Old value: " + valuestring);
    322322                }
    323323            }
     
    334334            ArgumentCompletionList threads;
    335335
    336             for (std::list<unsigned int>::const_iterator it = threadnumbers.begin(); it != threadnumbers.end(); ++it)
    337                 threads.push_back(ArgumentCompletionListElement(multi_cast<std::string>(*it)));
     336            for (unsigned int threadnumber : threadnumbers)
     337                threads.emplace_back(multi_cast<std::string>(threadnumber));
    338338
    339339            return threads;
  • code/trunk/src/libraries/core/command/ArgumentCompletionFunctions.h

    r11052 r11071  
    8686        {
    8787            for (int month = 1; month <= 12; ++month)
    88                 list.push_back(ArgumentCompletionListElement(multi_cast<std::string>(month)));
     88                list.emplace_back(multi_cast<std::string>(month));
    8989        }
    9090        else
    9191        {
    92             list.push_back(ArgumentCompletionListElement("January",   "january"));
    93             list.push_back(ArgumentCompletionListElement("February",  "february"));
    94             list.push_back(ArgumentCompletionListElement("March",     "march"));
    95             list.push_back(ArgumentCompletionListElement("April",     "april"));
    96             list.push_back(ArgumentCompletionListElement("May",       "may"));
    97             list.push_back(ArgumentCompletionListElement("June",      "june"));
    98             list.push_back(ArgumentCompletionListElement("July",      "july"));
    99             list.push_back(ArgumentCompletionListElement("August",    "august"));
    100             list.push_back(ArgumentCompletionListElement("September", "september"));
    101             list.push_back(ArgumentCompletionListElement("October",   "october"));
    102             list.push_back(ArgumentCompletionListElement("November",  "november"));
    103             list.push_back(ArgumentCompletionListElement("December",  "december"));
     92            list.emplace_back("January",   "january");
     93            list.emplace_back("February",  "february");
     94            list.emplace_back("March",     "march");
     95            list.emplace_back("April",     "april");
     96            list.emplace_back("May",       "may");
     97            list.emplace_back("June",      "june");
     98            list.emplace_back("July",      "july");
     99            list.emplace_back("August",    "august");
     100            list.emplace_back("September", "september");
     101            list.emplace_back("October",   "october");
     102            list.emplace_back("November",  "november");
     103            list.emplace_back("December",  "december");
    104104        }
    105105
  • code/trunk/src/libraries/core/command/CommandEvaluation.cc

    r10624 r11071  
    5454    void CommandEvaluation::initialize(const std::string& command)
    5555    {
    56         this->execCommand_ = 0;
    57         this->hintCommand_ = 0;
     56        this->execCommand_ = nullptr;
     57        this->hintCommand_ = nullptr;
    5858        this->string_ = command;
    5959        this->execArgumentsOffset_ = 0;
     
    119119    /**
    120120        @brief Executes the command which was evaluated by this object and returns its return-value.
    121         @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        @param error A pointer to an integer (or nullptr) which will be used to write error codes to (see @ref CommandExecutorErrorCodes "CommandExecutor error codes")
    122122        @return Returns the result of the command (or MultiType::Null if there is no return value)
    123123    */
     
    306306                // the user typed 1-2 arguments, check what he tried to type and print a suitable error
    307307                std::string groupLC = getLowercase(this->getToken(0));
    308                 for (std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommandManager::getInstance().getCommandsLC().begin(); it_group != ConsoleCommandManager::getInstance().getCommandsLC().end(); ++it_group)
    309                     if (it_group->first == groupLC)
     308                for (const auto& mapEntry : ConsoleCommandManager::getInstance().getCommandsLC())
     309                    if (mapEntry.first == groupLC)
    310310                        return std::string("Error: There is no command in group \"") + this->getToken(0) + "\" starting with \"" + this->getToken(1) + "\".";
    311311
     
    328328
    329329        // iterate through all groups and their commands and calculate the distance to the current command. keep the best.
    330         for (std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommandManager::getInstance().getCommandsLC().begin(); it_group != ConsoleCommandManager::getInstance().getCommandsLC().end(); ++it_group)
    331         {
    332             if (it_group->first != "")
    333             {
    334                 for (std::map<std::string, ConsoleCommand*>::const_iterator it_name = it_group->second.begin(); it_name != it_group->second.end(); ++it_name)
    335                 {
    336                     std::string command = it_group->first + " " + it_name->first;
     330        for (const auto& mapEntryGroup : ConsoleCommandManager::getInstance().getCommandsLC())
     331        {
     332            if (mapEntryGroup.first != "")
     333            {
     334                for (const auto& mapEntryName : mapEntryGroup.second)
     335                {
     336                    std::string command = mapEntryGroup.first + " " + mapEntryName.first;
    337337                    unsigned int distance = getLevenshteinDistance(command, token0_LC + " " + token1_LC);
    338338                    if (distance < nearestDistance)
     
    346346
    347347        // now also iterate through all shortcuts and keep the best if it's better than the one found above.
    348         std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommandManager::getInstance().getCommandsLC().find("");
     348        std::map<std::string, std::map<std::string, ConsoleCommand*>>::const_iterator it_group = ConsoleCommandManager::getInstance().getCommandsLC().find("");
    349349        if (it_group !=  ConsoleCommandManager::getInstance().getCommandsLC().end())
    350350        {
    351             for (std::map<std::string, ConsoleCommand*>::const_iterator it_name = it_group->second.begin(); it_name != it_group->second.end(); ++it_name)
    352             {
    353                 std::string command = it_name->first;
     351            for (const auto& mapEntry : it_group->second)
     352            {
     353                std::string command = mapEntry.first;
    354354                unsigned int distance = getLevenshteinDistance(command, token0_LC);
    355355                if (distance < nearestDistance)
     
    429429    {
    430430        size_t count = 0;
    431         for (ArgumentCompletionList::const_iterator it = list.begin(); it != list.end(); ++it)
    432             if (it->getComparable() != "")
     431        for (const ArgumentCompletionListElement& element : list)
     432            if (element.getComparable() != "")
    433433                ++count;
    434434        return count;
     
    495495        {
    496496            // only one (non-empty) value in the list - search it and return it
    497             for (ArgumentCompletionList::const_iterator it = list.begin(); it != list.end(); ++it)
    498             {
    499                 if (it->getComparable() != "")
     497            for (const ArgumentCompletionListElement& element : list)
     498            {
     499                if (element.getComparable() != "")
    500500                {
    501501                    // arguments that have a separate string to be displayed need a little more care - just return them without modification. add a space character to the others.
    502                     if (it->hasDisplay())
    503                         return (it->getString());
     502                    if (element.hasDisplay())
     503                        return (element.getString());
    504504                    else
    505                         return (it->getString() + ' ');
     505                        return (element.getString() + ' ');
    506506                }
    507507            }
     
    517517                char tempComparable = '\0';
    518518                char temp = '\0';
    519                 for (ArgumentCompletionList::const_iterator it = list.begin(); it != list.end(); ++it)
    520                 {
    521                     const std::string& argumentComparable = it->getComparable();
    522                     const std::string& argument = it->getString();
     519                for (const ArgumentCompletionListElement& element : list)
     520                {
     521                    const std::string& argumentComparable = element.getComparable();
     522                    const std::string& argument = element.getString();
    523523
    524524                    // ignore empty arguments
     
    560560    {
    561561        std::string output;
    562         for (ArgumentCompletionList::const_iterator it = list.begin(); it != list.end(); ++it)
    563         {
    564             output += it->getDisplay();
     562        for (const ArgumentCompletionListElement& element : list)
     563        {
     564            output += element.getDisplay();
    565565
    566566            // add a space character between two elements for all non-empty arguments
    567             if (it->getComparable() != "")
     567            if (element.getComparable() != "")
    568568                output += ' ';
    569569        }
  • code/trunk/src/libraries/core/command/CommandEvaluation.h

    r8079 r11071  
    8686
    8787            int execute();
    88             MultiType query(int* error = 0);
     88            MultiType query(int* error = nullptr);
    8989
    9090            std::string complete();
     
    9797            /// Returns true if the command evaluation contains a valid command that can be executed.
    9898            inline bool isValid() const
    99                 { return (this->execCommand_ != 0); }
     99                { return (this->execCommand_ != nullptr); }
    100100
    101101            /// Returns the console command that was evaluated by this object.
     
    137137            static std::string getCommonBegin(const ArgumentCompletionList& list);
    138138
    139             const ConsoleCommand* execCommand_;             ///< The command that will be executed (can be NULL if the command is not valid)
     139            const ConsoleCommand* execCommand_;             ///< The command that will be executed (can be nullptr if the command is not valid)
    140140            const ConsoleCommand* hintCommand_;             ///< The command that is used to display hints and argument lists (can be different to execCommand_ in some cases)
    141141            SubString tokens_;                              ///< The single words of the command string, split into tokens
  • code/trunk/src/libraries/core/command/CommandExecutor.cc

    r10624 r11071  
    8181        @brief Executes a command and returns its return-value.
    8282        @param command A string containing the command
    83         @param error A pointer to a value (or NULL) where the error-code should be written to (see @ref CommandExecutorErrorCodes "error codes")
     83        @param error A pointer to a value (or nullptr) 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)
    8585        @return Returns the return-value of the command (if any - MultiType::Null otherwise)
     
    127127        @brief Executes a command and returns its return-value as string.
    128128        @param command A string containing the command
    129         @param error A pointer to a value (or NULL) where the error-code should be written to (see @ref CommandExecutorErrorCodes "error codes")
     129        @param error A pointer to a value (or nullptr) where the error-code should be written to (see @ref CommandExecutorErrorCodes "error codes")
    130130        @param useTcl If true, the command is passed to tcl (see TclBind)
    131131        @return Returns the return-value of the command converted to a string (or "" if there's no return value)
     
    275275        {
    276276            // it is valid - copy the executor of this command
    277             ExecutorPtr executor = new Executor(*evaluation.getConsoleCommand()->getExecutor().get());
     277            ExecutorPtr executor = std::make_shared<Executor>(*evaluation.getConsoleCommand()->getExecutor().get());
    278278
    279279            // evaluate the arguments and if this returns no error, store them as default values
  • code/trunk/src/libraries/core/command/CommandExecutor.h

    r8858 r11071  
    113113            static int execute(const std::string& command, bool useTcl = true, bool printErrors = true); // tolua_export
    114114
    115             static MultiType queryMT(const std::string& command, int* error = 0, bool useTcl = true);
    116             static std::string query(const std::string& command, int* error = 0, bool useTcl = true); // tolua_export
     115            static MultiType queryMT(const std::string& command, int* error = nullptr, bool useTcl = true);
     116            static std::string query(const std::string& command, int* error = NULL, bool useTcl = true); // tolua_export
    117117
    118118            static CommandEvaluation evaluate(const std::string& command);
    119119
    120             static const int Success = 0;       ///< Error code for "success" (or no error)
    121             static const int Inexistent = 1;    ///< Error code if the command doesn't exist
    122             static const int Incomplete = 2;    ///< Error code if the command needs more arguments
    123             static const int Deactivated = 3;   ///< Error code if the command is not active
    124             static const int Denied = 4;        ///< Error code if the command needs a different access level
    125             static const int Error = 5;         ///< Error code if the command returned an error
     120            static constexpr int Success = 0;       ///< Error code for "success" (or no error)
     121            static constexpr int Inexistent = 1;    ///< Error code if the command doesn't exist
     122            static constexpr int Incomplete = 2;    ///< Error code if the command needs more arguments
     123            static constexpr int Deactivated = 3;   ///< Error code if the command is not active
     124            static constexpr int Denied = 4;        ///< Error code if the command needs a different access level
     125            static constexpr int Error = 5;         ///< Error code if the command returned an error
    126126
    127127            static std::string getErrorDescription(int error);
     
    132132
    133133        private:
    134             CommandExecutor() {}                            ///< Empty constructor
    135             CommandExecutor(const CommandExecutor& other);  ///< Not implemented copy-constructor
    136             ~CommandExecutor() {}                           ///< Empty destructor
     134            CommandExecutor() = default;                      ///< Empty constructor
     135            ~CommandExecutor() = default;                     ///< Empty destructor
     136
     137            // non-copyable:
     138            CommandExecutor(const CommandExecutor&) = delete;
     139            CommandExecutor& operator=(const CommandExecutor&) = delete;
    137140
    138141            static CommandExecutor& getInstance();
  • code/trunk/src/libraries/core/command/ConsoleCommand.cc

    r10624 r11071  
    5050    */
    5151    ConsoleCommand::ConsoleCommand(const std::string& name, const ExecutorPtr& executor, bool bInitialized)
    52     {
    53         this->init("", name, executor, bInitialized);
     52        : ConsoleCommand("", name, executor, bInitialized)
     53    {
    5454    }
    5555
     
    7575        this->baseFunctor_ = executor->getFunctor();
    7676
    77         for (size_t i = 0; i < MAX_FUNCTOR_ARGUMENTS; ++i)
    78             this->argumentCompleter_[i] = 0;
     77        for (ArgumentCompleter*& completer : this->argumentCompleter_)
     78            completer = nullptr;
    7979
    8080        this->keybindMode_ = KeybindMode::OnPress;
     
    8484            this->executor_ = executor;
    8585
    86         this->names_.push_back(CommandName(group, name));
     86        this->names_.emplace_back(group, name);
    8787    }
    8888
     
    9999    ConsoleCommand& ConsoleCommand::addShortcut()
    100100    {
    101         this->names_.push_back(CommandName("", this->baseName_));
     101        this->names_.emplace_back("", this->baseName_);
    102102        return *this;
    103103    }
     
    108108    ConsoleCommand& ConsoleCommand::addShortcut(const std::string&  name)
    109109    {
    110         this->names_.push_back(CommandName("", name));
     110        this->names_.emplace_back("", name);
    111111        return *this;
    112112    }
     
    117117    ConsoleCommand& ConsoleCommand::addGroup(const std::string& group)
    118118    {
    119         this->names_.push_back(CommandName(group, this->baseName_));
     119        this->names_.emplace_back(group, this->baseName_);
    120120        return *this;
    121121    }
     
    126126    ConsoleCommand& ConsoleCommand::addGroup(const std::string& group, const std::string&  name)
    127127    {
    128         this->names_.push_back(CommandName(group, name));
     128        this->names_.emplace_back(group, name);
    129129        return *this;
    130130    }
     
    320320    {
    321321        if (this->executor_)
    322             this->pushFunction(new Executor(*this->executor_.get()));
     322            this->pushFunction(std::make_shared<Executor>(*this->executor_.get()));
    323323        else
    324324            orxout(internal_error, context::commands) << "Couldn't push copy of executor in console command \"" << this->baseName_ << "\", no executor set." << endl;
     
    348348
    349349    /**
    350         @brief Sets the functor to NULL (which also deactivates the command).
     350        @brief Sets the functor to nullptr (which also deactivates the command).
    351351    */
    352352    void ConsoleCommand::resetFunction()
    353353    {
    354354        if (this->executor_)
    355             this->executor_->setFunctor(0);
     355            this->executor_->setFunctor(nullptr);
    356356        this->objectStack_.clear();
    357357    }
     
    405405    void ConsoleCommand::popObject()
    406406    {
    407         void* newobject = 0;
     407        void* newobject = nullptr;
    408408        if (!this->objectStack_.empty())
    409409        {
     
    422422            return this->executor_->getFunctor()->getRawObjectPointer();
    423423        else
    424             return 0;
     424            return nullptr;
    425425    }
    426426
     
    528528            return this->argumentCompleter_[index];
    529529        else
    530             return 0;
     530            return nullptr;
    531531    }
    532532
  • code/trunk/src/libraries/core/command/ConsoleCommand.h

    r10624 r11071  
    6060    }
    6161
    62     namespace AccessLevel
     62    /**
     63        @brief Possible access levels: A command can only be executed if the program is in the state which is requested by the access level.
     64    */
     65    enum class AccessLevel
    6366    {
    64         /**
    65             @brief Possible access levels: A command can only be executed if the program is in the state which is requested by the access level.
    66         */
    67         enum Enum
    68         {
    69             All,
    70             Standalone,
    71             Master,
    72             Server,
    73             Client,
    74             Online,
    75             Offline,
    76             None
    77         };
    78     }
     67        All,
     68        Standalone,
     69        Master,
     70        Server,
     71        Client,
     72        Online,
     73        Offline,
     74        None
     75    };
    7976
    8077    /**
     
    195192                        { if (this->command_) { this->command_->popFunction(); } return *this; }
    196193
    197                     /// Sets the current function-pointer to NULL, which also deactivates the command.
     194                    /// Sets the current function-pointer to nullptr, which also deactivates the command.
    198195                    inline ConsoleCommandManipulator& resetFunction()
    199196                        { if (this->command_) { this->command_->resetFunction(); } return *this; }
     
    205202                    inline ConsoleCommandManipulator& pushObject(void* object)
    206203                        { if (this->command_) { this->command_->pushObject(object); } return *this; }
    207                     /// Removes the current object from the object-stack and restores the old object (or NULL if there's no object left on the stack).
     204                    /// Removes the current object from the object-stack and restores the old object (or nullptr if there's no object left on the stack).
    208205                    inline ConsoleCommandManipulator& popObject()
    209206                        { if (this->command_) { this->command_->popObject(); } return *this; }
     
    249246
    250247                    /// Changes the access level of the command.
    251                     inline ConsoleCommandManipulator& accessLevel(AccessLevel::Enum level)
     248                    inline ConsoleCommandManipulator& accessLevel(AccessLevel level)
    252249                        { if (this->command_) { this->command_->accessLevel(level); } return *this; }
    253250
     
    332329
    333330            /// Changes the access level of the command.
    334             inline ConsoleCommand& accessLevel(AccessLevel::Enum level)
     331            inline ConsoleCommand& accessLevel(AccessLevel level)
    335332                { this->accessLevel_ = level; return *this; }
    336333            /// Returns the access level of the command.
    337             inline AccessLevel::Enum getAccessLevel() const
     334            inline AccessLevel getAccessLevel() const
    338335                { return this->accessLevel_; }
    339336
     
    394391            bool bActive_;                                                  ///< True if the command should be active (it can still be inactive, for example if the function is missing)
    395392            bool bHidden_;                                                  ///< True if the command is hidden (it is still executable, but not visible in the list of available commands)
    396             AccessLevel::Enum accessLevel_;                                 ///< The access level (the state of the game in which you can access the command)
     393            AccessLevel accessLevel_;                                       ///< The access level (the state of the game in which you can access the command)
    397394            std::string baseName_;                                          ///< The name that was first assigned to the command
    398395            std::vector<CommandName> names_;                                ///< All names and aliases of this command
  • code/trunk/src/libraries/core/command/ConsoleCommandIncludes.h

    r10624 r11071  
    316316            ~StaticallyInitializedConsoleCommand() { delete command_; }
    317317
    318             virtual void load();
    319             virtual void unload();
     318            virtual void load() override;
     319            virtual void unload() override;
    320320
    321321            inline ConsoleCommand& getCommand()
     
    331331        @brief Returns a manipulator for a command with the given name.
    332332
    333         @note If the command doesn't exist, the manipulator contains a NULL pointer to the command,
     333        @note If the command doesn't exist, the manipulator contains a nullptr to the command,
    334334        but it can still be used without checks, because all functions of ConsoleCommandManipulator
    335335        check internally if the command exists.
     
    340340        @brief Returns a manipulator for a command with the given group and name.
    341341
    342         @note If the command doesn't exist, the manipulator contains a NULL pointer to the command,
     342        @note If the command doesn't exist, the manipulator contains a nullptr to the command,
    343343        but it can still be used without checks, because all functions of ConsoleCommandManipulator
    344344        check internally if the command exists.
  • code/trunk/src/libraries/core/command/ConsoleCommandManager.cc

    r11052 r11071  
    3939namespace orxonox
    4040{
    41     ConsoleCommandManager* ConsoleCommandManager::singletonPtr_s = 0;
     41    ConsoleCommandManager* ConsoleCommandManager::singletonPtr_s = nullptr;
    4242
    4343    /**
     
    5050    {
    5151        // find the group
    52         std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = this->commandMap_.find(group);
     52        std::map<std::string, std::map<std::string, ConsoleCommand*>>::const_iterator it_group = this->commandMap_.find(group);
    5353        if (it_group != this->commandMap_.end())
    5454        {
     
    6868                orxout(internal_error, context::commands) << "Couldn't find console command with group \"" << group << "\" and name \"" << name << "\"" << endl;
    6969        }
    70         return 0;
     70        return nullptr;
    7171    }
    7272
     
    8383
    8484        // find the group
    85         std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = this->commandMapLC_.find(groupLC);
     85        std::map<std::string, std::map<std::string, ConsoleCommand*>>::const_iterator it_group = this->commandMapLC_.find(groupLC);
    8686        if (it_group != this->commandMapLC_.end())
    8787        {
     
    101101                orxout(internal_error, context::commands) << "Couldn't find console command with group \"" << group << "\" and name \"" << name << "\"" << endl;
    102102        }
    103         return 0;
     103        return nullptr;
    104104    }
    105105
     
    125125
    126126        // check if a command with this name already exists
    127         if (this->getCommand(group, name) != 0)
     127        if (this->getCommand(group, name) != nullptr)
    128128        {
    129129            if (group == "")
     
    146146    {
    147147        // iterate through all groups
    148         for (std::map<std::string, std::map<std::string, ConsoleCommand*> >::iterator it_group = this->commandMap_.begin(); it_group != this->commandMap_.end(); )
     148        for (std::map<std::string, std::map<std::string, ConsoleCommand*>>::iterator it_group = this->commandMap_.begin(); it_group != this->commandMap_.end(); )
    149149        {
    150150            // iterate through all commands of each group
     
    168168
    169169        // iterate through all groups
    170         for (std::map<std::string, std::map<std::string, ConsoleCommand*> >::iterator it_group = this->commandMapLC_.begin(); it_group != this->commandMapLC_.end(); )
     170        for (std::map<std::string, std::map<std::string, ConsoleCommand*>>::iterator it_group = this->commandMapLC_.begin(); it_group != this->commandMapLC_.end(); )
    171171        {
    172172            // iterate through all commands of each group
  • code/trunk/src/libraries/core/command/ConsoleCommandManager.h

    r10624 r11071  
    3939#include "util/Singleton.h"
    4040
     41#include <map>
     42
    4143namespace orxonox
    4244{
     
    5456
    5557            /// Returns the map with all groups and commands.
    56             inline const std::map<std::string, std::map<std::string, ConsoleCommand*> >& getCommands()
     58            inline const std::map<std::string, std::map<std::string, ConsoleCommand*>>& getCommands()
    5759                { return this->commandMap_; }
    5860            /// Returns the map with all groups and commands in lowercase.
    59             inline const std::map<std::string, std::map<std::string, ConsoleCommand*> >& getCommandsLC()
     61            inline const std::map<std::string, std::map<std::string, ConsoleCommand*>>& getCommandsLC()
    6062                { return this->commandMapLC_; }
    6163
     
    7173
    7274        private:
    73             std::map<std::string, std::map<std::string, ConsoleCommand*> > commandMap_;
    74             std::map<std::string, std::map<std::string, ConsoleCommand*> > commandMapLC_;
     75            std::map<std::string, std::map<std::string, ConsoleCommand*>> commandMap_;
     76            std::map<std::string, std::map<std::string, ConsoleCommand*>> commandMapLC_;
    7577
    7678            static ConsoleCommandManager* singletonPtr_s;
  • code/trunk/src/libraries/core/command/Executor.cc

    r9550 r11071  
    6767
    6868    /**
    69         @brief Destructor
    70     */
    71     Executor::~Executor()
    72     {
    73     }
    74 
    75     /**
    7669        @brief Calls the wrapped function with arguments that are passed in a string.
    7770        @param arguments The arguments that should be passed to the function, separated by @a delimiter
    78         @param error A pointer to a variable (or NULL) that is used to store the error code (see @ref CommandExecutorErrorCodes "CommandExecutor error codes")
     71        @param error A pointer to a variable (or nullptr) that is used to store the error code (see @ref CommandExecutorErrorCodes "CommandExecutor error codes")
    7972        @param delimiter The delimiter that is used to separate the arguments in the string @a arguments
    8073        @param bPrintError If true, errors are printed to the console if the function couldn't be executed with the given arguments
     
    8982        @brief Calls the wrapped function with arguments that are passed as tokens in a SubString
    9083        @param arguments The arguments that should be passed to the function
    91         @param error A pointer to a variable (or NULL) that is used to store the error code (see @ref CommandExecutorErrorCodes "CommandExecutor error codes")
     84        @param error A pointer to a variable (or nullptr) that is used to store the error code (see @ref CommandExecutorErrorCodes "CommandExecutor error codes")
    9285        @param delimiter The delimiter that was used to separate the arguments in the SubString @a arguments (used to join the surplus arguments)
    9386        @param bPrintError If true, errors are printed to the console if the function couldn't be executed with the given arguments
     
    127120        @param arguments The arguments that should be converted
    128121        @param arg An array of MultiType where the converted arguments will be stored
    129         @param error A pointer to a variable (or NULL) that is used to store the error code (see @ref CommandExecutorErrorCodes "CommandExecutor error codes")
     122        @param error A pointer to a variable (or nullptr) that is used to store the error code (see @ref CommandExecutorErrorCodes "CommandExecutor error codes")
    130123        @param delimiter The delimiter that was used to separate the arguments in the SubString @a arguments (used to join the surplus arguments)
    131124        @return Returns the number of evaluated arguments
  • code/trunk/src/libraries/core/command/Executor.h

    r9550 r11071  
    4242    orxonox::Executor is used to wrap an orxonox::Functor and to store default values for
    4343    its parameters. Usually one uses the function createExecutor() to create a new executor.
    44     This function returns an orxonox::ExecutorPtr which is a typedef of @ref orxonox::SharedPtr
    45     "SharedPtr<Executor>", used to manage the pointer to the executor.
     44    This function returns an orxonox::ExecutorPtr which is a typedef of "std::shared_ptr<Executor>",
     45    used to manage the pointer to the executor.
    4646
    4747    Executors are mostly used to execute callbacks. Because some callback functions need arguments,
     
    7474    @endcode
    7575
    76     Because executors that were created with createExecutor() are managed by an orxonox::SharedPtr,
    77     they don't need to be deleted after usage.
     76    Executors don't need to be deleted after usage normally because they are managed by an
     77    std::shared_ptr when they were created with createExecutor().
    7878*/
    7979
     
    100100            Executor(const FunctorPtr& functor, const std::string& name = "");
    101101            Executor(const Executor& other);
    102             virtual ~Executor();
     102            virtual ~Executor() = default;
    103103
    104104            /// Calls the wrapped function with 0 arguments. If the function needs more arguments, the executor's default values are used.
     
    121121                { return (*this->functor_)(arg1, arg2, arg3, arg4, arg5); }
    122122
    123             MultiType parse(const std::string& arguments, int* error = 0, const std::string& delimiter = " ", bool bPrintError = false) const;
    124             MultiType parse(const SubString& arguments, int* error = 0, const std::string& delimiter = " ", bool bPrintError = false) const;
    125 
    126             int evaluateArguments(const SubString& arguments, MultiType arg[MAX_FUNCTOR_ARGUMENTS], int* error = 0, const std::string& delimiter = " ") const;
     123            MultiType parse(const std::string& arguments, int* error = nullptr, const std::string& delimiter = " ", bool bPrintError = false) const;
     124            MultiType parse(const SubString& arguments, int* error = nullptr, const std::string& delimiter = " ", bool bPrintError = false) const;
     125
     126            int evaluateArguments(const SubString& arguments, MultiType arg[MAX_FUNCTOR_ARGUMENTS], int* error = nullptr, const std::string& delimiter = " ") const;
    127127
    128128            /// Changes the functor.
     
    147147                { return this->functor_->hasReturnvalue(); }
    148148            /// Returns the type of the wrapped function (static or member).
    149             inline Functor::Type::Enum getType() const
     149            inline Functor::Type getType() const
    150150                { return this->functor_->getType(); }
    151151            /// Returns the name of the type of a parameter with given index (the first parameter has index 0).
     
    249249
    250250            /// Overloads Executor::parse() with an additional object-pointer.
    251             MultiType parse(T* object, const std::string& arguments, int* error = 0, const std::string& delimiter = " ", bool bPrintError = false) const
     251            MultiType parse(T* object, const std::string& arguments, int* error = nullptr, const std::string& delimiter = " ", bool bPrintError = false) const
    252252            {
    253253                T* oldobject = this->functorMember_->getObject();
     
    267267    inline ExecutorPtr createExecutor(const FunctorPtr& functor, const std::string& name = "")
    268268    {
    269         return new Executor(functor, name);
     269        return std::make_shared<Executor>(functor, name);
    270270    }
    271271
     
    274274    inline ExecutorMemberPtr<T> createExecutor(const FunctorMemberPtr<T>& functor, const std::string& name = "")
    275275    {
    276         return new ExecutorMember<T>(functor, name);
     276        return std::make_shared<ExecutorMember<T>>(functor, name);
    277277    }
    278278
     
    280280    inline ExecutorStaticPtr createExecutor(const FunctorStaticPtr& functor, const std::string& name = "")
    281281    {
    282         return new ExecutorStatic(functor, name);
     282        return std::make_shared<ExecutorStatic>(functor, name);
    283283    }
    284284}
  • code/trunk/src/libraries/core/command/ExecutorPtr.h

    r7401 r11071  
    3232    @brief Typedefs and definitions of ExecutorPtr, ExecutorStaticPtr, and ExecutorMemberPtr
    3333
    34     Instances of orxonox::Executor are usually managed by an orxonox::SharedPtr. This ensures
     34    Instances of orxonox::Executor are usually managed by an std::shared_ptr. This ensures
    3535    that Executors will be destroyed after usage. To make things easier, there's a typedef
    36     that defines ExecutorPtr as SharedPtr<Executor>.
     36    that defines ExecutorPtr as std::shared_ptr<Executor>.
    3737
    3838    Because there's not only orxonox::Executor, but also orxonox::ExecutorStatic, and
     
    4949
    5050#include "core/CorePrereqs.h"
    51 #include "util/SharedPtr.h"
     51#include <memory>
    5252
    5353namespace orxonox
    5454{
    55     /// ExecutorPtr is just a typedef of SharedPtr
    56     typedef SharedPtr<Executor> ExecutorPtr;
    57 
    58     /// ExecutorStaticPtr is just a typedef of SharedChildPtr
    59     typedef SharedChildPtr<ExecutorStatic, ExecutorPtr> ExecutorStaticPtr;
    60 
    61     /// It's not possible to use a typedef for ExecutorMemberPtr<T>, so we have to create a child-class instead. It inherits all functions from SharedChildPtr, but needs to (re-)implement some constructors.
     55    using ExecutorPtr = std::shared_ptr<Executor>;
     56    using ExecutorStaticPtr = std::shared_ptr<ExecutorStatic>;
    6257    template <class T>
    63     class ExecutorMemberPtr : public SharedChildPtr<ExecutorMember<T>, ExecutorPtr>
    64     {
    65         public:
    66             inline ExecutorMemberPtr() : SharedChildPtr<ExecutorMember<T>, ExecutorPtr>() {}
    67             inline ExecutorMemberPtr(ExecutorMember<T>* pointer) : SharedChildPtr<ExecutorMember<T>, ExecutorPtr>(pointer) {}
    68             inline ExecutorMemberPtr(const SharedPtr<ExecutorMember<T> >& other) : SharedChildPtr<ExecutorMember<T>, ExecutorPtr>(other) {}
    69     };
     58    using ExecutorMemberPtr = std::shared_ptr<ExecutorMember<T>>;
    7059}
    7160
  • code/trunk/src/libraries/core/command/Functor.h

    r9667 r11071  
    4040
    4141    To create a Functor, the helper function createFunctor() is used. It returns an instance
    42     of orxonox::FunctorPtr which is simply a typedef of @ref orxonox::SharedPtr "SharedPtr<Functor>".
    43     This means you don't have to delete the Functor after using it, because it is managed
    44     by the SharedPtr.
     42    of orxonox::FunctorPtr which is simply a typedef of "std::shared_ptr<Functor>". This
     43    means you don't have to delete the Functor after using it, because it is managed
     44    by the std::shared_ptr.
    4545
    4646    Example:
     
    176176    {
    177177        public:
    178             struct Type
    179             {
    180                 /// Defines the type of a function (static or member)
    181                 enum Enum
    182                 {
    183                     Static,
    184                     Member
    185                 };
     178            /// Defines the type of a function (static or member)
     179            enum class Type
     180            {
     181                Static,
     182                Member
    186183            };
    187184
    188185        public:
    189             virtual ~Functor() {}
     186            virtual ~Functor() = default;
    190187
    191188            /// 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)
     
    196193
    197194            /// Returns the type of the function: static or member.
    198             virtual Type::Enum getType() const = 0;
     195            virtual Type getType() const = 0;
    199196            /// Returns the number of parameters of the function.
    200197            virtual unsigned int getParamCount() const = 0;
     
    215212            virtual void* getRawObjectPointer() const = 0;
    216213
    217             /// Enables or disables the safe mode which causes the functor to change the object pointer to NULL if the object is deleted (only member functors).
     214            /// Enables or disables the safe mode which causes the functor to change the object pointer to nullptr if the object is deleted (only member functors).
    218215            virtual void setSafeMode(bool bSafeMode) = 0;
    219216
     
    242239        public:
    243240            /// Constructor: Stores the object-pointer.
    244             FunctorMember(O* object = 0) : object_(object), bSafeMode_(false) {}
     241            FunctorMember(O* object = nullptr) : object_(object), bSafeMode_(false) {}
    245242            virtual ~FunctorMember() { if (this->bSafeMode_) { this->unregisterObject(this->object_); } }
    246243
    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)
     244            /// Calls the function-pointer with up to five arguments and an object. In case of a static-function, the object can be nullptr. @return Returns the return-value of the function (if any; MultiType::Null otherwise)
    248245            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;
    249246
    250247            // see Functor::operator()()
    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)
     248            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) override
    252249            {
    253250                // call the function if an object was assigned
     
    262259
    263260            // see Functor::getType()
    264             inline Functor::Type::Enum getType() const
     261            virtual inline Functor::Type getType() const override
    265262                { return Functor::Type::Member; }
    266263
     
    280277
    281278            // see Functor::setRawObjectPointer()
    282             inline void setRawObjectPointer(void* object)
     279            virtual inline void setRawObjectPointer(void* object) override
    283280                { this->setObject((O*)object); }
    284281            // see Functor::getRawObjectPointer()
    285             inline void* getRawObjectPointer() const
     282            virtual inline void* getRawObjectPointer() const override
    286283                { return this->object_; }
    287284
    288285            // see Functor::setSafeMode()
    289             inline void setSafeMode(bool bSafeMode)
     286            virtual inline void setSafeMode(bool bSafeMode) override
    290287            {
    291288                if (bSafeMode == this->bSafeMode_)
     
    301298
    302299        protected:
    303             /// Casts the object and registers as destruction listener.
    304             inline void registerObject(O* object)
    305                 { Destroyable* base = dynamic_cast<Destroyable*>(object); if (base) { this->registerAsDestructionListener(base); } }
    306             /// Casts the object and unregisters as destruction listener.
    307             inline void unregisterObject(O* object)
    308                 { Destroyable* base = dynamic_cast<Destroyable*>(object); if (base) { this->unregisterAsDestructionListener(base); } }
    309 
    310             /// Will be called by Destroyable::~Destroyable() if the stored object is deleted and the Functor is in safe mode.
    311             inline void objectDeleted()
    312                 { this->object_ = 0; }
    313 
    314             O* object_;     ///< The stored object-pointer, used to execute a member-function (or NULL for static functions)
    315             bool bSafeMode_; ///< If true, the functor is in safe mode and registers itself as listener at the object and changes the pointer to NULL if the object is deleted
     300            /// Casts the object and registers as destruction listener if the object is a Destroyable.
     301            inline void registerObject(Destroyable* object)
     302                { this->registerAsDestructionListener(object); }
     303
     304            inline void registerObject(void* object) {}
     305
     306            /// Casts the object and unregisters as destruction listener if the object is a Destroyable.
     307            inline void unregisterObject(Destroyable* object)
     308                { this->unregisterAsDestructionListener(object); }
     309
     310            inline void unregisterObject(void* object) {}
     311
     312            /// Will be called by Destroyable::~Destroyable() if the stored object is a Destroyable and deleted and the Functor is in safe mode.
     313            virtual inline void objectDeleted() override
     314                { this->object_ = nullptr; }
     315
     316            O* object_;     ///< The stored object-pointer, used to execute a member-function (or nullptr for static functions)
     317            bool bSafeMode_; ///< If true, the functor is in safe mode and registers itself as listener at the object and changes the pointer to nullptr if the object is deleted
    316318    };
    317319
     
    322324        public:
    323325            /// Constructor: Stores the object-pointer.
    324             FunctorMember(void* object = 0) {}
    325 
    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)
     326            FunctorMember(void* object = nullptr) {}
     327
     328            /// Calls the function-pointer with up to five arguments and an object. In case of a static-function, the object can be nullptr. @return Returns the return-value of the function (if any; MultiType::Null otherwise)
    327329            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;
    328330
    329331            // see Functor::operator()()
    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)
    331             {
    332                 return (*this)((void*)0, param1, param2, param3, param4, param5);
     332            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) override
     333            {
     334                return (*this)((void*)nullptr, param1, param2, param3, param4, param5);
    333335            }
    334336
    335337            // see Functor::getType()
    336             inline Functor::Type::Enum getType() const
     338            virtual inline Functor::Type getType() const override
    337339                { return Functor::Type::Static; }
    338340
    339341            // see Functor::setRawObjectPointer()
    340             inline void setRawObjectPointer(void*)
     342            virtual inline void setRawObjectPointer(void*) override
    341343                { orxout(internal_warning) << "Can't assign an object pointer to a static functor" << endl; }
    342344            // see Functor::getRawObjectPointer()
    343             inline void* getRawObjectPointer() const
    344                 { return 0; }
     345            virtual inline void* getRawObjectPointer() const override
     346                { return nullptr; }
    345347
    346348            // see Functor::setSafeMode()
    347             inline void setSafeMode(bool) {}
     349            virtual inline void setSafeMode(bool) override {}
    348350    };
    349351
     
    352354
    353355    /**
    354         @brief FunctorPointer is a child class of FunctorMember and expands it with a function-pointer.
    355         @param F The type of the function-pointer
    356         @param O The type of the function's class (or void if it's a static function)
     356        @brief FunctorPointer is a child class of FunctorMember and extends it with a function-pointer (or a function-object).
     357        @param F The type of the function-pointer (or the function-object)
     358        @param O The type of the function's class (or void if it's a static function or a function-object)
    357359
    358360        The template FunctorPointer has an additional template parameter that defines the type
    359         of the function-pointer. This can be handy if you want to get or set the function-pointer.
    360         You can then use a static_cast to cast a Functor to FunctorPointer if you know the type
    361         of the function-pointer.
     361        of the function-pointer (or the function-object). This can be handy if you want to get
     362        or set the function-pointer (or the function-object). You can then use a static_cast
     363        to cast a Functor to FunctorPointer if you know the type of the function.
    362364
    363365        However FunctorPointer is not aware of the types of the different parameters or the
     
    369371        public:
    370372            /// Constructor: Initializes the base class and stores the function-pointer.
    371             FunctorPointer(F functionPointer, O* object = 0) : FunctorMember<O>(object), functionPointer_(functionPointer) {}
     373            FunctorPointer(F functionPointer, O* object = nullptr) : FunctorMember<O>(object), functionPointer_(functionPointer) {}
    372374
    373375            /// Changes the function-pointer.
     
    378380                { return this->functionPointer_; }
    379381
    380             // see Functor::getFullIdentifier()
    381             const std::type_info& getFullIdentifier() const
    382                 { return typeid(F); }
    383 
    384382        protected:
    385383            F functionPointer_;     ///< The stored function-pointer
     
    388386    namespace detail
    389387    {
    390         // Helper class to get the type of the function pointer with the given class, parameters, return-value, and constness
    391         template <class R, class O, bool isconst, class P1, class P2, class P3, class P4, class P5> struct FunctionPointer                                            { typedef R (O::*Type)(P1, P2, P3, P4, P5); };
    392         template <class R, class O, class P1, class P2, class P3, class P4, class P5>               struct FunctionPointer<R, O, false, P1, P2, P3, P4, P5>           { typedef R (O::*Type)(P1, P2, P3, P4, P5); };
    393         template <class R, class O, class P1, class P2, class P3, class P4>                         struct FunctionPointer<R, O, false, P1, P2, P3, P4, void>         { typedef R (O::*Type)(P1, P2, P3, P4); };
    394         template <class R, class O, class P1, class P2, class P3>                                   struct FunctionPointer<R, O, false, P1, P2, P3, void, void>       { typedef R (O::*Type)(P1, P2, P3); };
    395         template <class R, class O, class P1, class P2>                                             struct FunctionPointer<R, O, false, P1, P2, void, void, void>     { typedef R (O::*Type)(P1, P2); };
    396         template <class R, class O, class P1>                                                       struct FunctionPointer<R, O, false, P1, void, void, void, void>   { typedef R (O::*Type)(P1); };
    397         template <class R, class O>                                                                 struct FunctionPointer<R, O, false, void, void, void, void, void> { typedef R (O::*Type)(); };
    398         template <class R, class O, class P1, class P2, class P3, class P4, class P5> struct FunctionPointer<R, O, true, P1, P2, P3, P4, P5>           { typedef R (O::*Type)(P1, P2, P3, P4, P5) const; };
    399         template <class R, class O, class P1, class P2, class P3, class P4>           struct FunctionPointer<R, O, true, P1, P2, P3, P4, void>         { typedef R (O::*Type)(P1, P2, P3, P4) const; };
    400         template <class R, class O, class P1, class P2, class P3>                     struct FunctionPointer<R, O, true, P1, P2, P3, void, void>       { typedef R (O::*Type)(P1, P2, P3) const; };
    401         template <class R, class O, class P1, class P2>                               struct FunctionPointer<R, O, true, P1, P2, void, void, void>     { typedef R (O::*Type)(P1, P2) const; };
    402         template <class R, class O, class P1>                                         struct FunctionPointer<R, O, true, P1, void, void, void, void>   { typedef R (O::*Type)(P1) const; };
    403         template <class R, class O>                                                   struct FunctionPointer<R, O, true, void, void, void, void, void> { typedef R (O::*Type)() const; };
    404         template <class R, class P1, class P2, class P3, class P4, class P5> struct FunctionPointer<R, void, false, P1, P2, P3, P4, P5>           { typedef R (*Type)(P1, P2, P3, P4, P5); };
    405         template <class R, class P1, class P2, class P3, class P4>           struct FunctionPointer<R, void, false, P1, P2, P3, P4, void>         { typedef R (*Type)(P1, P2, P3, P4); };
    406         template <class R, class P1, class P2, class P3>                     struct FunctionPointer<R, void, false, P1, P2, P3, void, void>       { typedef R (*Type)(P1, P2, P3); };
    407         template <class R, class P1, class P2>                               struct FunctionPointer<R, void, false, P1, P2, void, void, void>     { typedef R (*Type)(P1, P2); };
    408         template <class R, class P1>                                         struct FunctionPointer<R, void, false, P1, void, void, void, void>   { typedef R (*Type)(P1); };
    409         template <class R>                                                   struct FunctionPointer<R, void, false, void, void, void, void, void> { typedef R (*Type)(); };
    410 
    411         // Helper class, used to call a function-pointer with a given object and parameters and to return its return-value (if available)
    412         template <class R, class O, bool isconst, class P1, class P2, class P3, class P4, class P5> struct FunctorCaller                                              { static inline MultiType call(typename detail::FunctionPointer<R, 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) { return (object->*functionPointer)(param1, param2, param3, param4, param5); } };
    413         template <class R, class O, bool isconst, class P1, class P2, class P3, class P4>           struct FunctorCaller<R, O, isconst, P1, P2, P3, P4, void>         { static inline MultiType call(typename detail::FunctionPointer<R, 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&) { return (object->*functionPointer)(param1, param2, param3, param4); } };
    414         template <class R, class O, bool isconst, class P1, class P2, class P3>                     struct FunctorCaller<R, O, isconst, P1, P2, P3, void, void>       { static inline MultiType call(typename detail::FunctionPointer<R, O, isconst, P1, P2, P3, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType&, const MultiType&) { return (object->*functionPointer)(param1, param2, param3); } };
    415         template <class R, class O, bool isconst, class P1, class P2>                               struct FunctorCaller<R, O, isconst, P1, P2, void, void, void>     { static inline MultiType call(typename detail::FunctionPointer<R, O, isconst, P1, P2, void, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType&, const MultiType&, const MultiType&) { return (object->*functionPointer)(param1, param2); } };
    416         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); } };
    417         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 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; } };
    424         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); } };
    425         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); } };
    426         template <class R, bool isconst, class P1, class P2, class P3>                     struct FunctorCaller<R, void, isconst, P1, P2, P3, void, void>       { static inline MultiType call(typename detail::FunctionPointer<R, void, isconst, P1, P2, P3, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType&, const MultiType&) { return (*functionPointer)(param1, param2, param3); } };
    427         template <class R, bool isconst, class P1, class P2>                               struct FunctorCaller<R, void, isconst, P1, P2, void, void, void>     { static inline MultiType call(typename detail::FunctionPointer<R, void, isconst, P1, P2, void, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType&, const MultiType&, const MultiType&) { return (*functionPointer)(param1, param2); } };
    428         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); } };
    429         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 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; } };
    436 
    437         // Helper class, used to identify the header of a function-pointer (independent of its class)
    438         template <class R, class P1, class P2, class P3, class P4, class P5>
    439         struct FunctorHeaderIdentifier
    440         {};
     388        // Helper class to get the type of the function-pointer (or the function-object) with the given class, parameters, return-value, and constness
     389        template <class F, class R, class O, bool isconst, class... Params> struct FunctionType /* generic type is undefined */;
     390        template <         class R, class O,               class... Params> struct FunctionType<void, R, O,    false, Params...> { typedef R (O::*Type)(Params...); };       // spezialization: non-const member function
     391        template <         class R, class O,               class... Params> struct FunctionType<void, R, O,    true,  Params...> { typedef R (O::*Type)(Params...) const; }; // spezialization: const member function
     392        template <         class R,                        class... Params> struct FunctionType<void, R, void, false, Params...> { typedef R (*Type)(Params...); };          // spezialization: static function
     393        template <class F, class R,                        class... Params> struct FunctionType<F,    R, void, false, Params...> { typedef F Type; };                        // spezialization: function object
     394
     395        // Helper class, used to call a function with a given object and parameters and to return its return-value (if available)
     396        template <class F, class R, class O, bool isconst, class... Params> struct FunctorCaller /* generic type is undefined */;
     397        template <         class R, class O, bool isconst, class... Params> struct FunctorCaller<void, R,    O,    isconst, Params...> { template <class... UnusedParams> static inline MultiType call(typename detail::FunctionType<void, R,    O,    isconst, Params...>::Type functionPointer, O* object, const Params&... parameters, const UnusedParams&...) { return (object->*functionPointer)(parameters...); } };                  // spezialization: member function with return value
     398        template <                  class O, bool isconst, class... Params> struct FunctorCaller<void, void, O,    isconst, Params...> { template <class... UnusedParams> static inline MultiType call(typename detail::FunctionType<void, void, O,    isconst, Params...>::Type functionPointer, O* object, const Params&... parameters, const UnusedParams&...) { (object->*functionPointer)(parameters...); return MultiType::Null; } }; // spezialization: member function without return value
     399        template <         class R,                        class... Params> struct FunctorCaller<void, R,    void, false,   Params...> { template <class... UnusedParams> static inline MultiType call(typename detail::FunctionType<void, R,    void, false,   Params...>::Type functionPointer, void*,     const Params&... parameters, const UnusedParams&...) { return (*functionPointer)(parameters...); } };                          // spezialization: static function with return value
     400        template <                                         class... Params> struct FunctorCaller<void, void, void, false,   Params...> { template <class... UnusedParams> static inline MultiType call(typename detail::FunctionType<void, void, void, false,   Params...>::Type functionPointer, void*,     const Params&... parameters, const UnusedParams&...) { (*functionPointer)(parameters...); return MultiType::Null; } };         // spezialization: static function without return value
     401        template <class F, class R,                        class... Params> struct FunctorCaller<F,    R,    void, false,   Params...> { template <class... UnusedParams> static inline MultiType call(typename detail::FunctionType<F,    R,    void, false,   Params...>::Type functor,         void*,     const Params&... parameters, const UnusedParams&...) { return functor(parameters...); } };                                     // spezialization: function object with return value
     402        template <class F,                                 class... Params> struct FunctorCaller<F,    void, void, false,   Params...> { template <class... UnusedParams> static inline MultiType call(typename detail::FunctionType<F,    void, void, false,   Params...>::Type functor,         void*,     const Params&... parameters, const UnusedParams&...) { functor(parameters...); return MultiType::Null; } };                    // spezialization: function object without return value
    441403
    442404        // Helper class to determine if a function has a returnvalue
     
    448410        { enum { result = false }; };
    449411
    450         // Helper class to count the number of parameters
    451         template <class P1, class P2, class P3, class P4, class P5>
    452         struct FunctorParamCount
    453         { enum { result = 5 }; };
    454         template <class P1, class P2, class P3, class P4>
    455         struct FunctorParamCount<P1, P2, P3, P4, void>
    456         { enum { result = 4 }; };
    457         template <class P1, class P2, class P3>
    458         struct FunctorParamCount<P1, P2, P3, void, void>
    459         { enum { result = 3 }; };
    460         template <class P1, class P2>
    461         struct FunctorParamCount<P1, P2, void, void, void>
    462         { enum { result = 2 }; };
    463         template <class P1>
    464         struct FunctorParamCount<P1, void, void, void, void>
    465         { enum { result = 1 }; };
     412        // Helper class to determine the N-th parameter of a variadic template (with 0 being the index of the first parameter)
     413        template <int n, typename T = void, typename... Other>
     414        struct GetNthParamType
     415        { typedef typename GetNthParamType<n - 1, Other...>::Type Type; };
     416        template <typename T, typename... Other>
     417        struct GetNthParamType<0, T, Other...>
     418        { typedef T Type; };
     419
     420        // Helper structs to deduce the first N types of a parameter pack
     421        template<class... Types> struct type_list {};
     422
     423        template <class T1, class... AllTypes>
     424        struct make_type_list_helper
     425        {
     426            template <std::size_t N, class... Types>
     427            struct make_type_list_impl : make_type_list_helper<AllTypes...>::template make_type_list_impl<N - 1, Types..., T1> {};
     428
     429            template <class... Types>
     430            struct make_type_list_impl<1u, Types...> : type_list<Types..., T1> {};
     431        };
     432
     433        template <class T1>
     434        struct make_type_list_helper<T1>
     435        {
     436            template <std::size_t N, class... Types>
     437            struct make_type_list_impl : type_list<Types..., T1> {};
     438        };
     439
     440        template <std::size_t N, class... Types>
     441        struct make_type_list : make_type_list_helper<Types...>::template make_type_list_impl<N> {};
     442
     443        template <class... Types>
     444        struct make_type_list<0u, Types...> : type_list<> {};
     445
     446        template <std::size_t N>
     447        struct make_type_list<N> : type_list<> {};
     448
    466449        template <>
    467         struct FunctorParamCount<void, void, void, void, void>
    468         { enum { result = 0 }; };
     450        struct make_type_list<0u> : type_list<> {};
    469451    }
    470452
     
    473455        that need to know the exact types of the parameters, return-value, and class.
    474456
     457        @param F the type of the function-object (or void if a function-pointer is used).
    475458        @param R The type of the return-value of the function
    476459        @param O The class of the function
    477460        @param isconst True if the function is a const member-function
    478         @param P1 The type of the first parameter
    479         @param P2 The type of the second parameter
    480         @param P3 The type of the third parameter
    481         @param P4 The type of the fourth parameter
    482         @param P5 The type of the fifth parameter
     461        @param Params The types of the parameters
    483462
    484463        This template has many parameters and is usually not used directly. It is created by
     
    489468        All template arguments can be void.
    490469    */
    491     template <class R, class O, bool isconst, class P1, class P2, class P3, class P4, class P5>
    492     class FunctorTemplate : public FunctorPointer<typename detail::FunctionPointer<R, O, isconst, P1, P2, P3, P4, P5>::Type, O>
    493     {
     470    template <class F, class R, class O, bool isconst, class... Params>
     471    class FunctorTemplate : public FunctorPointer<typename detail::FunctionType<F, R, O, isconst, Params...>::Type, O>
     472    {
     473        static_assert(sizeof...(Params) <= 5, "Only up to 5 parameters are supported");
     474
    494475        public:
    495476            /// Constructor: Initializes the base class.
    496             FunctorTemplate(typename detail::FunctionPointer<R, O, isconst, P1, P2, P3, P4, P5>::Type functionPointer, O* object = 0) : FunctorPointer<typename detail::FunctionPointer<R, O, isconst, P1, P2, P3, P4, P5>::Type, O>(functionPointer, object) {}
     477            FunctorTemplate(typename detail::FunctionType<F, R, O, isconst, Params...>::Type functionPointer, O* object = nullptr) : FunctorPointer<typename detail::FunctionType<F, R, O, isconst, Params...>::Type, O>(functionPointer, object) {}
    497478
    498479            // see FunctorMember::operator()()
    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)
    500             {
    501                 return detail::FunctorCaller<R, O, isconst, P1, P2, P3, P4, P5>::call(this->functionPointer_, object, param1, param2, param3, param4, param5);
     480            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) override
     481            {
     482                return detail::FunctorCaller<F, R, O, isconst, Params...>::call(this->functionPointer_, object, param1, param2, param3, param4, param5);
    502483            }
    503484
    504485            // see Functor::clone()
    505             FunctorPtr clone()
    506             {
    507                 return new FunctorTemplate(*this);
     486            virtual FunctorPtr clone() override
     487            {
     488                return std::make_shared<FunctorTemplate>(*this);
    508489            }
    509490
    510491            // see Functor::evaluateArgument()
    511             void evaluateArgument(unsigned int index, MultiType& argument) const
     492            virtual void evaluateArgument(unsigned int index, MultiType& argument) const override
    512493            {
    513494                switch (index)
    514495                {
    515                     case 0: argument.convert<P1>(); break;
    516                     case 1: argument.convert<P2>(); break;
    517                     case 2: argument.convert<P3>(); break;
    518                     case 3: argument.convert<P4>(); break;
    519                     case 4: argument.convert<P5>(); break;
     496                    case 0: argument.convert<typename detail::GetNthParamType<0, Params...>::Type>(); break;
     497                    case 1: argument.convert<typename detail::GetNthParamType<1, Params...>::Type>(); break;
     498                    case 2: argument.convert<typename detail::GetNthParamType<2, Params...>::Type>(); break;
     499                    case 3: argument.convert<typename detail::GetNthParamType<3, Params...>::Type>(); break;
     500                    case 4: argument.convert<typename detail::GetNthParamType<4, Params...>::Type>(); break;
    520501                }
    521502            }
    522503
    523504            // see Functor::getParamCount()
    524             unsigned int getParamCount() const
    525             {
    526                 return detail::FunctorParamCount<P1, P2, P3, P4, P5>::result;
     505            virtual unsigned int getParamCount() const override
     506            {
     507                return sizeof...(Params);
    527508            }
    528509
    529510            // see Functor::hasReturnvalue()
    530             bool hasReturnvalue() const
     511            virtual bool hasReturnvalue() const override
    531512            {
    532513                return detail::FunctorHasReturnvalue<R>::result;
     
    534515
    535516            // see Functor::getTypenameParam()
    536             std::string getTypenameParam(unsigned int index) const
     517            virtual std::string getTypenameParam(unsigned int index) const override
    537518            {
    538519                switch (index)
    539520                {
    540                     case 0:  return typeToString<P1>();
    541                     case 1:  return typeToString<P2>();
    542                     case 2:  return typeToString<P3>();
    543                     case 3:  return typeToString<P4>();
    544                     case 4:  return typeToString<P5>();
     521                    case 0:  return typeToString<typename detail::GetNthParamType<0, Params...>::Type>();
     522                    case 1:  return typeToString<typename detail::GetNthParamType<1, Params...>::Type>();
     523                    case 2:  return typeToString<typename detail::GetNthParamType<2, Params...>::Type>();
     524                    case 3:  return typeToString<typename detail::GetNthParamType<3, Params...>::Type>();
     525                    case 4:  return typeToString<typename detail::GetNthParamType<4, Params...>::Type>();
    545526                    default: return "";
    546527                }
     
    548529
    549530            // see Functor::getTypenameReturnvalue()
    550             std::string getTypenameReturnvalue() const
     531            virtual std::string getTypenameReturnvalue() const override
    551532            {
    552533                return typeToString<R>();
    553534            }
    554535
     536            // see Functor::getFullIdentifier()
     537            virtual const std::type_info& getFullIdentifier() const override
     538            {
     539                return typeid(typename detail::FunctionType<void, R, O, isconst, Params...>::Type);
     540            }
     541
    555542            // see Functor::getHeaderIdentifier()
    556             const std::type_info& getHeaderIdentifier() const
    557             {
    558                 return typeid(detail::FunctorHeaderIdentifier<R, P1, P2, P3, P4, P5>);
     543            virtual const std::type_info& getHeaderIdentifier() const override
     544            {
     545                return typeid(typename detail::FunctionType<void, R, void, false, Params...>::Type);
    559546            }
    560547
    561548            // see Functor::getHeaderIdentifier(unsigned int)
    562             const std::type_info& getHeaderIdentifier(unsigned int params) const
     549            virtual const std::type_info& getHeaderIdentifier(unsigned int params) const override
    563550            {
    564551                switch (params)
    565552                {
    566                     case 0:  return typeid(detail::FunctorHeaderIdentifier<R, void, void, void, void, void>);
    567                     case 1:  return typeid(detail::FunctorHeaderIdentifier<R, P1, void, void, void, void>);
    568                     case 2:  return typeid(detail::FunctorHeaderIdentifier<R, P1, P2, void, void, void>);
    569                     case 3:  return typeid(detail::FunctorHeaderIdentifier<R, P1, P2, P3, void, void>);
    570                     case 4:  return typeid(detail::FunctorHeaderIdentifier<R, P1, P2, P3, P4, void>);
    571                     default: return typeid(detail::FunctorHeaderIdentifier<R, P1, P2, P3, P4, P5>);
     553                    case 0:  return this->getTypelistIdentifier(detail::make_type_list<0, Params...>{});
     554                    case 1:  return this->getTypelistIdentifier(detail::make_type_list<1, Params...>{});
     555                    case 2:  return this->getTypelistIdentifier(detail::make_type_list<2, Params...>{});
     556                    case 3:  return this->getTypelistIdentifier(detail::make_type_list<3, Params...>{});
     557                    case 4:  return this->getTypelistIdentifier(detail::make_type_list<4, Params...>{});
     558                    default: return this->getTypelistIdentifier(detail::make_type_list<5, Params...>{});
    572559                }
    573560            }
     561
     562    private:
     563            /// Helper function that deduces a parameter pack of types and returns the corresponding identifier
     564            template<class... Types>
     565            const std::type_info& getTypelistIdentifier(detail::type_list<Types...>) const
     566            {
     567                return typeid(typename detail::FunctionType<void, R, void, false, Types...>::Type);
     568            }
    574569    };
    575570
    576     template <class R, class O, class OO, class P1, class P2, class P3, class P4, class P5> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4, P5), OO* object) { return new FunctorTemplate<R, O, false, P1, P2, P3, P4, P5>(functionPointer, object); }   ///< Creates a new FunctorMember with the given function-pointer and an assigned object
    577     template <class R, class O, class OO, class P1, class P2, class P3, class P4>           inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4), OO* object)     { return new FunctorTemplate<R, O, false, P1, P2, P3, P4, void>(functionPointer, object); }   ///< Creates a new FunctorMember with the given function-pointer and an assigned object
    578     template <class R, class O, class OO, class P1, class P2, class P3>                     inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3), OO* object)         { return new FunctorTemplate<R, O, false, P1, P2, P3, void, void>(functionPointer, object); }   ///< Creates a new FunctorMember with the given function-pointer and an assigned object
    579     template <class R, class O, class OO, class P1, class P2>                               inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2), OO* object)             { return new FunctorTemplate<R, O, false, P1, P2, void, void, void>(functionPointer, object); }   ///< Creates a new FunctorMember with the given function-pointer and an assigned object
    580     template <class R, class O, class OO, class P1>                                         inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1), OO* object)                 { return new FunctorTemplate<R, O, false, P1, void, void, void, void>(functionPointer, object); }   ///< Creates a new FunctorMember with the given function-pointer and an assigned object
    581     template <class R, class O, class OO>                                                   inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(), OO* object)                   { return new FunctorTemplate<R, O, false, void, void, void, void, void>(functionPointer, object); }   ///< Creates a new FunctorMember with the given function-pointer and an assigned object
    582     template <class R, class O, class OO, class P1, class P2, class P3, class P4, class P5> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4, P5) const, OO* object) { return new FunctorTemplate<R, O, true, P1, P2, P3, P4, P5>(functionPointer, object); }   ///< Creates a new FunctorMember with the given function-pointer and an assigned object
    583     template <class R, class O, class OO, class P1, class P2, class P3, class P4>           inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4) const, OO* object)     { return new FunctorTemplate<R, O, true, P1, P2, P3, P4, void>(functionPointer, object); }   ///< Creates a new FunctorMember with the given function-pointer and an assigned object
    584     template <class R, class O, class OO, class P1, class P2, class P3>                     inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3) const, OO* object)         { return new FunctorTemplate<R, O, true, P1, P2, P3, void, void>(functionPointer, object); }   ///< Creates a new FunctorMember with the given function-pointer and an assigned object
    585     template <class R, class O, class OO, class P1, class P2>                               inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2) const, OO* object)             { return new FunctorTemplate<R, O, true, P1, P2, void, void, void>(functionPointer, object); }   ///< Creates a new FunctorMember with the given function-pointer and an assigned object
    586     template <class R, class O, class OO, class P1>                                         inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1) const, OO* object)                 { return new FunctorTemplate<R, O, true, P1, void, void, void, void>(functionPointer, object); }   ///< Creates a new FunctorMember with the given function-pointer and an assigned object
    587     template <class R, class O, class OO>                                                   inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)() const, OO* object)                   { return new FunctorTemplate<R, O, true, void, void, void, void, void>(functionPointer, object); }   ///< Creates a new FunctorMember with the given function-pointer and an assigned object
    588 
    589     template <class R, class O, class P1, class P2, class P3, class P4, class P5> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4, P5)) { return new FunctorTemplate<R, O, false, P1, P2, P3, P4, P5>(functionPointer); }   ///< Creates a new FunctorMember with the given function-pointer
    590     template <class R, class O, class P1, class P2, class P3, class P4>           inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4))     { return new FunctorTemplate<R, O, false, P1, P2, P3, P4, void>(functionPointer); }   ///< Creates a new FunctorMember with the given function-pointer
    591     template <class R, class O, class P1, class P2, class P3>                     inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3))         { return new FunctorTemplate<R, O, false, P1, P2, P3, void, void>(functionPointer); }   ///< Creates a new FunctorMember with the given function-pointer
    592     template <class R, class O, class P1, class P2>                               inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2))             { return new FunctorTemplate<R, O, false, P1, P2, void, void, void>(functionPointer); }   ///< Creates a new FunctorMember with the given function-pointer
    593     template <class R, class O, class P1>                                         inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1))                 { return new FunctorTemplate<R, O, false, P1, void, void, void, void>(functionPointer); }   ///< Creates a new FunctorMember with the given function-pointer
    594     template <class R, class O>                                                   inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)())                   { return new FunctorTemplate<R, O, false, void, void, void, void, void>(functionPointer); }   ///< Creates a new FunctorMember with the given function-pointer
    595     template <class R, class O, class P1, class P2, class P3, class P4, class P5> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4, P5) const) { return new FunctorTemplate<R, O, true, P1, P2, P3, P4, P5>(functionPointer); }   ///< Creates a new FunctorMember with the given function-pointer
    596     template <class R, class O, class P1, class P2, class P3, class P4>           inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4) const)     { return new FunctorTemplate<R, O, true, P1, P2, P3, P4, void>(functionPointer); }   ///< Creates a new FunctorMember with the given function-pointer
    597     template <class R, class O, class P1, class P2, class P3>                     inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3) const)         { return new FunctorTemplate<R, O, true, P1, P2, P3, void, void>(functionPointer); }   ///< Creates a new FunctorMember with the given function-pointer
    598     template <class R, class O, class P1, class P2>                               inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2) const)             { return new FunctorTemplate<R, O, true, P1, P2, void, void, void>(functionPointer); }   ///< Creates a new FunctorMember with the given function-pointer
    599     template <class R, class O, class P1>                                         inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1) const)                 { return new FunctorTemplate<R, O, true, P1, void, void, void, void>(functionPointer); }   ///< Creates a new FunctorMember with the given function-pointer
    600     template <class R, class O>                                                   inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)() const)                   { return new FunctorTemplate<R, O, true, void, void, void, void, void>(functionPointer); }   ///< Creates a new FunctorMember with the given function-pointer
    601 
    602     template <class R, class P1, class P2, class P3, class P4, class P5> inline FunctorStaticPtr createFunctor(R (*functionPointer)(P1, P2, P3, P4, P5)) { return new FunctorTemplate<R, void, false, P1, P2, P3, P4, P5>(functionPointer); }   ///< Creates a new Functor with the given function-pointer
    603     template <class R, class P1, class P2, class P3, class P4>           inline FunctorStaticPtr createFunctor(R (*functionPointer)(P1, P2, P3, P4))     { return new FunctorTemplate<R, void, false, P1, P2, P3, P4, void>(functionPointer); }   ///< Creates a new Functor with the given function-pointer
    604     template <class R, class P1, class P2, class P3>                     inline FunctorStaticPtr createFunctor(R (*functionPointer)(P1, P2, P3))         { return new FunctorTemplate<R, void, false, P1, P2, P3, void, void>(functionPointer); }   ///< Creates a new Functor with the given function-pointer
    605     template <class R, class P1, class P2>                               inline FunctorStaticPtr createFunctor(R (*functionPointer)(P1, P2))             { return new FunctorTemplate<R, void, false, P1, P2, void, void, void>(functionPointer); }   ///< Creates a new Functor with the given function-pointer
    606     template <class R, class P1>                                         inline FunctorStaticPtr createFunctor(R (*functionPointer)(P1))                 { return new FunctorTemplate<R, void, false, P1, void, void, void, void>(functionPointer); }   ///< Creates a new Functor with the given function-pointer
    607     template <class R>                                                   inline FunctorStaticPtr createFunctor(R (*functionPointer)())                   { return new FunctorTemplate<R, void, false, void, void, void, void, void>(functionPointer); }   ///< Creates a new Functor with the given function-pointer
     571
     572    namespace detail
     573    {
     574        // Helper functions to deduce types and constness of operator() and return the correct FunctorTemplate
     575        template <class F>
     576        struct CallableHelper
     577        {
     578            template <class R, class... Params> static inline FunctorStaticPtr create(const F& functionObject, R(F::*)(Params...))       { return std::make_shared<FunctorTemplate<F, R, void, false, Params...>>(functionObject); }
     579            template <class R, class... Params> static inline FunctorStaticPtr create(const F& functionObject, R(F::*)(Params...) const) { return std::make_shared<FunctorTemplate<F, R, void, false, Params...>>(functionObject); } // note: both const and non-const function-objects are treated as static functors with isconst=false.
     580        };
     581    }
     582
     583    template <class R, class O, class OO, class... Params> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(Params...),       OO* object) { return std::make_shared<FunctorTemplate<void, R, O, false, Params...>>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object
     584    template <class R, class O, class OO, class... Params> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(Params...) const, OO* object) { return std::make_shared<FunctorTemplate<void, R, O, true,  Params...>>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object
     585
     586    template <class R, class O, class... Params> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(Params...))       { return std::make_shared<FunctorTemplate<void, R, O, false, Params...>>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer
     587    template <class R, class O, class... Params> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(Params...) const) { return std::make_shared<FunctorTemplate<void, R, O, true,  Params...>>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer
     588
     589    template <class R, class... Params> inline FunctorStaticPtr createFunctor(R (*functionPointer)(Params...)) { return std::make_shared<FunctorTemplate<void, R, void, false, Params...>>(functionPointer); } ///< Creates a new FunctorStatic with the given function-pointer
     590
     591    /** Take care that this functor does not outlive objects that have been captured by reference in a lambda. */
     592    template <class F> inline FunctorStaticPtr createFunctor(const F& functionObject) { return detail::CallableHelper<F>::create(functionObject, &F::operator()); } ///< Creates a new Functor with a callable object
    608593}
    609594
  • code/trunk/src/libraries/core/command/FunctorPtr.h

    r7401 r11071  
    3232    @brief Typedefs and definitions of FunctorPtr, FunctorMemberPtr, FunctorStaticPtr, and FunctorPointerPtr
    3333
    34     Instances of orxonox::Functor are usually managed by an orxonox::SharedPtr. This ensures
     34    Instances of orxonox::Functor are usually managed by an std::shared_ptr. This ensures
    3535    that Functors will be destroyed after usage. To make things easier, there's a typedef
    36     that defines FunctorPtr as SharedPtr<Functor>.
     36    that defines FunctorPtr as std::shared_ptr<Functor>.
    3737
    3838    Because there's not only orxonox::Functor, but also orxonox::FunctorStatic, and
     
    5151
    5252#include "core/CorePrereqs.h"
    53 #include "util/SharedPtr.h"
     53#include <memory>
    5454
    5555namespace orxonox
    5656{
    57     /// FunctorPtr is just a typedef of SharedPtr
    58     typedef SharedPtr<Functor> FunctorPtr;
    59 
    60     /// It's not possible to use a typedef for FunctorMemberPtr<T>, so we have to create a child-class instead. It inherits all functions from SharedChildPtr, but needs to (re-)implement some constructors.
     57    using FunctorPtr = std::shared_ptr<Functor>;
    6158    template <class T>
    62     class FunctorMemberPtr : public SharedChildPtr<FunctorMember<T>, FunctorPtr>
    63     {
    64         public:
    65             inline FunctorMemberPtr() : SharedChildPtr<FunctorMember<T>, FunctorPtr>() {}
    66             inline FunctorMemberPtr(FunctorMember<T>* pointer) : SharedChildPtr<FunctorMember<T>, FunctorPtr>(pointer) {}
    67             inline FunctorMemberPtr(const SharedPtr<FunctorMember<T> >& other) : SharedChildPtr<FunctorMember<T>, FunctorPtr>(other) {}
    68     };
    69 
    70     /// FunctorStaticPtr is just FunctorMemberPtr with @a T = void
    71     typedef FunctorMemberPtr<void> FunctorStaticPtr;
    72 
    73     /// It's not possible to use a typedef for FunctorPointerPtr<T>, so we have to create a child-class instead. It inherits all functions from SharedChildPtr, but needs to (re-)implement some constructors.
     59    using FunctorMemberPtr = std::shared_ptr<FunctorMember<T>>;
     60    using FunctorStaticPtr = std::shared_ptr<FunctorMember<void>>;
    7461    template <class F, class T>
    75     class FunctorPointerPtr : public SharedChildPtr<FunctorPointer<F, T>, FunctorMemberPtr<T> >
    76     {
    77         public:
    78             inline FunctorPointerPtr() : SharedChildPtr<FunctorPointer<F, T>, FunctorMemberPtr<T> >() {}
    79             inline FunctorPointerPtr(FunctorPointer<F, T>* pointer) : SharedChildPtr<FunctorPointer<F, T>, FunctorMemberPtr<T> >(pointer) {}
    80             inline FunctorPointerPtr(const SharedPtr<FunctorPointer<F, T> >& other) : SharedChildPtr<FunctorPointer<F, T>, FunctorMemberPtr<T> >(other) {}
    81     };
     62    using FunctorPointerPtr = std::shared_ptr<FunctorPointer<F, T>>;
    8263}
    8364
  • code/trunk/src/libraries/core/command/IOConsolePOSIX.cc

    r9667 r11071  
    4444namespace orxonox
    4545{
    46     IOConsole* IOConsole::singletonPtr_s = NULL;
    47 
    48     namespace EscapeMode
    49     {
    50         enum Value
    51         {
    52             None,
    53             First,
    54             Second
    55         };
    56     }
     46    IOConsole* IOConsole::singletonPtr_s = nullptr;
     47
     48    enum class EscapeMode
     49    {
     50        None,
     51        First,
     52        Second
     53    };
    5754
    5855    IOConsole::IOConsole()
     
    6259        , promptString_("orxonox # ")
    6360        , bStatusPrinted_(false)
    64         , originalTerminalSettings_(0)
     61        , originalTerminalSettings_(nullptr)
    6562    {
    6663        this->setTerminalMode();
     
    9087        std::cout.flush();
    9188        if (!this->origCout_.str().empty())
    92             this->shell_->addOutput(this->origCout_.str(), Shell::Cout);
     89            this->shell_->addOutput(this->origCout_.str(), Shell::LineType::Cout);
    9390        // Erase input and status lines
    9491        this->cout_ << "\033[1G\033[J";
     
    111108        unsigned char c;
    112109        std::string escapeSequence;
    113         EscapeMode::Value escapeMode = EscapeMode::None;
     110        EscapeMode escapeMode = EscapeMode::None;
    114111        while (std::cin.good())
    115112        {
     
    231228        if (!this->origCout_.str().empty())
    232229        {
    233             this->shell_->addOutput(this->origCout_.str(), Shell::Cout);
     230            this->shell_->addOutput(this->origCout_.str(), Shell::LineType::Cout);
    234231            this->origCout_.str("");
    235232        }
     
    241238        switch (type)
    242239        {
    243             case Shell::Message:
    244             case Shell::DebugOutput:     this->cout_ << "\033[0m"; break;
    245 
    246             case Shell::UserError:       this->cout_ << "\033[91m"; break;
    247             case Shell::UserWarning:     this->cout_ << "\033[93m"; break;
    248             case Shell::UserStatus:      this->cout_ << "\033[92m"; break;
    249             case Shell::UserInfo:        this->cout_ << "\033[96m"; break;
    250 
    251             case Shell::InternalError:   this->cout_ << "\033[31m"; break;
    252             case Shell::InternalWarning: this->cout_ << "\033[33m"; break;
    253             case Shell::InternalStatus:  this->cout_ << "\033[32m"; break;
    254             case Shell::InternalInfo:    this->cout_ << "\033[36m"; break;
    255 
    256             case Shell::Verbose:         this->cout_ << "\033[94m"; break;
    257             case Shell::VerboseMore:     this->cout_ << "\033[34m"; break;
    258             case Shell::VerboseUltra:    this->cout_ << "\033[34m"; break;
    259 
    260             case Shell::Command:         this->cout_ << "\033[95m"; break;
    261             case Shell::Hint:            this->cout_ << "\033[35m"; break;
    262 
    263             default:                     this->cout_ << "\033[37m"; break;
     240            case Shell::LineType::Message:
     241            case Shell::LineType::DebugOutput:     this->cout_ << "\033[0m"; break;
     242
     243            case Shell::LineType::UserError:       this->cout_ << "\033[91m"; break;
     244            case Shell::LineType::UserWarning:     this->cout_ << "\033[93m"; break;
     245            case Shell::LineType::UserStatus:      this->cout_ << "\033[92m"; break;
     246            case Shell::LineType::UserInfo:        this->cout_ << "\033[96m"; break;
     247
     248            case Shell::LineType::InternalError:   this->cout_ << "\033[31m"; break;
     249            case Shell::LineType::InternalWarning: this->cout_ << "\033[33m"; break;
     250            case Shell::LineType::InternalStatus:  this->cout_ << "\033[32m"; break;
     251            case Shell::LineType::InternalInfo:    this->cout_ << "\033[36m"; break;
     252
     253            case Shell::LineType::Verbose:         this->cout_ << "\033[94m"; break;
     254            case Shell::LineType::VerboseMore:     this->cout_ << "\033[34m"; break;
     255            case Shell::LineType::VerboseUltra:    this->cout_ << "\033[34m"; break;
     256
     257            case Shell::LineType::Command:         this->cout_ << "\033[95m"; break;
     258            case Shell::LineType::Hint:            this->cout_ << "\033[35m"; break;
     259
     260            default:                               this->cout_ << "\033[37m"; break;
    264261        }
    265262
     
    326323            tcsetattr(0, TCSANOW, IOConsole::singletonPtr_s->originalTerminalSettings_);
    327324            delete IOConsole::singletonPtr_s->originalTerminalSettings_;
    328             IOConsole::singletonPtr_s->originalTerminalSettings_ = 0;
     325            IOConsole::singletonPtr_s->originalTerminalSettings_ = nullptr;
    329326        }
    330327    }
     
    353350        const char* s;
    354351        if (!this->terminalWidth_ && (s = getenv("COLUMNS")))
    355             this->terminalWidth_  = strtol(s, NULL, 10);
     352            this->terminalWidth_  = strtol(s, nullptr, 10);
    356353        if (!this->terminalWidth_)
    357354            this->terminalWidth_ = 80;
    358355        if (!this->terminalHeight_ && (s = getenv("LINES")))
    359             this->terminalHeight_ = strtol(s, NULL, 10);
     356            this->terminalHeight_ = strtol(s, nullptr, 10);
    360357        if (!this->terminalHeight_)
    361358            this->terminalHeight_ = 24;
     
    384381    void IOConsole::executed()
    385382    {
    386         this->shell_->addOutput(this->promptString_ + this->shell_->getInput(), Shell::Command);
     383        this->shell_->addOutput(this->promptString_ + this->shell_->getInput(), Shell::LineType::Command);
    387384    }
    388385
  • code/trunk/src/libraries/core/command/IOConsolePOSIX.h

    r8858 r11071  
    6565
    6666        // Methods from ShellListener
    67         void linesChanged();
    68         void lineAdded();
    69         void inputChanged();
    70         void cursorChanged();
    71         void executed();
    72         void exit();
     67        virtual void linesChanged() override;
     68        virtual void lineAdded() override;
     69        virtual void inputChanged() override;
     70        virtual void cursorChanged() override;
     71        virtual void executed() override;
     72        virtual void exit() override;
    7373
    7474        bool willPrintStatusLines();
  • code/trunk/src/libraries/core/command/IOConsoleWindows.cc

    r9676 r11071  
    4141namespace orxonox
    4242{
    43     IOConsole* IOConsole::singletonPtr_s = NULL;
     43    IOConsole* IOConsole::singletonPtr_s = nullptr;
    4444
    4545    //! Redirects std::cout, creates the corresponding Shell and changes the terminal mode
     
    9797        std::cout.flush();
    9898        if (!this->origCout_.str().empty())
    99             this->shell_->addOutput(this->origCout_.str(), Shell::Cout);
     99            this->shell_->addOutput(this->origCout_.str(), Shell::LineType::Cout);
    100100
    101101        this->shell_->unregisterListener(this);
     
    190190        if (!this->origCout_.str().empty())
    191191        {
    192             this->shell_->addOutput(this->origCout_.str(), Shell::Cout);
     192            this->shell_->addOutput(this->origCout_.str(), Shell::LineType::Cout);
    193193            this->origCout_.str("");
    194194        }
     
    202202        switch (type)
    203203        {
    204             case Shell::Message:
    205             case Shell::DebugOutput:     colour = FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE; break;
    206 
    207             case Shell::UserError:       colour = FOREGROUND_INTENSITY | FOREGROUND_RED | 0                | 0              ; break;
    208             case Shell::UserWarning:     colour = FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | 0              ; break;
    209             case Shell::UserStatus:      colour = FOREGROUND_INTENSITY | 0              | FOREGROUND_GREEN | 0              ; break;
    210             case Shell::UserInfo:        colour = FOREGROUND_INTENSITY | 0              | FOREGROUND_GREEN | FOREGROUND_BLUE; break;
    211 
    212             case Shell::InternalError:   colour = 0                    | FOREGROUND_RED | 0                | 0              ; break;
    213             case Shell::InternalWarning: colour = 0                    | FOREGROUND_RED | FOREGROUND_GREEN | 0              ; break;
    214             case Shell::InternalStatus:  colour = 0                    | 0              | FOREGROUND_GREEN | 0              ; break;
    215             case Shell::InternalInfo:    colour = 0                    | 0              | FOREGROUND_GREEN | FOREGROUND_BLUE; break;
    216 
    217             case Shell::Verbose:         colour = FOREGROUND_INTENSITY | 0              | 0                | FOREGROUND_BLUE; break;
    218             case Shell::VerboseMore:     colour = FOREGROUND_INTENSITY | 0              | 0                | FOREGROUND_BLUE; break;
    219             case Shell::VerboseUltra:    colour = FOREGROUND_INTENSITY | 0              | 0                | FOREGROUND_BLUE; break;
    220 
    221             case Shell::Command:         colour = FOREGROUND_INTENSITY | FOREGROUND_RED | 0                | FOREGROUND_BLUE; break;
    222             case Shell::Hint:            colour = 0                    | FOREGROUND_RED | 0                | FOREGROUND_BLUE; break;
    223 
    224             default:                     colour = 0                    | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE; break;
     204            case Shell::LineType::Message:
     205            case Shell::LineType::DebugOutput:     colour = FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE; break;
     206
     207            case Shell::LineType::UserError:       colour = FOREGROUND_INTENSITY | FOREGROUND_RED | 0                | 0              ; break;
     208            case Shell::LineType::UserWarning:     colour = FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | 0              ; break;
     209            case Shell::LineType::UserStatus:      colour = FOREGROUND_INTENSITY | 0              | FOREGROUND_GREEN | 0              ; break;
     210            case Shell::LineType::UserInfo:        colour = FOREGROUND_INTENSITY | 0              | FOREGROUND_GREEN | FOREGROUND_BLUE; break;
     211
     212            case Shell::LineType::InternalError:   colour = 0                    | FOREGROUND_RED | 0                | 0              ; break;
     213            case Shell::LineType::InternalWarning: colour = 0                    | FOREGROUND_RED | FOREGROUND_GREEN | 0              ; break;
     214            case Shell::LineType::InternalStatus:  colour = 0                    | 0              | FOREGROUND_GREEN | 0              ; break;
     215            case Shell::LineType::InternalInfo:    colour = 0                    | 0              | FOREGROUND_GREEN | FOREGROUND_BLUE; break;
     216
     217            case Shell::LineType::Verbose:         colour = FOREGROUND_INTENSITY | 0              | 0                | FOREGROUND_BLUE; break;
     218            case Shell::LineType::VerboseMore:     colour = FOREGROUND_INTENSITY | 0              | 0                | FOREGROUND_BLUE; break;
     219            case Shell::LineType::VerboseUltra:    colour = FOREGROUND_INTENSITY | 0              | 0                | FOREGROUND_BLUE; break;
     220
     221            case Shell::LineType::Command:         colour = FOREGROUND_INTENSITY | FOREGROUND_RED | 0                | FOREGROUND_BLUE; break;
     222            case Shell::LineType::Hint:            colour = 0                    | FOREGROUND_RED | 0                | FOREGROUND_BLUE; break;
     223
     224            default:                               colour = 0                    | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE; break;
    225225        }
    226226
     
    300300                this->terminalWidth_ - 1, this->inputLineRow_ + this->inputLineHeight_ + this->statusLines_ - 1);
    301301            this->inputLineRow_ += linesDown;
    302             ScrollConsoleScreenBuffer(stdOutHandle_, &oldRect, NULL, makeCOORD(0, this->inputLineRow_), &fillChar);
     302            ScrollConsoleScreenBuffer(stdOutHandle_, &oldRect, nullptr, makeCOORD(0, this->inputLineRow_), &fillChar);
    303303            // Move cursor down to the new bottom so the user can see the status lines
    304304            COORD pos = makeCOORD(0, this->inputLineRow_ + this->inputLineHeight_ - 1 + this->statusLines_);
     
    312312            // Scroll output up
    313313            SMALL_RECT oldRect = makeSMALL_RECT(0, lines - linesDown, this->terminalWidth_ - 1, this->inputLineRow_ - 1);
    314             ScrollConsoleScreenBuffer(stdOutHandle_, &oldRect, NULL, makeCOORD(0, 0), &fillChar);
     314            ScrollConsoleScreenBuffer(stdOutHandle_, &oldRect, nullptr, makeCOORD(0, 0), &fillChar);
    315315        }
    316316    }
     
    331331    void IOConsole::executed()
    332332    {
    333         this->shell_->addOutput(this->promptString_ + this->shell_->getInput(), Shell::Command);
     333        this->shell_->addOutput(this->promptString_ + this->shell_->getInput(), Shell::LineType::Command);
    334334    }
    335335
     
    360360            SMALL_RECT oldRect = makeSMALL_RECT(0, statusLineRow, this->terminalWidth_ - 1, statusLineRow + this->statusLines_);
    361361            CHAR_INFO fillChar = {{' '}, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED};
    362             ScrollConsoleScreenBuffer(stdOutHandle_, &oldRect, NULL, makeCOORD(0, statusLineRow + newLines), &fillChar);
     362            ScrollConsoleScreenBuffer(stdOutHandle_, &oldRect, nullptr, makeCOORD(0, statusLineRow + newLines), &fillChar);
    363363            // Clear potential leftovers
    364364            if (-newLines - this->statusLines_ > 0)
  • code/trunk/src/libraries/core/command/IOConsoleWindows.h

    r9676 r11071  
    6767
    6868        // Methods from ShellListener
    69         void linesChanged();
    70         void lineAdded();
    71         void inputChanged();
    72         void cursorChanged();
    73         void executed();
    74         void exit();
     69        virtual void linesChanged() override;
     70        virtual void lineAdded() override;
     71        virtual void inputChanged() override;
     72        virtual void cursorChanged() override;
     73        virtual void executed() override;
     74        virtual void exit() override;
    7575
    7676        void resetTerminalMode();
  • code/trunk/src/libraries/core/command/IRC.cc

    r10624 r11071  
    4444namespace orxonox
    4545{
    46     static const unsigned int IRC_TCL_THREADID  = 1421421421;   ///< The ID of the thread in TclThreadManager that is used for the IRC connection
     46    static constexpr unsigned int IRC_TCL_THREADID  = 1421421421;   ///< The ID of the thread in TclThreadManager that is used for the IRC connection
    4747
    4848    SetConsoleCommand("IRC", "say",  &IRC::say);
     
    6666    IRC::IRC()
    6767    {
    68         this->interpreter_ = 0;
     68        this->interpreter_ = nullptr;
    6969    }
    7070
  • code/trunk/src/libraries/core/command/IRC.h

    r7401 r11071  
    6565
    6666            IRC();
    67             IRC(const IRC& other);              ///< Copy-constructor: Not implemented
    68             ~IRC() {}                           ///< Destructor
     67            ~IRC() = default;
     68
     69            // non-copyable:
     70            IRC(const IRC&) = delete;
     71            IRC& operator=(const IRC&) = delete;
    6972
    7073            Tcl::interpreter* interpreter_;     ///< The Tcl interpreter that is used for the IRC connection
  • code/trunk/src/libraries/core/command/Shell.cc

    r10624 r11071  
    258258        vectorize(text, '\n', &lines);
    259259
    260         for (size_t i = 0; i < lines.size(); ++i)
    261             this->addLine(lines[i], type);
     260        for (const std::string& line : lines)
     261            this->addLine(line, type);
    262262    }
    263263
     
    268268    {
    269269        // yes it was - push the new line to the list
    270         this->outputLines_.push_front(std::make_pair(line, static_cast<LineType>(type)));
     270        this->outputLines_.push_front(std::make_pair(line, type));
    271271
    272272        // adjust the scroll position if needed
     
    381381        const std::string& result = CommandExecutor::query(this->inputBuffer_->get(), &error);
    382382        if (error)
    383             this->addOutput("Error: Can't execute \"" + this->inputBuffer_->get() + "\", " + CommandExecutor::getErrorDescription(error) + ". (Shell)", UserError);
     383            this->addOutput("Error: Can't execute \"" + this->inputBuffer_->get() + "\", " + CommandExecutor::getErrorDescription(error) + ". (Shell)", LineType::UserError);
    384384        else if (result != "")
    385             this->addOutput(result, Result);
     385            this->addOutput(result, LineType::Result);
    386386
    387387        this->clearInput();
     
    392392    {
    393393        this->inputBuffer_->set(CommandExecutor::evaluate(this->inputBuffer_->get()).complete());
    394         this->addOutput(CommandExecutor::evaluate(this->inputBuffer_->get()).hint(), Hint);
     394        this->addOutput(CommandExecutor::evaluate(this->inputBuffer_->get()).hint(), LineType::Hint);
    395395
    396396        this->inputChanged();
  • code/trunk/src/libraries/core/command/Shell.h

    r10624 r11071  
    6161
    6262        public:
    63             virtual ~ShellListener() {}
     63            ShellListener() = default;
     64            virtual ~ShellListener() = default;
    6465
    6566        private:
     
    8788        public:
    8889            /// Defines the type of a line of text in the Shell - some types depend on the output level, others are of internal use.
    89             enum LineType
     90            enum class LineType
    9091            {
    9192                DebugOutput     = debug_output,
     
    128129            const std::string& getInput() const;
    129130
    130             typedef std::list<std::pair<std::string, LineType> > LineList;
     131            typedef std::list<std::pair<std::string, LineType>> LineList;
    131132            LineList::const_iterator getNewestLineIterator() const;
    132133            LineList::const_iterator getEndIterator() const;
    133134
    134             void addOutput(const std::string& text, LineType type = DebugOutput);
    135             void addLine(const std::string& line, LineType type = DebugOutput);
     135            void addOutput(const std::string& text, LineType type = LineType::DebugOutput);
     136            void addLine(const std::string& line, LineType type = LineType::DebugOutput);
    136137            void clearOutput();
    137138
     
    148149
    149150        private:
    150             Shell(const Shell& other);
     151            // non-copyable:
     152            Shell(const Shell&) = delete;
     153            Shell& operator=(const Shell&) = delete;
    151154
    152155            // DevModeListener
    153             void devModeChanged(bool value);
     156            virtual void devModeChanged(bool value) override;
    154157
    155158            void addToHistory(const std::string& command);
     
    157160            void clearInput();
    158161            // BaseWriter
    159             virtual void printLine(const std::string& line, OutputLevel level);
     162            virtual void printLine(const std::string& line, OutputLevel level) override;
    160163
    161164            void configureInputBuffer();
  • code/trunk/src/libraries/core/command/TclBind.cc

    r10624 r11071  
    4747    SetConsoleCommand("bgerror", &TclBind::bgerror).hide();
    4848
    49     TclBind* TclBind::singletonPtr_s = 0;
     49    TclBind* TclBind::singletonPtr_s = nullptr;
    5050
    5151    /**
     
    5555    TclBind::TclBind(const std::string& datapath)
    5656    {
    57         this->interpreter_ = 0;
     57        this->interpreter_ = nullptr;
    5858        this->bSetTclDataPath_ = false;
    5959        this->setDataPath(datapath);
     
    228228        @brief Executes Tcl-code and returns the return-value.
    229229        @param tclcode A string that contains Tcl-code
    230         @param error A pointer to an integer (or NULL) that is used to write an error-code (see @ref CommandExecutorErrorCodes "CommandExecutor error codes")
     230        @param error A pointer to an integer (or nullptr) that is used to write an error-code (see @ref CommandExecutorErrorCodes "CommandExecutor error codes")
    231231        @return Returns the return-value of the executed code (or an empty string if there's no return-value)
    232232    */
  • code/trunk/src/libraries/core/command/TclBind.h

    r8079 r11071  
    121121            static void tcl_execute(Tcl::object const &args);
    122122
    123             static std::string eval(const std::string& tclcode, int* error = 0);
     123            static std::string eval(const std::string& tclcode, int* error = nullptr);
    124124
    125125        private:
    126             TclBind(const TclBind& other);      ///< Copy-constructor, not implemented
     126            // non-copyable:
     127            TclBind(const TclBind&) = delete;
     128            TclBind& operator=(const TclBind&) = delete;
    127129
    128130            static std::string tcl_helper(Tcl::object const &args, bool bQuery);
  • code/trunk/src/libraries/core/command/TclThreadList.h

    r7401 r11071  
    262262        boost::shared_lock<boost::shared_mutex> lock(this->mutex_);
    263263
    264         for (typename std::list<T>::const_iterator it = this->list_.begin(); it != this->list_.end(); ++it)
    265             if (*it == value)
     264        for (const T& element : this->list_)
     265            if (element == value)
    266266                return true;
    267267
  • code/trunk/src/libraries/core/command/TclThreadManager.cc

    r10624 r11071  
    3434#include "TclThreadManager.h"
    3535
    36 #include <boost/bind.hpp>
     36#include <functional>
    3737#include <boost/thread/thread.hpp>
    3838#include <boost/thread/locks.hpp>
     
    8686    };
    8787
    88     TclThreadManager* TclThreadManager::singletonPtr_s = 0;
     88    TclThreadManager* TclThreadManager::singletonPtr_s = nullptr;
    8989
    9090    /**
     
    145145            {
    146146                boost::shared_lock<boost::shared_mutex> lock(*this->interpreterBundlesMutex_);
    147                 for (std::map<unsigned int, TclInterpreterBundle*>::const_iterator it = this->interpreterBundles_.begin(); it != this->interpreterBundles_.end(); ++it)
     147                for (const auto& mapEntry : this->interpreterBundles_)
    148148                {
    149                     if (it->first == 0)
     149                    if (mapEntry.first == 0)
    150150                        continue; // We'll handle the default interpreter later (and without threads of course)
    151151
    152                     TclInterpreterBundle* bundle = it->second;
     152                    TclInterpreterBundle* bundle = mapEntry.second;
    153153                    if (!bundle->queue_.empty())
    154154                    {
     
    163163                                {
    164164                                    // Start a thread to execute the command
    165                                     boost::thread(boost::bind(&tclThread, bundle, command));
     165                                    boost::thread(std::bind(&tclThread, bundle, command));
    166166                                }
    167167                                else
     
    289289        catch (const Tcl::tcl_error& e)
    290290        {
    291             bundle->interpreter_ = 0;
     291            bundle->interpreter_ = nullptr;
    292292            orxout(user_error, context::tcl) << "Tcl error while creating Tcl-interpreter (" << id_string << "): " << e.what() << endl;
    293293        }
     
    488488    void TclThreadManager::source(const std::string& file)
    489489    {
    490         boost::thread(boost::bind(&sourceThread, file));
     490        boost::thread(std::bind(&sourceThread, file));
    491491    }
    492492
     
    521521        {
    522522            TclThreadManager::error("No Tcl-interpreter with ID " + multi_cast<std::string>(id) + " existing.");
    523             return 0;
     523            return nullptr;
    524524        }
    525525    }
     
    551551
    552552        std::list<unsigned int> threads;
    553         for (std::map<unsigned int, TclInterpreterBundle*>::const_iterator it = this->interpreterBundles_.begin(); it != this->interpreterBundles_.end(); ++it)
    554             if (it->first > 0 && it->first <= this->numInterpreterBundles_) // only list autonumbered interpreters (created with create()) - exclude the default interpreter 0 and all manually numbered interpreters)
    555                 threads.push_back(it->first);
     553        for (const auto& mapEntry : this->interpreterBundles_)
     554            if (mapEntry.first > 0 && mapEntry.first <= this->numInterpreterBundles_) // only list autonumbered interpreters (created with create()) - exclude the default interpreter 0 and all manually numbered interpreters)
     555                threads.push_back(mapEntry.first);
    556556        return threads;
    557557    }
Note: See TracChangeset for help on using the changeset viewer.