definition.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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/definition.h $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 8/24/01 4:57p $*
  29. * *
  30. * $Revision:: 20 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #if defined(_MSC_VER)
  36. #pragma once
  37. #endif
  38. #ifndef __DEFINITION_H
  39. #define __DEFINITION_H
  40. #include "always.h"
  41. // SKB Remove because of G conflicts with CLASSID_??
  42. #include "definitionclassids.h"
  43. #include "definitionmgr.h"
  44. #include "editable.h"
  45. #include "wwstring.h"
  46. // Forward declarations
  47. class ChunkSaveClass;
  48. class ChunkLoadClass;
  49. //////////////////////////////////////////////////////////////////////////////////
  50. //
  51. // DefinitionClass
  52. //
  53. //////////////////////////////////////////////////////////////////////////////////
  54. class DefinitionClass : public PersistClass, public EditableClass
  55. {
  56. public:
  57. /////////////////////////////////////////////////////////////////////
  58. // Editable interface requirements
  59. /////////////////////////////////////////////////////////////////////
  60. DECLARE_EDITABLE(DefinitionClass, EditableClass);
  61. /////////////////////////////////////////////////////////////////////
  62. // Public constructors/destructors
  63. /////////////////////////////////////////////////////////////////////
  64. DefinitionClass (void);
  65. virtual ~DefinitionClass (void);
  66. /////////////////////////////////////////////////////////////////////
  67. // Public methods
  68. /////////////////////////////////////////////////////////////////////
  69. // Type identification
  70. virtual uint32 Get_Class_ID (void) const = 0;
  71. virtual uint32 Get_ID (void) const;
  72. virtual void Set_ID (uint32 id);
  73. virtual PersistClass * Create (void) const = 0;
  74. // Display name methods
  75. virtual const char * Get_Name (void) const;
  76. virtual void Set_Name (const char *new_name);
  77. // Validation methods
  78. virtual bool Is_Valid_Config (StringClass &message);
  79. // From PersistClass
  80. virtual bool Save (ChunkSaveClass &csave);
  81. virtual bool Load (ChunkLoadClass &cload);
  82. // User data support
  83. uint32 Get_User_Data (void) const { return m_GenericUserData; }
  84. void Set_User_Data (uint32 data) { m_GenericUserData = data; }
  85. // Save support
  86. bool Is_Save_Enabled (void) const { return m_SaveEnabled; }
  87. void Enable_Save (bool onoff) { m_SaveEnabled = onoff; }
  88. protected:
  89. /////////////////////////////////////////////////////////////////////
  90. // Protected member data
  91. /////////////////////////////////////////////////////////////////////
  92. int m_DefinitionMgrLink;
  93. private:
  94. /////////////////////////////////////////////////////////////////////
  95. // Private methods
  96. /////////////////////////////////////////////////////////////////////
  97. bool Save_Variables (ChunkSaveClass &csave);
  98. bool Load_Variables (ChunkLoadClass &cload);
  99. /////////////////////////////////////////////////////////////////////
  100. // Private member data
  101. /////////////////////////////////////////////////////////////////////
  102. StringClass m_Name;
  103. uint32 m_ID;
  104. uint32 m_GenericUserData;
  105. bool m_SaveEnabled;
  106. /////////////////////////////////////////////////////////////////////
  107. // Friends
  108. /////////////////////////////////////////////////////////////////////
  109. friend class DefinitionMgrClass;
  110. };
  111. /////////////////////////////////////////////////////////////////////
  112. // DefinitionClass
  113. /////////////////////////////////////////////////////////////////////
  114. inline
  115. DefinitionClass::DefinitionClass (void)
  116. : m_ID (0),
  117. m_SaveEnabled (true),
  118. m_DefinitionMgrLink (-1)
  119. {
  120. return ;
  121. }
  122. /////////////////////////////////////////////////////////////////////
  123. // DefinitionClass
  124. /////////////////////////////////////////////////////////////////////
  125. inline
  126. DefinitionClass::~DefinitionClass (void)
  127. {
  128. return ;
  129. }
  130. //////////////////////////////////////////////////////////////////////////////////
  131. // Get_Name
  132. //////////////////////////////////////////////////////////////////////////////////
  133. inline const char *
  134. DefinitionClass::Get_Name (void) const
  135. {
  136. return m_Name;
  137. }
  138. //////////////////////////////////////////////////////////////////////////////////
  139. // Set_Name
  140. //////////////////////////////////////////////////////////////////////////////////
  141. inline void
  142. DefinitionClass::Set_Name (const char *new_name)
  143. {
  144. m_Name = new_name;
  145. return ;
  146. }
  147. //////////////////////////////////////////////////////////////////////////////////
  148. // Get_ID
  149. //////////////////////////////////////////////////////////////////////////////////
  150. inline uint32
  151. DefinitionClass::Get_ID (void) const
  152. {
  153. return m_ID;
  154. }
  155. //////////////////////////////////////////////////////////////////////////////////
  156. // Is_Valid_Config
  157. //////////////////////////////////////////////////////////////////////////////////
  158. inline bool
  159. DefinitionClass::Is_Valid_Config (StringClass &message)
  160. {
  161. return true;
  162. }
  163. #endif //__DEFINITION_H