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

Last change on this file since 562 was 540, checked in by mhnguyen, 9 years ago

Reorganizing structure of grid

+) Grid doesn't have domain_ref and axis_ref anymore.
All domain and axis of a grid must be inside grid (These domain and axis can be defined or refer to others)
+) Grid contains list of domain and axis
+) Reorder some functions to make sure new functionlities work

Test
+) On Curie
+) Mode attached and detached
+) Only test_new_features
+) Passed

  • Property copyright set to
    Software name : XIOS (Xml I/O Server)
    http://forge.ipsl.jussieu.fr/ioserver
    Creation date : January 2009
    Licence : CeCCIL version2
    see license file in root directory : Licence_CeCILL_V2-en.txt
    or http://www.cecill.info/licences/Licence_CeCILL_V2-en.html
    Holder : CEA/LSCE (Laboratoire des Sciences du CLimat et de l'Environnement)
    CNRS/IPSL (Institut Pierre Simon Laplace)
    Project Manager : Yann Meurdesoif
    yann.meurdesoif@cea.fr
File size: 7.3 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 "expr_node.hpp"
16#include "declare_ref_func.hpp"
17
18
19namespace xios {
20
21   /// ////////////////////// Déclarations ////////////////////// ///
22
23   class CFieldGroup;
24   class CFieldAttributes;
25   class CField;
26
27   class CFile;
28   class CGrid;
29   class CContext ;
30   ///--------------------------------------------------------------
31
32   // Declare/Define CFieldAttribute
33   BEGIN_DECLARE_ATTRIBUTE_MAP(CField)
34#  include "field_attribute.conf"
35   END_DECLARE_ATTRIBUTE_MAP(CField)
36
37   ///--------------------------------------------------------------
38   class CField
39      : public CObjectTemplate<CField>
40      , public CFieldAttributes
41   {
42         /// friend ///
43         friend class CFile;
44
45         /// typedef ///
46         typedef CObjectTemplate<CField>   SuperClass;
47         typedef CFieldAttributes SuperClassAttribute;
48
49      public :
50
51         typedef CFieldAttributes RelAttributes;
52         typedef CFieldGroup      RelGroup;
53
54         enum EEventId
55         {
56           EVENT_ID_UPDATE_DATA, EVENT_ID_ADD_VARIABLE, EVENT_ID_ADD_VARIABLE_GROUP
57         } ;
58
59         /// Constructeurs ///
60         CField(void);
61         explicit CField(const StdString & id);
62         CField(const CField & field);       // Not implemented yet.
63         CField(const CField * const field); // Not implemented yet.
64
65         /// Accesseurs ///
66
67         CGrid* getRelGrid(void) const ;
68         CFile* getRelFile(void) const ;
69
70      public :
71
72         StdSize getNStep(void) const;
73
74         const CDuration & getFreqOperation(void) const;
75         const CDuration & getFreqWrite(void) const;
76
77         boost::shared_ptr<CDate> getLastWriteDate(void) const;
78         boost::shared_ptr<CDate> getLastOperationDate(void) const;
79
80         boost::shared_ptr<func::CFunctor> getFieldOperation(void) const;
81
82         CArray<double, 1> getData(void) const;
83
84
85
86         /// Mutateur ///
87         void setRelFile(CFile* _file);
88         void incrementNStep(void);
89         void resetNStep() ;
90
91         template <int N> bool updateData(const CArray<double, N>&   data);
92         bool updateDataFromExpression(const CArray<double, 1>&   data);
93         void setDataFromExpression(const CArray<double, 1>& _data) ;
94
95         bool updateDataServer
96               (const CDate & currDate,
97                const std::deque< CArray<double, 1>* > storedClient);
98
99         std::map<int, StdSize> getGridDataSize();
100
101       public :
102         bool isActive(void) const;
103         bool active ;
104         bool hasOutputFile ;
105         bool hasFieldOut ;
106
107         /// Traitements ///
108         void processEnabledField(void) ;
109
110         void solveGridReference(void);
111         void solveOperation(void);
112         void solveCheckMaskIndex(bool doSendingIndex);
113         void solveAllReferenceEnabledField(bool doSending2Sever);
114         void buildAllExpressionEnabledField();
115         void solveGridDomainAxisRef(bool checkAtt);
116
117
118//         virtual void fromBinary(StdIStream & is);
119
120         /// Destructeur ///
121         virtual ~CField(void);
122
123         /// Accesseurs statiques ///
124         static StdString GetName(void);
125         static StdString GetDefName(void);
126
127         static ENodeType GetType(void);
128
129        template <int N> void setData(const CArray<double, N>& _data) ;
130        static bool dispatchEvent(CEventServer& event) ;
131        void sendUpdateData(void) ;
132        static void recvUpdateData(CEventServer& event) ;
133        void recvUpdateData(vector<int>& ranks, vector<CBufferIn*>& buffers) ;
134        void writeField(void) ;
135        void outputField(CArray<double,3>& fieldOut) ;
136        void outputField(CArray<double,2>& fieldOut) ;
137        void scaleFactorAddOffset(double scaleFactor, double addOffset) ;
138        void parse(xml::CXMLNode & node) ;
139        CArray<double,1>* getInstantData(void)  ;
140
141        void setVirtualVariableGroup(CVariableGroup* newVVariableGroup);
142        void setVirtualVariableGroup(void);
143        CVariableGroup* getVirtualVariableGroup(void) const;
144        vector<CVariable*> getAllVariables(void) const;
145        virtual void solveDescInheritance(bool apply, const CAttributeMap * const parent = 0);
146
147        CVariable* addVariable(const string& id="") ;
148        CVariableGroup* addVariableGroup(const string& id="") ;
149        void sendAddVariable(const string& id="") ;
150        void sendAddVariableGroup(const string& id="") ;
151        static void recvAddVariable(CEventServer& event) ;
152        void recvAddVariable(CBufferIn& buffer) ;
153        static void recvAddVariableGroup(CEventServer& event) ;
154        void recvAddVariableGroup(CBufferIn& buffer) ;
155        void sendAddAllVariables();
156
157
158        const std::pair<StdString, StdString>& getDomainAxisIds();
159      public :
160         /// Propriétés privées ///
161         CVariableGroup* vVariableGroup ;
162
163         CGrid*  grid ;
164         CFile*  file;
165         CField* fieldOut ;
166
167         CDuration freq_operation, freq_write;
168         CDuration freq_operation_srv, freq_write_srv;
169
170         StdSize nstep;
171         boost::shared_ptr<CDate>    last_Write, last_operation;
172         boost::shared_ptr<CDate>    lastlast_Write_srv,last_Write_srv, last_operation_srv;
173
174         boost::shared_ptr<func::CFunctor> foperation;
175         map<int,boost::shared_ptr<func::CFunctor> > foperation_srv;
176
177         CArray<double, 1> data;
178         CArray<double, 1> instantData;
179         bool hasInstantData ;
180         map<int, CArray<double,1>* > data_srv ;
181         bool isOnceOperation ;
182         bool isFirstOperation ;
183         string content ;
184
185         list< pair<CField *,int> > fieldDependency ;
186         void buildExpression(void) ;
187         void addDependency(CField* field, int slotId) ;
188         void resetSlots(void) ;
189         vector<bool> slots ;
190         CDate* slotUpdateDate ;
191         CFieldNode * expression ;
192         bool hasExpression ;
193         bool slotsFull(void) ;
194         void setSlot(int slotId);
195         bool processed ;
196         bool areAllReferenceSolved;
197         bool areAllExpressionBuilt;
198         std::pair<StdString,StdString> domAxisIds_;
199         DECLARE_REF_FUNC(Field,field)
200//       public:
201//         bool hasDirectFieldReference(void) const;
202//         CField* getDirectFieldReference(void) const;
203//         CField* getBaseFieldReference(void) const;
204//         void addReference(CField* field);
205//         const std::vector<CField*> & getAllReference(void) const;
206//void solveRefInheritance(bool apply);
207//void solveBaseReference(void);
208//         void removeRefInheritance();
209//         const StdString & getBaseFieldId(void) const;
210//
211//         std::vector<CField*> refObject;
212//         CField* baseRefObject;
213
214
215   }; // class CField
216
217   ///--------------------------------------------------------------
218
219   // Declare/Define CFieldGroup and CFieldDefinition
220   DECLARE_GROUP(CField);
221
222   ///-----------------------------------------------------------------
223
224   template <>
225      void CGroupTemplate<CField, CFieldGroup, CFieldAttributes>::solveRefInheritance(void);
226
227   ///-----------------------------------------------------------------
228} // namespace xios
229
230
231#endif // __XMLIO_CField__
Note: See TracBrowser for help on using the repository browser.