[98] | 1 | #ifndef __FIELD__ |
---|
| 2 | #define __FIELD__ |
---|
[79] | 3 | |
---|
[98] | 4 | using XMLIOSERVER::XML::XMLNode; |
---|
| 5 | using XMLIOSERVER::XML::THashAttributes; |
---|
[79] | 6 | |
---|
[98] | 7 | namespace XMLIOSERVER |
---|
[79] | 8 | { |
---|
[120] | 9 | class CGrid; // CGRID = CDOMAINE + CAXIS |
---|
[124] | 10 | class CFile; |
---|
[120] | 11 | |
---|
[106] | 12 | class CField : public ObjectTemplate<CField>, public FieldAttribut |
---|
[98] | 13 | { |
---|
| 14 | public: |
---|
[107] | 15 | |
---|
[124] | 16 | CField(void) : ObjectTemplate<CField>(), FieldAttribut(), lastStored(NULL), grid(NULL), file(NULL) |
---|
[107] | 17 | {/* Ne rien faire de plus */} |
---|
[124] | 18 | CField(const string& _id) : ObjectTemplate<CField>(_id), FieldAttribut(), lastStored(NULL), grid(NULL), file(NULL) |
---|
[107] | 19 | {/* Ne rien faire de plus */} |
---|
| 20 | |
---|
[122] | 21 | static string GetName(void) { return ("field"); } |
---|
[107] | 22 | |
---|
[124] | 23 | inline void solveGridRef(void) ; |
---|
[120] | 24 | |
---|
[122] | 25 | const CGrid* getGrid(void) const { return (grid); } |
---|
[123] | 26 | const Array<double, 1>& getData(void) const { return (data); } |
---|
[120] | 27 | |
---|
[124] | 28 | void initLastStoredDate(const Date& _newlastStored) |
---|
| 29 | { if(lastStored == NULL) lastStored = new Date(_newlastStored); }; |
---|
| 30 | |
---|
| 31 | bool isStorable(const Date& currDate) |
---|
| 32 | { |
---|
| 33 | if (lastStored == NULL) return (false); |
---|
| 34 | if (freq_op.hasValue()) |
---|
| 35 | return (currDate >= (*lastStored + (Duration)freq_op)); |
---|
| 36 | return (true); |
---|
| 37 | } |
---|
| 38 | |
---|
| 39 | void storeData(const Array<double, 1> & arr, const Date& currDate) |
---|
| 40 | { |
---|
| 41 | *lastStored = currDate; |
---|
| 42 | data.resize(shape(arr.size())) ; |
---|
| 43 | data = arr; |
---|
| 44 | } |
---|
| 45 | |
---|
| 46 | const CFile* getRelFile(void) const { return (file); } |
---|
| 47 | void setRelFile(CFile* _file) { file = _file; } |
---|
| 48 | |
---|
[108] | 49 | virtual CField* getReference(void) const |
---|
| 50 | { |
---|
[120] | 51 | if(!field_ref.hasValue()) return (NULL); |
---|
[109] | 52 | if (!CField::HasObject(field_ref)) |
---|
[123] | 53 | { WARNING("Référence invalide sur l'objet "+GetName()+" nommé \""+((string)field_ref)+"\""); return (NULL); } |
---|
[108] | 54 | |
---|
[120] | 55 | return (CField::GetObject(field_ref)); |
---|
[108] | 56 | } |
---|
| 57 | |
---|
[113] | 58 | virtual ~CField(void) |
---|
[124] | 59 | { if(lastStored != NULL) delete lastStored; } |
---|
[107] | 60 | |
---|
[120] | 61 | private : |
---|
| 62 | |
---|
[124] | 63 | Date* lastStored; |
---|
| 64 | |
---|
[120] | 65 | CGrid* grid ; |
---|
[124] | 66 | CFile* file; |
---|
[120] | 67 | |
---|
[124] | 68 | Array<double, 1> data; |
---|
| 69 | |
---|
[110] | 70 | }; // class CField |
---|
[107] | 71 | |
---|
[114] | 72 | } // namespace XMLIOSERVER |
---|
[107] | 73 | |
---|
[114] | 74 | DECLARE_GROUP(Field) |
---|
[112] | 75 | |
---|
[98] | 76 | #endif // __FIELD__ |
---|