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

Last change on this file since 520 was 509, checked in by mhnguyen, 10 years ago

Implementing buffer size auto-detection for mode client -server

+) Process xml tree in client side then send all the information to server
+) Only information enabled fields in enabled files are sent to server
+) Some important change in structure of code which must be refactored

Test
+) On Curie
+) Only mode client-server
+) Passed for all tests

  • 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 "context.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         CField* getDirectFieldReference(void) const;
67         CField* getBaseFieldReference(void)   const;
68         void addReference(CField* field) ;
69         const std::vector<CField*> & getAllReference(void) const;
70
71         CGrid* getRelGrid(void) const ;
72         CFile* getRelFile(void) const ;
73
74      public :
75
76         StdSize getNStep(void) const;
77
78         const CDuration & getFreqOperation(void) const;
79         const CDuration & getFreqWrite(void) const;
80
81         boost::shared_ptr<CDate> getLastWriteDate(void) const;
82         boost::shared_ptr<CDate> getLastOperationDate(void) const;
83
84         boost::shared_ptr<func::CFunctor> getFieldOperation(void) const;
85
86         CArray<double, 1> getData(void) const;
87
88         const StdString & getBaseFieldId(void) const;
89
90         /// Mutateur ///
91         void setRelFile(CFile* _file);
92         void incrementNStep(void);
93         void resetNStep() ;
94
95         template <int N> bool updateData(const CArray<double, N>&   data);
96         bool updateDataFromExpression(const CArray<double, 1>&   data);
97         void setDataFromExpression(const CArray<double, 1>& _data) ;
98
99         bool updateDataServer
100               (const CDate & currDate,
101                const std::deque< CArray<double, 1>* > storedClient);
102
103         std::map<int, StdSize> getGridDataSize();
104
105       public :
106
107         /// Test ///
108         bool hasDirectFieldReference(void) const;
109         bool isActive(void) const;
110         bool active ;
111         bool hasOutputFile ;
112         bool hasFieldOut ;
113
114         /// Traitements ///
115         void processEnabledField(void) ;
116         void solveRefInheritance(bool apply);
117         void solveBaseReference(void);
118         void solveGridReference(void);
119         void solveOperation(void);
120         void solveCheckMaskIndex(bool doSendingIndex);
121         void solveAllReferenceEnabledField(bool doSending2Sever);
122         void buildAllExpressionEnabledField();
123         void solveGridDomainAxisRef(bool checkAtt);
124         void removeRefInheritance();  // Remove all reference of current field (it refers to itself)
125
126//         virtual void fromBinary(StdIStream & is);
127
128         /// Destructeur ///
129         virtual ~CField(void);
130
131         /// Accesseurs statiques ///
132         static StdString GetName(void);
133         static StdString GetDefName(void);
134
135         static ENodeType GetType(void);
136
137        template <int N> void setData(const CArray<double, N>& _data) ;
138        static bool dispatchEvent(CEventServer& event) ;
139        void sendUpdateData(void) ;
140        static void recvUpdateData(CEventServer& event) ;
141        void recvUpdateData(vector<int>& ranks, vector<CBufferIn*>& buffers) ;
142        void writeField(void) ;
143        void outputField(CArray<double,3>& fieldOut) ;
144        void outputField(CArray<double,2>& fieldOut) ;
145        void scaleFactorAddOffset(double scaleFactor, double addOffset) ;
146        void parse(xml::CXMLNode & node) ;
147        CArray<double,1>* getInstantData(void)  ;
148
149        void setVirtualVariableGroup(CVariableGroup* newVVariableGroup);
150        void setVirtualVariableGroup(void);
151        CVariableGroup* getVirtualVariableGroup(void) const;
152        vector<CVariable*> getAllVariables(void) const;
153        virtual void solveDescInheritance(bool apply, const CAttributeMap * const parent = 0);
154
155        CVariable* addVariable(const string& id="") ;
156        CVariableGroup* addVariableGroup(const string& id="") ;
157        void sendAddVariable(const string& id="") ;
158        void sendAddVariableGroup(const string& id="") ;
159        static void recvAddVariable(CEventServer& event) ;
160        void recvAddVariable(CBufferIn& buffer) ;
161        static void recvAddVariableGroup(CEventServer& event) ;
162        void recvAddVariableGroup(CBufferIn& buffer) ;
163        void sendAddAllVariables();
164
165
166        const std::pair<StdString, StdString>& getDomainAxisIds();
167      public :
168
169         /// Propriétés privées ///
170         CVariableGroup* vVariableGroup ;
171
172         std::vector<CField*> refObject;
173         CField* baseRefObject;
174         CGrid*  grid ;
175         CFile*  file;
176         CField* fieldOut ;
177
178         CDuration freq_operation, freq_write;
179         CDuration freq_operation_srv, freq_write_srv;
180
181         StdSize nstep;
182         boost::shared_ptr<CDate>    last_Write, last_operation;
183         boost::shared_ptr<CDate>    lastlast_Write_srv,last_Write_srv, last_operation_srv;
184
185         boost::shared_ptr<func::CFunctor> foperation;
186         map<int,boost::shared_ptr<func::CFunctor> > foperation_srv;
187
188         CArray<double, 1> data;
189         CArray<double, 1> instantData;
190         bool hasInstantData ;
191         map<int, CArray<double,1>* > data_srv ;
192         bool isOnceOperation ;
193         bool isFirstOperation ;
194         string content ;
195
196         list< pair<CField *,int> > fieldDependency ;
197         void buildExpression(void) ;
198         void addDependency(CField* field, int slotId) ;
199         void resetSlots(void) ;
200         vector<bool> slots ;
201         CDate* slotUpdateDate ;
202         CFieldNode * expression ;
203         bool hasExpression ;
204         bool slotsFull(void) ;
205         void setSlot(int slotId);
206         bool processed ;
207         bool areAllReferenceSolved;
208         bool areAllExpressionBuilt;
209         std::pair<StdString,StdString> domAxisIds_;
210
211   }; // class CField
212
213   ///--------------------------------------------------------------
214
215   // Declare/Define CFieldGroup and CFieldDefinition
216   DECLARE_GROUP(CField);
217
218   ///-----------------------------------------------------------------
219
220   template <>
221      void CGroupTemplate<CField, CFieldGroup, CFieldAttributes>::solveRefInheritance(void);
222
223   ///-----------------------------------------------------------------
224} // namespace xios
225
226
227#endif // __XMLIO_CField__
Note: See TracBrowser for help on using the repository browser.