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

Last change on this file since 124 was 124, checked in by hozdoba, 14 years ago

Commit pour sauvegarde - diverses corrections de bogues et améliorations du code.

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
23         inline void solveGridRef(void) ;
24
25         const CGrid* getGrid(void) const { return (grid); }
26         const Array<double, 1>& getData(void) const { return (data); }
27
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
49         virtual CField* getReference(void) const
50         {
51            if(!field_ref.hasValue()) return (NULL);
52            if (!CField::HasObject(field_ref))
53            { WARNING("Référence invalide sur l'objet "+GetName()+" nommé \""+((string)field_ref)+"\""); return (NULL); }
54
55            return (CField::GetObject(field_ref));
56         }
57
58         virtual ~CField(void)
59         { if(lastStored !=  NULL) delete lastStored; }
60
61      private :
62
63         Date* lastStored;
64
65         CGrid* grid ;
66         CFile* file;
67
68         Array<double, 1>  data;
69
70   }; // class CField
71
72} // namespace XMLIOSERVER
73
74DECLARE_GROUP(Field)
75
76#endif // __FIELD__
Note: See TracBrowser for help on using the repository browser.