00001
00002
00003 #ifndef GridBaseH
00004 #define GridBaseH
00005
00006
00007 #include "WorkerBase.h"
00008
00049 class clGridBase : public clWorkerBase{
00050 friend class clGridManager;
00051 friend class clPackage;
00052 friend class clGridTest;
00054 protected:
00076 clGridBase(clSimManager *p_oSimManager, char *cGridName,
00077 short int iNumIntVals, short int iNumFloatVals, short int iNumCharVals,
00078 short int iNumBoolVals, float fXCellLength = 0, float fYCellLength = 0);
00079
00080
00084 ~clGridBase();
00085
00097 inline short int RegisterDataMember(char *cLabel, short int iNumVals,
00098 char **p_cLabelList);
00099
00103 struct stcRecords {
00104 int *p_iIntVals;
00105 float *p_fFloatVals;
00106 char **p_cCharVals;
00107 bool *p_bBoolVals;
00108 clPackage *p_oPackage;
00110 } **mp_gridVals;
00112 short int m_iNumIntVals;
00113 short int m_iNumFloatVals;
00114 short int m_iNumCharVals;
00115 short int m_iNumBoolVals;
00117 char **mp_cIntLabels;
00118 char **mp_cFloatLabels;
00119 char **mp_cCharLabels;
00120 char **mp_cBoolLabels;
00122 float m_fXCellSize;
00123 float m_fYCellSize;
00124 float m_fYPlotLength;
00125 float m_fXPlotLength;
00127 int m_iNumXCells;
00128 int m_iNumYCells;
00130 char m_cMapFileVersion[MAX_VERSION_SIZE];
00132 bool m_bPackageChangeAllowed;
00134 bool m_bPackageDataChanged;
00137 short int m_iNumPackageIntVals;
00138 short int m_iNumPackageFloatVals;
00139 short int m_iNumPackageCharVals;
00140 short int m_iNumPackageBoolVals;
00142 char **mp_cPackageIntLabels;
00143 char **mp_cPackageFloatLabels;
00144 char **mp_cPackageCharLabels;
00145 char **mp_cPackageBoolLabels;
00159 float GetAverageValue(float fX, float fY, short int iCode, float fRadius,
00160 bool bFloat);
00161
00175 float GetAverageValue(float fFromX, float fFromY, float fToX, float fToY,
00176 short int iCode, bool bFloat);
00177
00178 public:
00179
00184 int GetObjectVersion() {return 1;};
00185
00190 void GetData(xercesc::DOMDocument *p_oDoc);
00191
00209 void ReadMapFile(xercesc::DOMDocument *p_oDoc);
00210
00224 void ChangePackageDataStructure(short int iNumIntVals, short int iNumFloatVals,
00225 short int iNumCharVals, short int iNumBoolVals);
00226
00241 void GetValueAtPoint(float fX, float fY, short int iCode, int *p_iValHolder);
00242
00257 void GetValueAtPoint(float fX, float fY, short int iCode,float *p_fValHolder);
00258
00273 void GetValueAtPoint(float fX, float fY, short int iCode, char *p_cValHolder);
00274
00289 void GetValueAtPoint(float fX, float fY, short int iCode, bool *p_bValHolder);
00290
00305 void GetValueOfCell(int iX, int iY, short int iCode, int *p_iValHolder);
00306
00321 void GetValueOfCell(int iX, int iY, short int iCode, float *p_fValHolder);
00322
00337 void GetValueOfCell(int iX, int iY, short int iCode, char *p_cValHolder);
00338
00353 void GetValueOfCell(int iX, int iY, short int iCode, bool *p_bValHolder);
00354
00370 float GetAverageFloatValue(float fX, float fY, short int iCode,float fRadius);
00371
00387 float GetAverageIntValue(float fX, float fY, short int iCode, float fRadius);
00388
00405 float GetAverageFloatValue(float fFromX, float fFromY, float fToX, float fToY, short int iCode);
00406
00423 float GetAverageIntValue(float fFromX, float fFromY, float fToX, float fToY, short int iCode);
00424
00433 float GetOriginXOfCell(int iX);
00434
00443 float GetOriginYOfCell(int iY);
00444
00454 float GetEndXOfCell(int iX);
00455
00465 float GetEndYOfCell(int iY);
00466
00475 clPackage* GetFirstPackageOfCell(int iX, int iY);
00476
00485 clPackage* GetFirstPackageAtPoint(float fX, float fY);
00486
00494 void GetPointOfCell(short int iCellX, short int iCellY, float *fX, float *fY);
00495
00503 void GetCellOfPoint(float fX, float fY, short int *iCellX, short int *iCellY);
00504
00509 int GetNumberXCells() {return m_iNumXCells;};
00510
00515 int GetNumberYCells() {return m_iNumYCells;};
00516
00521 float GetLengthXCells() {return m_fXCellSize;};
00522
00527 float GetLengthYCells() {return m_fYCellSize;};
00528
00533 int GetNumberIntDataMembers() {return m_iNumIntVals;};
00534
00539 int GetNumberFloatDataMembers() {return m_iNumFloatVals;};
00540
00545 int GetNumberCharDataMembers() {return m_iNumCharVals;};
00546
00551 int GetNumberBoolDataMembers() {return m_iNumBoolVals;};
00552
00557 int GetNumberIntPackageDataMembers() {return m_iNumPackageIntVals;};
00558
00563 int GetNumberFloatPackageDataMembers() {return m_iNumPackageFloatVals;};
00564
00569 int GetNumberCharPackageDataMembers() {return m_iNumPackageCharVals;};
00570
00575 int GetNumberBoolPackageDataMembers() {return m_iNumPackageBoolVals;};
00576
00582 bool GetPackageDataChanged() {return m_bPackageDataChanged;};
00583
00597 void SetValueAtPoint(float fX, float fY, short int iCode, float fValue);
00598
00612 void SetValueAtPoint(float fX, float fY, short int iCode, int iValue);
00613
00627 void SetValueAtPoint(float fX, float fY, short int iCode, char *p_cValue);
00628
00642 void SetValueAtPoint(float fX, float fY, short int iCode, bool bValue);
00643
00658 void SetValueOfCell(int iX, int iY, short int iCode, float fValue);
00659
00674 void SetValueOfCell(int iX, int iY, short int iCode, int iValue);
00675
00690 void SetValueOfCell(int iX, int iY, short int iCode, char *p_cValue);
00691
00706 void SetValueOfCell(int iX, int iY, short int iCode, bool bValue);
00707
00718 short int RegisterInt(char *cLabel);
00719
00730 short int RegisterFloat(char *cLabel);
00731
00742 short int RegisterChar(char *cLabel);
00743
00754 short int RegisterBool(char *cLabel);
00755
00768 short int RegisterPackageInt(char *cLabel);
00769
00782 short int RegisterPackageFloat(char *cLabel);
00783
00796 short int RegisterPackageChar(char *cLabel);
00797
00810 short int RegisterPackageBool(char *cLabel);
00811
00812
00813
00814
00815
00816
00825 clPackage* CreatePackage(clPackage *p_oPreviousPackage);
00826
00836 clPackage* CreatePackageOfCell(int iX, int iY);
00837
00847 clPackage* CreatePackageAtPoint(float fX, float fY);
00848
00855 void DeletePackage(clPackage *p_oOldPackage);
00856
00864 short int GetIntDataCode(char *cLabel);
00865
00873 short int GetFloatDataCode(char *cLabel);
00874
00882 short int GetCharDataCode(char *cLabel);
00883
00891 short int GetBoolDataCode(char *cLabel);
00892
00900 short int GetPackageIntDataCode(char *cLabel);
00901
00909 short int GetPackageFloatDataCode(char *cLabel);
00910
00918 short int GetPackageCharDataCode(char *cLabel);
00919
00927 short int GetPackageBoolDataCode(char *cLabel);
00928
00937 char* GetIntDataLabel(short int iCode);
00938
00947 char* GetFloatDataLabel(short int iCode);
00948
00957 char* GetCharDataLabel(short int iCode);
00958
00967 char* GetBoolDataLabel(short int iCode);
00968
00977 char* GetPackageIntDataLabel(short int iCode);
00978
00987 char* GetPackageFloatDataLabel(short int iCode);
00988
00997 char* GetPackageCharDataLabel(short int iCode);
00998
01007 char* GetPackageBoolDataLabel(short int iCode);
01008
01009 };
01010
01011 struct clGridBase::stcRecords;
01012
01019 class clPackage {
01020
01021 friend class clGridBase;
01022 friend class clGridTest;
01023 public:
01024
01031 clPackage* GetNextPackage() {return mp_oNext;};
01032
01039 void SetValue(short int iCode, int iValue);
01040
01047 void SetValue(short int iCode, float fValue);
01048
01055 void SetValue(short int iCode, bool bValue);
01056
01063 void SetValue(short int iCode, char *cValue);
01064
01065
01066
01074 void GetValue(short int iCode, int *p_iValHolder);
01075
01083 void GetValue(short int iCode, float *p_fValHolder);
01084
01092 void GetValue(short int iCode, bool *p_bValHolder);
01093
01101 void GetValue(short int iCode, char *p_cValHolder);
01102
01103 protected:
01111 clPackage(clGridBase *p_oParentGrid, struct clGridBase::stcRecords *p_oParentCell);
01112
01116 ~clPackage();
01117
01118 clGridBase *mp_oParentGrid;
01119 clGridBase::stcRecords *mp_parentCell;
01121 int *mp_iIntVals;
01122 float *mp_fFloatVals;
01123 char **mp_cCharVals;
01124 bool *mp_bBoolVals;
01126 clPackage *mp_oNext;
01127 };
01128
01129 #endif
01130