1 |
tim |
658 |
#ifndef __GENERICDATA_H__ |
2 |
|
|
#define __GENERICDATA_H__ |
3 |
|
|
|
4 |
|
|
#include <string> |
5 |
|
|
#include <vector> |
6 |
|
|
|
7 |
|
|
using namespace std; |
8 |
|
|
|
9 |
|
|
class GenericData |
10 |
|
|
{ |
11 |
|
|
public: |
12 |
|
|
GenericData(); |
13 |
|
|
GenericData(const GenericData& rhs) { id = rhs.getID(); } |
14 |
|
|
GenericData& operator =(const GenericData& rhs); |
15 |
|
|
virtual ~GenericData() {} |
16 |
|
|
|
17 |
|
|
const string& getID() const { return id; } |
18 |
|
|
void setID(string rhs) { id = rhs; } |
19 |
|
|
|
20 |
|
|
protected: |
21 |
|
|
string id; |
22 |
|
|
}; |
23 |
|
|
|
24 |
|
|
/** Something we can improve it here is to use template |
25 |
|
|
** |
26 |
|
|
*/ |
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 |
|
|
|
40 |
|
|
class DoubleData : public GenericData{ |
41 |
|
|
|
42 |
|
|
public: |
43 |
|
|
|
44 |
|
|
double getData() { return data; } |
45 |
|
|
void setData(double rhs) { data = rhs; } |
46 |
|
|
|
47 |
|
|
protected: |
48 |
|
|
double data; |
49 |
|
|
}; |
50 |
|
|
|
51 |
|
|
class StringData : public GenericData{ |
52 |
|
|
|
53 |
|
|
public: |
54 |
|
|
const string& getData() const { return data; } |
55 |
|
|
void setData(const string& rhs) { data = rhs; } |
56 |
|
|
protected: |
57 |
|
|
string data; |
58 |
|
|
}; |
59 |
|
|
#endif |