00001 #ifndef FCS_STATE_WITH_LOCATIONS_MATRIX_H 00002 #define FCS_STATE_WITH_LOCATIONS_MATRIX_H 00003 00011 00017 class AFCSStateWithLocationsMatrix 00018 { 00019 public: 00021 virtual ~AFCSStateWithLocationsMatrix() {} 00022 00028 virtual FCSStateWithLocations* Get(int Dim1, int Dim2) = 0; 00029 00034 virtual void Set(int Dim1, FCSStateWithLocations* SetPtr) = 0; 00035 00039 virtual void Create(int Dim1) = 0; 00040 00044 virtual void CreateArray(int Dim1, int Size) = 0; 00045 00049 virtual void Delete(int Dim1) = 0; 00050 00054 virtual void DeleteArray(int Dim1) = 0; 00055 00062 virtual void DeleteStateWithLocationsParent(int Dim1, int Dim2) = 0; 00063 00069 virtual void ReallocSingle(int Dim1, int OldSize, int NewSize) = 0; 00070 00076 virtual void ReallocArray(int OldSize, int NewSize) = 0; 00077 }; 00078 00085 template <class ConcreteClass> 00086 class FCSStateWithLocationsMatrix : public AFCSStateWithLocationsMatrix 00087 { 00088 public: 00092 FCSStateWithLocationsMatrix(int Size); 00093 00095 virtual ~FCSStateWithLocationsMatrix(); 00096 00102 virtual FCSStateWithLocations* Get(int Dim1, int Dim2); 00103 00108 virtual void Set(int Dim1, FCSStateWithLocations* SetPtr); 00109 00113 virtual void Create(int Dim1); 00114 00118 virtual void CreateArray(int Dim1, int Size); 00119 00123 virtual void Delete(int Dim1); 00124 00128 virtual void DeleteArray(int Dim1); 00129 00136 virtual void DeleteStateWithLocationsParent(int Dim1, int Dim2); 00137 00143 virtual void ReallocSingle(int Dim1, int OldSize, int NewSize); 00144 00150 virtual void ReallocArray(int OldSize, int NewSize); 00151 00152 protected: 00153 00155 ConcreteClass** m_Array; 00156 }; 00157 00158 template <class ConcreteClass> 00159 FCSStateWithLocationsMatrix<ConcreteClass>::FCSStateWithLocationsMatrix(int Size) 00160 { 00161 m_Array = new ConcreteClass*[Size]; 00162 } 00163 00164 template <class ConcreteClass> 00165 FCSStateWithLocationsMatrix<ConcreteClass>::~FCSStateWithLocationsMatrix() 00166 { 00167 delete [] m_Array; 00168 } 00169 00170 template <class ConcreteClass> 00171 FCSStateWithLocations* FCSStateWithLocationsMatrix<ConcreteClass>::Get(int Dim1, int Dim2) 00172 { 00173 return &m_Array[Dim1][Dim2]; 00174 } 00175 00176 template <class ConcreteClass> 00177 void FCSStateWithLocationsMatrix<ConcreteClass>::Set(int Dim1, FCSStateWithLocations* SetPtr) 00178 { 00179 m_Array[Dim1] = (ConcreteClass*)SetPtr; 00180 } 00181 00182 00183 template <class ConcreteClass> 00184 void FCSStateWithLocationsMatrix<ConcreteClass>::Create(int Dim1) 00185 { 00186 m_Array[Dim1] = new ConcreteClass(); 00187 } 00188 00189 00190 template <class ConcreteClass> 00191 void FCSStateWithLocationsMatrix<ConcreteClass>::CreateArray(int Dim1, int Size) 00192 { 00193 m_Array[Dim1] = new ConcreteClass[Size]; 00194 } 00195 00196 template <class ConcreteClass> 00197 void FCSStateWithLocationsMatrix<ConcreteClass>::Delete(int Dim1) 00198 { 00199 delete m_Array[Dim1]; 00200 } 00201 00202 template <class ConcreteClass> 00203 void FCSStateWithLocationsMatrix<ConcreteClass>::DeleteArray(int Dim1) 00204 { 00205 delete [] m_Array[Dim1]; 00206 } 00207 00208 template <class ConcreteClass> 00209 void FCSStateWithLocationsMatrix<ConcreteClass>::DeleteStateWithLocationsParent(int Dim1, int Dim2) 00210 { 00211 if (m_Array[Dim1][Dim2].m_MovesToParent != NULL) 00212 delete [] m_Array[Dim1][Dim2].m_MovesToParent; 00213 } 00214 00215 template <class ConcreteClass> 00216 void FCSStateWithLocationsMatrix<ConcreteClass>::ReallocSingle(int Dim1, int OldSize, int NewSize) 00217 { 00218 Realloc<ConcreteClass>(&m_Array[Dim1], OldSize, NewSize); 00219 } 00220 00221 template <class ConcreteClass> 00222 void FCSStateWithLocationsMatrix<ConcreteClass>::ReallocArray(int OldSize, int NewSize) 00223 { 00224 Realloc<ConcreteClass*>(&m_Array, OldSize, NewSize); 00225 } 00226 00227 #endif