debug_cmd.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. ** Command & Conquer Generals Zero Hour(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program 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. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /////////////////////////////////////////////////////////////////////////EA-V1
  19. // $File: //depot/GeneralsMD/Staging/code/Libraries/Source/debug/debug_cmd.h $
  20. // $Author: mhoffe $
  21. // $Revision: #1 $
  22. // $DateTime: 2003/07/03 11:55:26 $
  23. //
  24. // ©2003 Electronic Arts
  25. //
  26. // Debug command interface
  27. //////////////////////////////////////////////////////////////////////////////
  28. #ifdef _MSC_VER
  29. # pragma once
  30. #endif
  31. #ifndef DEBUG_CMD_H // Include guard
  32. #define DEBUG_CMD_H
  33. /**
  34. \interface DebugCmdInterface debug.h <rts/debug.h>
  35. \brief Debug command group interface.
  36. A debug command group interface implementation defines a new
  37. command group and the commands implemented for this group.
  38. A Debug command group interface instance must register itself
  39. using Debug::AddCommands. Ownership is then transfered to
  40. the Debug module unless the object is manually removed
  41. by calling Debug::RemoveCommands.
  42. For convenience the macro \ref DEBUG_CREATE_COMMAND_GROUP
  43. can be used as well.
  44. */
  45. class DebugCmdInterface
  46. {
  47. // no copy/assign op
  48. DebugCmdInterface(const &DebugCmdInterface);
  49. DebugCmdInterface& operator=(const DebugCmdInterface&);
  50. protected:
  51. // nobody can call this destructor (except child classes)
  52. virtual ~DebugCmdInterface() {}
  53. public:
  54. // interface only so no functionality here
  55. explicit DebugCmdInterface(void) {}
  56. /// possible command modes
  57. enum CommandMode
  58. {
  59. /// normal command mode
  60. Normal,
  61. /// structured command mode
  62. Structured,
  63. MAX
  64. };
  65. /**
  66. \brief Execute the given command.
  67. This function is called whenever a command has been issued for
  68. the command group the interface implements.
  69. \param dbg debug instance
  70. \param cmd command issued
  71. \param cmdmode command mode
  72. \param argn number of additional arguments passed in
  73. \param argv argument list
  74. \return true if command was known, false if not
  75. */
  76. virtual bool Execute(class Debug& dbg, const char *cmd, CommandMode cmdmode,
  77. unsigned argn, const char * const * argv)=0;
  78. /**
  79. \brief Destroys the current command interface.
  80. Use this function instead of just delete'ing the instance.
  81. */
  82. virtual void Delete(void)=0;
  83. };
  84. /**
  85. \addtogroup debug_cmd_macros Debug command interface helper macros
  86. These macros can be used if a command interface instance should
  87. be available right after starting the program (which is usually
  88. the case).
  89. */
  90. ///@{
  91. #ifdef DOXYGEN
  92. /**
  93. \brief Helper macro for creating and registering a command interface
  94. instance the Debug module.
  95. \param groupname name of command group this class if for
  96. (without quotes)
  97. \param type type name of class we're implementing
  98. */
  99. #define DEBUG_CREATE_COMMAND_GROUP(groupname,type)
  100. #else
  101. #define DEBUG_CREATE_COMMAND_GROUP(groupname,type) \
  102. static bool __RegisterDebugCmdGroup_##type=Debug::AddCommands(#groupname,new type);
  103. #endif
  104. ///@}
  105. #endif // DEBUG_CMD_H