| 1 | tim | 658 | #ifndef __GENERICDATA_H__ | 
| 2 |  |  | #define __GENERICDATA_H__ | 
| 3 |  |  |  | 
| 4 | tim | 682 | #include <algorithm> | 
| 5 | tim | 658 | #include <string> | 
| 6 |  |  | #include <vector> | 
| 7 |  |  |  | 
| 8 | tim | 682 | #define ZCONSTIME_ID            "ZCONSTIME" | 
| 9 |  |  | #define ZCONSPARADATA_ID    "ZCONSPARA" | 
| 10 |  |  | #define ZCONSFILENAME_ID     "ZCONSFILENAME" | 
| 11 |  |  | #define ZCONSTOL_ID              "ZCONSTOL" | 
| 12 | tim | 699 | #define ZCONSFORCEPOLICY_ID "ZCONSFORCEPOLICY" | 
| 13 | tim | 1091 | #define ZCONSGAP_ID "ZCONSGAP" | 
| 14 |  |  | #define ZCONSFIXTIME_ID "ZCONSFIXTIME" | 
| 15 | tim | 1093 | #define ZCONSUSINGSMD_ID "ZCONSUSINGSMD" | 
| 16 | tim | 682 |  | 
| 17 | tim | 837 | #define CHIVALUE_ID "CHIVALUE" | 
| 18 |  |  | #define INTEGRALOFCHIDT_ID "INTEGRALOFCHIDT" | 
| 19 |  |  | #define ETAVALUE_ID "ETAVALUE" | 
| 20 |  |  |  | 
| 21 | tim | 658 | using namespace std; | 
| 22 | tim | 1234 | //////////////////////////////////////////////////////////////////////////////// | 
| 23 |  |  | //Declaration of GenericData | 
| 24 |  |  | //////////////////////////////////////////////////////////////////////////////// | 
| 25 | tim | 658 | class GenericData | 
| 26 |  |  | { | 
| 27 |  |  | public: | 
| 28 |  |  | GenericData(); | 
| 29 |  |  | GenericData(const GenericData& rhs)  {  id = rhs.getID(); } | 
| 30 |  |  | GenericData& operator =(const GenericData& rhs); | 
| 31 |  |  | virtual ~GenericData() {} | 
| 32 | tim | 837 |  | 
| 33 | tim | 658 | const string& getID() const {  return id; } | 
| 34 | tim | 1234 | void setID(const string& rhs)     {  id = rhs;  } | 
| 35 | tim | 837 |  | 
| 36 | tim | 658 | protected: | 
| 37 |  |  | string id; | 
| 38 |  |  | }; | 
| 39 |  |  |  | 
| 40 | tim | 1234 | /** | 
| 41 |  |  | * Something we can improve it here is to use template | 
| 42 | tim | 658 | */ | 
| 43 | tim | 1234 | //////////////////////////////////////////////////////////////////////////////// | 
| 44 |  |  | //Declaration of IntData | 
| 45 |  |  | //////////////////////////////////////////////////////////////////////////////// | 
| 46 | tim | 1093 | class IntData : public GenericData{ | 
| 47 |  |  |  | 
| 48 |  |  | public: | 
| 49 |  |  |  | 
| 50 |  |  | double getData()         { return data; } | 
| 51 |  |  | void setData(int rhs) { data = rhs;  } | 
| 52 |  |  |  | 
| 53 |  |  | protected: | 
| 54 |  |  | int data; | 
| 55 |  |  | }; | 
| 56 |  |  |  | 
| 57 | tim | 1234 | //////////////////////////////////////////////////////////////////////////////// | 
| 58 |  |  | //Declaration of DoubleData | 
| 59 |  |  | //////////////////////////////////////////////////////////////////////////////// | 
| 60 | tim | 658 | class DoubleData : public GenericData{ | 
| 61 |  |  |  | 
| 62 |  |  | public: | 
| 63 |  |  |  | 
| 64 |  |  | double getData()         { return data; } | 
| 65 |  |  | void setData(double rhs) { data = rhs;  } | 
| 66 | tim | 837 |  | 
| 67 | tim | 658 | protected: | 
| 68 |  |  | double data; | 
| 69 |  |  | }; | 
| 70 |  |  |  | 
| 71 | tim | 1234 | //////////////////////////////////////////////////////////////////////////////// | 
| 72 |  |  | //Declaration of StringData | 
| 73 |  |  | //////////////////////////////////////////////////////////////////////////////// | 
| 74 | tim | 658 | class StringData : public GenericData{ | 
| 75 | tim | 837 |  | 
| 76 |  |  | public: | 
| 77 | tim | 658 | const string& getData() const  {  return data; } | 
| 78 |  |  | void setData(const string& rhs) {  data = rhs;  } | 
| 79 |  |  | protected: | 
| 80 | tim | 837 | string data; | 
| 81 | tim | 658 | }; | 
| 82 | tim | 682 |  | 
| 83 | tim | 1234 | //////////////////////////////////////////////////////////////////////////////// | 
| 84 |  |  | //Declaration of BoolData | 
| 85 |  |  | //////////////////////////////////////////////////////////////////////////////// | 
| 86 |  |  | class BoolData : public GenericData{ | 
| 87 |  |  | public: | 
| 88 |  |  | bool getData() const  {  return data; } | 
| 89 |  |  | void setData(const bool rhs) {  data = rhs;  } | 
| 90 |  |  | protected: | 
| 91 |  |  | bool data; | 
| 92 |  |  |  | 
| 93 |  |  | }; | 
| 94 |  |  |  | 
| 95 |  |  | //////////////////////////////////////////////////////////////////////////////// | 
| 96 |  |  | //Declaration of ZConsParaData | 
| 97 |  |  | //////////////////////////////////////////////////////////////////////////////// | 
| 98 | mmeineke | 789 | struct ZConsParaItem { | 
| 99 | tim | 682 | int zconsIndex; | 
| 100 |  |  | bool havingZPos; | 
| 101 |  |  | double zPos; | 
| 102 |  |  | double kRatio; | 
| 103 | tim | 1093 | bool havingCantVel; | 
| 104 |  |  | double cantVel; | 
| 105 | tim | 682 | }; | 
| 106 |  |  |  | 
| 107 |  |  | class ZConsParaData : public GenericData{ | 
| 108 | tim | 837 |  | 
| 109 |  |  | public: | 
| 110 | tim | 682 | ZConsParaData(); | 
| 111 |  |  | void addItem(ZConsParaItem& item) {data.push_back(item);} | 
| 112 |  |  | vector<ZConsParaItem>* getData() {return &data;} | 
| 113 |  |  | void setData(vector<ZConsParaItem>& theData) {data = theData;} | 
| 114 |  |  | void sortByIndex(); | 
| 115 | tim | 736 | bool isIndexUnique(); | 
| 116 | tim | 837 |  | 
| 117 |  |  | private: | 
| 118 | tim | 682 | vector<ZConsParaItem> data; | 
| 119 |  |  | }; | 
| 120 |  |  |  | 
| 121 |  |  | class ZConsParaSortCriterion{ | 
| 122 |  |  | public: | 
| 123 |  |  | bool operator ()(const ZConsParaItem& item1, const ZConsParaItem& item2){ | 
| 124 |  |  | return item1.zconsIndex < item2.zconsIndex; | 
| 125 |  |  | } | 
| 126 |  |  |  | 
| 127 |  |  | }; | 
| 128 |  |  |  | 
| 129 | tim | 1234 | //////////////////////////////////////////////////////////////////////////////// | 
| 130 |  |  | //Declaration of IntData | 
| 131 |  |  | //////////////////////////////////////////////////////////////////////////////// | 
| 132 | tim | 837 | class DoubleArrayData : public GenericData{ | 
| 133 |  |  |  | 
| 134 |  |  | public: | 
| 135 |  |  | vector<double> getData() const  {  return data; } | 
| 136 |  |  | void setData(double* source, int num){ | 
| 137 |  |  | data.clear(); | 
| 138 |  |  | for(int i = 0; i < num; i++) | 
| 139 |  |  | data.push_back(source[i]); | 
| 140 |  |  | } | 
| 141 |  |  | protected: | 
| 142 |  |  | vector<double> data; | 
| 143 |  |  | }; | 
| 144 | tim | 1118 |  | 
| 145 | tim | 1234 | //////////////////////////////////////////////////////////////////////////////// | 
| 146 |  |  | //Declaration of AtomData | 
| 147 |  |  | //////////////////////////////////////////////////////////////////////////////// | 
| 148 | tim | 1118 | struct AtomInfo : public GenericData{ | 
| 149 |  |  | public: | 
| 150 |  |  | string AtomType; | 
| 151 |  |  | double pos[3]; | 
| 152 |  |  | double dipole[3]; | 
| 153 |  |  | }; | 
| 154 |  |  |  | 
| 155 |  |  | class AtomData : public GenericData{ | 
| 156 |  |  | public: | 
| 157 |  |  | ~AtomData(); | 
| 158 |  |  | void addAtomInfo(AtomInfo* info) {data.push_back(info);} | 
| 159 |  |  | void clearAllAtomInfo(); | 
| 160 |  |  | AtomInfo* beginAtomInfo(vector<AtomInfo*>::iterator& i){ | 
| 161 |  |  | i = data.begin(); | 
| 162 |  |  | return i != data.end()? *i : NULL; | 
| 163 |  |  | } | 
| 164 |  |  | AtomInfo* nextAtomInfo(vector<AtomInfo*>::iterator& i){ | 
| 165 | tim | 1126 | ++i; | 
| 166 | tim | 1118 | return i != data.end()? *i: NULL; | 
| 167 |  |  | } | 
| 168 |  |  | vector<AtomInfo*> getData() {return data;} | 
| 169 |  |  | int getSize() {return data.size();} | 
| 170 |  |  | protected: | 
| 171 |  |  | vector<AtomInfo*> data; | 
| 172 |  |  | }; | 
| 173 |  |  |  | 
| 174 | tim | 658 | #endif |