parameterlist.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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. /***********************************************************************************************
  19. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : WWSaveLoad *
  23. * *
  24. * $Archive:: /Commando/Code/wwsaveload/parameterlist.h $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 10/06/99 2:52p $*
  29. * *
  30. * $Revision:: 9 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #if defined(_MSC_VER)
  36. #pragma once
  37. #endif
  38. #ifndef __PARAMETER_LIST_H
  39. #define __PARAMETER_LIST_H
  40. #include "always.h"
  41. #include "vector.h"
  42. #include "parameter.h"
  43. #include "wwdebug.h"
  44. //////////////////////////////////////////////////////////////////////////////////
  45. //
  46. // ParameterListClass
  47. //
  48. //////////////////////////////////////////////////////////////////////////////////
  49. class ParameterListClass : public DynamicVectorClass<ParameterClass *>
  50. {
  51. public:
  52. /////////////////////////////////////////////////////////////////////
  53. // Public constructurs/destructors
  54. /////////////////////////////////////////////////////////////////////
  55. ~ParameterListClass (void);
  56. /////////////////////////////////////////////////////////////////////
  57. // Public methods
  58. /////////////////////////////////////////////////////////////////////
  59. void Add (void *data, const char *param_name, ParameterClass::Type type);
  60. void Add (ParameterClass *parameter);
  61. protected:
  62. /////////////////////////////////////////////////////////////////////
  63. // Protected methods
  64. /////////////////////////////////////////////////////////////////////
  65. void Free_Parameters (void);
  66. private:
  67. /////////////////////////////////////////////////////////////////////
  68. // Private member data
  69. /////////////////////////////////////////////////////////////////////
  70. //DynamicVectorClass<ParameterClass *> m_Parameters;
  71. };
  72. /////////////////////////////////////////////////////////////////////
  73. // ~ParameterListClass
  74. /////////////////////////////////////////////////////////////////////
  75. inline
  76. ParameterListClass::~ParameterListClass (void)
  77. {
  78. Free_Parameters ();
  79. return ;
  80. }
  81. /////////////////////////////////////////////////////////////////////
  82. // Add
  83. /////////////////////////////////////////////////////////////////////
  84. inline void
  85. ParameterListClass::Add (void *data, const char *param_name, ParameterClass::Type type)
  86. {
  87. //
  88. // Create a new parameter object
  89. //
  90. ParameterClass *new_param = ParameterClass::Construct (type, data, param_name);
  91. //
  92. // Add the new paramter object to our list
  93. //
  94. WWASSERT (new_param != NULL);
  95. if (new_param != NULL) {
  96. DynamicVectorClass<ParameterClass *>::Add (new_param);
  97. }
  98. return ;
  99. }
  100. /////////////////////////////////////////////////////////////////////
  101. // Add
  102. /////////////////////////////////////////////////////////////////////
  103. inline void
  104. ParameterListClass::Add (ParameterClass *new_param)
  105. {
  106. //
  107. // Add the new paramter object to our list
  108. //
  109. if (new_param != NULL) {
  110. DynamicVectorClass<ParameterClass *>::Add (new_param);
  111. }
  112. return ;
  113. }
  114. /////////////////////////////////////////////////////////////////////
  115. // Free_Parameters
  116. /////////////////////////////////////////////////////////////////////
  117. inline void
  118. ParameterListClass::Free_Parameters (void)
  119. {
  120. for (int index = 0; index < Count (); index ++) {
  121. ParameterClass *param = Vector[index];
  122. //
  123. // Free the parameter object
  124. //
  125. if (param != NULL) {
  126. delete param;
  127. }
  128. }
  129. Delete_All();
  130. // m_Parameters.Delete_All ();
  131. return ;
  132. }
  133. #endif //__PARAMETER_LIST_H