source: XMLIO_V2/dev/dev_rv/src/XMLIO/field.hpp @ 125

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