| 1 |
|
#ifndef __GENERICDATA_H__ |
| 2 |
|
#define __GENERICDATA_H__ |
| 3 |
|
|
| 4 |
+ |
#include <algorithm> |
| 5 |
|
#include <string> |
| 6 |
|
#include <vector> |
| 7 |
|
|
| 8 |
+ |
#define ZCONSTIME_ID "ZCONSTIME" |
| 9 |
+ |
#define ZCONSPARADATA_ID "ZCONSPARA" |
| 10 |
+ |
#define ZCONSFILENAME_ID "ZCONSFILENAME" |
| 11 |
+ |
#define ZCONSTOL_ID "ZCONSTOL" |
| 12 |
+ |
#define ZCONSFORCEPOLICY_ID "ZCONSFORCEPOLICY" |
| 13 |
+ |
|
| 14 |
+ |
#define CHIVALUE_ID "CHIVALUE" |
| 15 |
+ |
#define INTEGRALOFCHIDT_ID "INTEGRALOFCHIDT" |
| 16 |
+ |
#define ETAVALUE_ID "ETAVALUE" |
| 17 |
+ |
|
| 18 |
|
using namespace std; |
| 19 |
|
|
| 20 |
|
class GenericData |
| 24 |
|
GenericData(const GenericData& rhs) { id = rhs.getID(); } |
| 25 |
|
GenericData& operator =(const GenericData& rhs); |
| 26 |
|
virtual ~GenericData() {} |
| 27 |
< |
|
| 27 |
> |
|
| 28 |
|
const string& getID() const { return id; } |
| 29 |
< |
void setID(string rhs) { id = rhs; } |
| 30 |
< |
|
| 29 |
> |
void setID(string rhs) { id = rhs; } |
| 30 |
> |
|
| 31 |
|
protected: |
| 32 |
|
string id; |
| 33 |
|
}; |
| 34 |
|
|
| 35 |
|
/** Something we can improve it here is to use template |
| 36 |
< |
** |
| 36 |
> |
** |
| 37 |
|
*/ |
| 27 |
– |
class IndexData : public GenericData |
| 28 |
– |
{ |
| 29 |
– |
public: |
| 30 |
– |
IndexData(); |
| 31 |
– |
IndexData(const IndexData& rhs); |
| 32 |
– |
IndexData& operator = (const IndexData& rhs); |
| 33 |
– |
|
| 34 |
– |
const vector<int>& getIndexData() const { return indexData; } |
| 35 |
– |
void setIndexData(const vector<int>& rhs) { indexData = rhs; } |
| 36 |
– |
protected: |
| 37 |
– |
vector<int> indexData; |
| 38 |
– |
}; |
| 39 |
– |
|
| 38 |
|
class DoubleData : public GenericData{ |
| 39 |
|
|
| 40 |
|
public: |
| 41 |
|
|
| 42 |
|
double getData() { return data; } |
| 43 |
|
void setData(double rhs) { data = rhs; } |
| 44 |
< |
|
| 44 |
> |
|
| 45 |
|
protected: |
| 46 |
|
double data; |
| 47 |
|
}; |
| 48 |
|
|
| 49 |
|
class StringData : public GenericData{ |
| 50 |
< |
|
| 51 |
< |
public: |
| 50 |
> |
|
| 51 |
> |
public: |
| 52 |
|
const string& getData() const { return data; } |
| 53 |
|
void setData(const string& rhs) { data = rhs; } |
| 54 |
|
protected: |
| 55 |
< |
string data; |
| 55 |
> |
string data; |
| 56 |
|
}; |
| 57 |
+ |
|
| 58 |
+ |
struct ZConsParaItem { |
| 59 |
+ |
int zconsIndex; |
| 60 |
+ |
bool havingZPos; |
| 61 |
+ |
double zPos; |
| 62 |
+ |
double kRatio; |
| 63 |
+ |
}; |
| 64 |
+ |
|
| 65 |
+ |
class ZConsParaData : public GenericData{ |
| 66 |
+ |
|
| 67 |
+ |
public: |
| 68 |
+ |
ZConsParaData(); |
| 69 |
+ |
void addItem(ZConsParaItem& item) {data.push_back(item);} |
| 70 |
+ |
vector<ZConsParaItem>* getData() {return &data;} |
| 71 |
+ |
void setData(vector<ZConsParaItem>& theData) {data = theData;} |
| 72 |
+ |
void sortByIndex(); |
| 73 |
+ |
bool isIndexUnique(); |
| 74 |
+ |
|
| 75 |
+ |
private: |
| 76 |
+ |
vector<ZConsParaItem> data; |
| 77 |
+ |
}; |
| 78 |
+ |
|
| 79 |
+ |
class ZConsParaSortCriterion{ |
| 80 |
+ |
public: |
| 81 |
+ |
bool operator ()(const ZConsParaItem& item1, const ZConsParaItem& item2){ |
| 82 |
+ |
return item1.zconsIndex < item2.zconsIndex; |
| 83 |
+ |
} |
| 84 |
+ |
|
| 85 |
+ |
}; |
| 86 |
+ |
|
| 87 |
+ |
class DoubleArrayData : public GenericData{ |
| 88 |
+ |
|
| 89 |
+ |
public: |
| 90 |
+ |
vector<double> getData() const { return data; } |
| 91 |
+ |
void setData(double* source, int num){ |
| 92 |
+ |
data.clear(); |
| 93 |
+ |
for(int i = 0; i < num; i++) |
| 94 |
+ |
data.push_back(source[i]); |
| 95 |
+ |
} |
| 96 |
+ |
protected: |
| 97 |
+ |
vector<double> data; |
| 98 |
+ |
}; |
| 99 |
|
#endif |