/* * Copyright (C) 2022 The V-Gears Team * * This file is part of V-Gears * * V-Gears is free software: you can redistribute it and/or modify it under * terms of the GNU General Public License as published by the Free Software * Foundation, version 3.0 (GPLv3) of the License. * * V-Gears is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ #pragma once #include #include #include #include "ConfigCmd.h" /** * A manager for configuration commands. */ class ConfigCmdManager : public Ogre::Singleton{ public: /** * Constructor. */ ConfigCmdManager(); /** * Destructor. */ ~ConfigCmdManager(); /** * Adds a command to the manager. * * @param name[in] Command name. * @param description[in] Command description. * @param params_description[in] Command parameters description. * @param handler[in] Command handler. * @param completion[in] Command completion. */ void AddCommand( const Ogre::String& name, const Ogre::String& description, const Ogre::String& params_description, ConfigCmdHandler handler, ConfigCmdCompletion completion ); /** * Executes a command. * * @param cmd_string[in] The command, in string format. */ void ExecuteString( const Ogre::String& cmd_string ); /** * Finds a command by name. * * @param name[in] Name of the command. * @return The command by the name, or nullptr if there is none. */ ConfigCmd* Find(const Ogre::String& name) const; /** * Counts the commands in the manager. * * @return The total number of commands */ int GetConfigCmdNumber(); /** * Retrieves a command by index. * * A command index is the position at which it was added to the * manager. */ ConfigCmd* GetConfigCmd(unsigned int i) const; private: /** * Forbidden copy constructor. * * @param rhs[in] Manager to not copy. */ ConfigCmdManager(const ConfigCmdManager& rhs) = delete; /** * Forbidden copy constructor. * * @param rhs[in] Manager to not copy. */ ConfigCmdManager operator =(const ConfigCmdManager& rhs) = delete; /** * Initializes the command. * * Must be called from the constructor. */ void InitCmd(); /** * List of command in the manager. */ std::vector> commands_; };