| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- /*
- * 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 <OgreSingleton.h>
- #include <vector>
- #include <memory>
- #include "ConfigCmd.h"
- /**
- * A manager for configuration commands.
- */
- class ConfigCmdManager : public Ogre::Singleton<ConfigCmdManager>{
- 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<std::unique_ptr<ConfigCmd>> commands_;
- };
|