ConfigCmd.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*
  2. * Copyright (C) 2022 The V-Gears Team
  3. *
  4. * This file is part of V-Gears
  5. *
  6. * V-Gears is free software: you can redistribute it and/or modify it under
  7. * terms of the GNU General Public License as published by the Free Software
  8. * Foundation, version 3.0 (GPLv3) of the License.
  9. *
  10. * V-Gears is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. */
  15. #pragma once
  16. #include <OgreString.h>
  17. #include <OgreStringVector.h>
  18. class ConfigCmdManager;
  19. typedef void (*ConfigCmdHandler)(const Ogre::StringVector& params);
  20. typedef void (*ConfigCmdCompletion)(Ogre::StringVector& complete_params);
  21. /**
  22. * A configuration command.
  23. */
  24. class ConfigCmd{
  25. friend class ConfigCmdManager;
  26. public:
  27. /**
  28. * Constructor.
  29. *
  30. * It should only be created only by ConfigCmdManager.
  31. *
  32. * @param name[in] Command name.
  33. * @param description[in] Command description.
  34. * @param params_description[in] Command parameters description.
  35. * @param handler[in] Command handler.
  36. * @param completion[in] Command completion.
  37. */
  38. ConfigCmd(
  39. const Ogre::String& name, const Ogre::String& description,
  40. const Ogre::String& params_description, ConfigCmdHandler handler,
  41. ConfigCmdCompletion completion
  42. );
  43. /**
  44. * Retrieves the command name.
  45. *
  46. * @return The command name.
  47. */
  48. const Ogre::String& GetName() const;
  49. /**
  50. * Retrieves the command description.
  51. *
  52. * @return The command description.
  53. */
  54. const Ogre::String& GetDescription() const;
  55. /**
  56. * Retrieves the command parameter description.
  57. *
  58. * @return The command parameter description.
  59. */
  60. const Ogre::String& GetParamsDescription() const;
  61. /**
  62. * Retrieves the command parameter description.
  63. *
  64. * @return The command parameter description.
  65. */
  66. ConfigCmdHandler GetHandler() const;
  67. /**
  68. * Checks the command completion
  69. *
  70. * @return The command completion.
  71. */
  72. ConfigCmdCompletion GetCompletion() const;
  73. private:
  74. /**
  75. * Forbidden copy constructor.
  76. *
  77. * @param rhs[in] Command to not copy.
  78. */
  79. ConfigCmd(const ConfigCmd& rhs) = delete;
  80. /**
  81. * Forbidden copy constructor.
  82. *
  83. * @param rhs[in] Command to not copy.
  84. */
  85. ConfigCmd& operator =(const ConfigCmd& rhs) = delete;
  86. /**
  87. * The command name.
  88. */
  89. Ogre::String name_;
  90. /**
  91. * The command description.
  92. */
  93. Ogre::String description_;
  94. /**
  95. * The command parameters description.
  96. */
  97. Ogre::String params_description_;
  98. /**
  99. * The command handler.
  100. */
  101. ConfigCmdHandler handler_;
  102. /**
  103. * The command completion.
  104. */
  105. ConfigCmdCompletion completion_;
  106. };