source: XIOS/trunk/src/node/field.hpp @ 436

Last change on this file since 436 was 436, checked in by ymipsl, 11 years ago

bug fix :

  • freq_op is now by default of 1 timestep (1ts)
  • once operation is now working as required

YM

File size: 4.9 KB
Line 
1#ifndef __XMLIO_CField__
2#define __XMLIO_CField__
3
4/// xios headers ///
5#include "xmlioserver_spl.hpp"
6#include "group_factory.hpp"
7#include "functor.hpp"
8#include "functor_type.hpp"
9#include "duration.hpp"
10#include "date.hpp"
11#include "declare_group.hpp"
12#include "calendar_util.hpp"
13#include "array_new.hpp"
14#include "attribute_array.hpp"
15//#include "context.hpp"
16
17
18namespace xios {
19   
20   /// ////////////////////// Déclarations ////////////////////// ///
21
22   class CFieldGroup;
23   class CFieldAttributes;
24   class CField;
25
26   class CFile;
27   class CGrid;
28   class CContext ;
29   ///--------------------------------------------------------------
30
31   // Declare/Define CFieldAttribute
32   BEGIN_DECLARE_ATTRIBUTE_MAP(CField)
33#  include "field_attribute.conf"
34   END_DECLARE_ATTRIBUTE_MAP(CField)
35
36   ///--------------------------------------------------------------
37   class CField
38      : public CObjectTemplate<CField>
39      , public CFieldAttributes
40   {
41         /// friend ///
42         friend class CFile;
43
44         /// typedef ///
45         typedef CObjectTemplate<CField>   SuperClass;
46         typedef CFieldAttributes SuperClassAttribute;
47
48      public :
49
50         typedef CFieldAttributes RelAttributes;
51         typedef CFieldGroup      RelGroup;
52
53         enum EEventId
54         {
55           EVENT_ID_UPDATE_DATA
56         } ;
57         
58         /// Constructeurs ///
59         CField(void);
60         explicit CField(const StdString & id);
61         CField(const CField & field);       // Not implemented yet.
62         CField(const CField * const field); // Not implemented yet.
63
64         /// Accesseurs ///
65         CField* getDirectFieldReference(void) const;
66         CField* getBaseFieldReference(void)   const;
67         const std::vector<CField*> & getAllReference(void) const;
68
69         CGrid* getRelGrid(void) const ;
70         CFile* getRelFile(void) const ;
71
72      public :
73
74         StdSize getNStep(void) const;
75
76         const CDuration & getFreqOperation(void) const;
77         const CDuration & getFreqWrite(void) const;
78
79         boost::shared_ptr<CDate> getLastWriteDate(void) const;
80         boost::shared_ptr<CDate> getLastOperationDate(void) const;
81
82         boost::shared_ptr<func::CFunctor> getFieldOperation(void) const;
83         
84         CArray<double, 1> getData(void) const;
85
86         const StdString & getBaseFieldId(void) const;
87
88         /// Mutateur ///
89         void setRelFile(CFile* _file);
90         void incrementNStep(void);
91         void resetNStep() ;
92
93         template <int N> bool updateData(const CArray<double, N>&   data);
94         
95         bool updateDataServer
96               (const CDate & currDate,
97                const std::deque< CArray<double, 1>* > storedClient);
98 
99       public :
100
101         /// Test ///
102         bool hasDirectFieldReference(void) const;
103         bool isActive(void) const;
104
105         /// Traitements ///
106         void solveRefInheritance(void);
107         void solveGridReference(void);
108         void solveOperation(void);
109
110//         virtual void fromBinary(StdIStream & is);
111
112         /// Destructeur ///
113         virtual ~CField(void);
114
115         /// Accesseurs statiques ///
116         static StdString GetName(void);
117         static StdString GetDefName(void);
118         
119         static ENodeType GetType(void);
120         
121        template <int N> void setData(const CArray<double, N>& _data) ;
122        static bool dispatchEvent(CEventServer& event) ;
123        void sendUpdateData(void) ;
124        static void recvUpdateData(CEventServer& event) ;
125        void recvUpdateData(vector<int>& ranks, vector<CBufferIn*>& buffers) ;
126        void writeField(void) ;
127        void outputField(CArray<double,3>& fieldOut) ;
128        void outputField(CArray<double,2>& fieldOut) ;
129       
130      public :
131
132         /// Propriétés privées ///
133         
134         std::vector<CField*> refObject;
135         CField* baseRefObject;
136         CGrid*  grid ;
137         CFile*  file;
138
139         CDuration freq_operation, freq_write;
140         CDuration freq_operation_srv, freq_write_srv;
141
142         StdSize nstep;
143         boost::shared_ptr<CDate>    last_Write, last_operation;
144         boost::shared_ptr<CDate>    lastlast_Write_srv,last_Write_srv, last_operation_srv;
145         
146         boost::shared_ptr<func::CFunctor> foperation;
147         map<int,boost::shared_ptr<func::CFunctor> > foperation_srv;
148         
149         CArray<double, 1> data;
150         map<int, CArray<double,1>* > data_srv ;
151         bool isOnceOperation ;
152         bool isFirstOperation ;
153
154   }; // class CField
155
156   ///--------------------------------------------------------------
157
158   // Declare/Define CFieldGroup and CFieldDefinition
159   DECLARE_GROUP(CField);
160
161   ///-----------------------------------------------------------------
162
163   template <>
164      void CGroupTemplate<CField, CFieldGroup, CFieldAttributes>::solveRefInheritance(void);
165
166   ///-----------------------------------------------------------------
167} // namespace xios
168
169
170#endif // __XMLIO_CField__
Note: See TracBrowser for help on using the repository browser.