source: XIOS/dev/dev_olga/src/node/field.hpp @ 1021

Last change on this file since 1021 was 1021, checked in by oabramkina, 4 years ago

Intermeadiate version for merging with new server functionalities.

  • 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
  • Property svn:executable set to *
File size: 9.0 KB
Line 
1#ifndef __XIOS_CField__
2#define __XIOS_CField__
3
4/// XIOS headers ///
5#include "xios_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 "declare_ref_func.hpp"
16#include "transformation_enum.hpp"
17#include "variable.hpp"
18#include "context_client.hpp"
19
20
21namespace xios {
22
23   /// ////////////////////// Déclarations ////////////////////// ///
24
25   class CFieldGroup;
26   class CFieldAttributes;
27   class CField;
28
29   class CFile;
30   class CGrid;
31   class CContext;
32   class CGenericFilter;
33
34   class CGarbageCollector;
35   class COutputPin;
36   class CSourceFilter;
37   class CStoreFilter;
38   class CFileWriterFilter;
39
40   ///--------------------------------------------------------------
41
42   // Declare/Define CFieldAttribute
43   BEGIN_DECLARE_ATTRIBUTE_MAP(CField)
44#  include "field_attribute.conf"
45   END_DECLARE_ATTRIBUTE_MAP(CField)
46
47   ///--------------------------------------------------------------
48   class CField
49      : public CObjectTemplate<CField>
50      , public CFieldAttributes
51   {
52         /// friend ///
53         friend class CFile;
54
55         /// typedef ///
56         typedef CObjectTemplate<CField>   SuperClass;
57         typedef CFieldAttributes SuperClassAttribute;
58
59      public:
60
61         typedef CFieldAttributes RelAttributes;
62         typedef CFieldGroup      RelGroup;
63
64         enum EEventId
65         {
66           EVENT_ID_UPDATE_DATA, EVENT_ID_READ_DATA, EVENT_ID_READ_DATA_READY,
67           EVENT_ID_ADD_VARIABLE, EVENT_ID_ADD_VARIABLE_GROUP
68         };
69
70         /// Constructeurs ///
71         CField(void);
72         explicit CField(const StdString& id);
73         CField(const CField& field);       // Not implemented yet.
74         CField(const CField* const field); // Not implemented yet.
75
76         /// Accesseurs ///
77
78         CGrid* getRelGrid(void) const;
79         CFile* getRelFile(void) const;
80
81         func::CFunctor::ETimeType getOperationTimeType() const;
82
83      public:
84         int getNStep(void) const;
85
86         template <int N> void getData(CArray<double, N>& _data) const;
87
88         boost::shared_ptr<COutputPin> getInstantDataFilter();
89
90         /// Mutateur ///
91         void setRelFile(CFile* _file);
92         void incrementNStep(void);
93         void resetNStep(int nstep = 0);
94         void resetNStepMax();
95
96         std::map<int, StdSize> getGridAttributesBufferSize();
97         std::map<int, StdSize> getGridDataBufferSize();
98
99       public:
100         bool isActive(void) const;
101         bool hasOutputFile;
102
103         bool wasWritten() const;
104         void setWritten();
105
106         bool getUseCompressedOutput() const;
107         void setUseCompressedOutput();
108
109         /// Traitements ///
110         void solveGridReference(void);
111         void solveServerOperation(void);
112         void solveCheckMaskIndex(bool doSendingIndex);
113         void solveAllReferenceEnabledField(bool doSending2Server);
114         void solveOnlyReferenceEnabledField(bool doSending2Server);
115         void generateNewTransformationGridDest();
116         void updateRef(CGrid* grid);
117         void buildGridTransformationGraph();
118         void solveGridDomainAxisRef(bool checkAtt);
119         void solveTransformedGrid();
120         void solveGenerateGrid();
121         void solveGridDomainAxisBaseRef();
122
123         void buildFilterGraph(CGarbageCollector& gc, bool enableOutput);
124         boost::shared_ptr<COutputPin> getFieldReference(CGarbageCollector& gc);
125         boost::shared_ptr<COutputPin> getSelfReference(CGarbageCollector& gc);
126         boost::shared_ptr<COutputPin> getTemporalDataFilter(CGarbageCollector& gc, CDuration outFreq);
127         boost::shared_ptr<COutputPin> getSelfTemporalDataFilter(CGarbageCollector& gc, CDuration outFreq);
128
129//         virtual void fromBinary(StdIStream& is);
130
131         /// Destructeur ///
132         virtual ~CField(void);
133
134         /// Accesseurs statiques ///
135         static StdString GetName(void);
136         static StdString GetDefName(void);
137
138         static ENodeType GetType(void);
139
140        template <int N> void setData(const CArray<double, N>& _data);
141        static bool dispatchEvent(CEventServer& event);
142        void sendUpdateData(const CArray<double,1>& data);
143        void sendUpdateData(const CArray<double,1>& data, CContextClient* client);
144        static void recvUpdateData(CEventServer& event);
145        void recvUpdateData(vector<int>& ranks, vector<CBufferIn*>& buffers);
146        void writeField(void);
147        void sendReadDataRequest(const CDate& tsDataRequested);
148        bool sendReadDataRequestIfNeeded(void);
149        static void recvReadDataRequest(CEventServer& event);
150        void recvReadDataRequest(void);
151        bool readField(void);
152        static void recvReadDataReady(CEventServer& event);
153        void recvReadDataReady(vector<int> ranks, vector<CBufferIn*> buffers);
154        void outputField(CArray<double,3>& fieldOut);
155        void outputField(CArray<double,2>& fieldOut);
156        void outputField(CArray<double,1>& fieldOut);
157        void inputField(CArray<double,3>& fieldOut);
158        void inputField(CArray<double,2>& fieldOut);
159        void inputField(CArray<double,1>& fieldOut);
160        void outputCompressedField(CArray<double, 1>& fieldOut);
161        void scaleFactorAddOffset(double scaleFactor, double addOffset);
162        void invertScaleFactorAddOffset(double scaleFactor, double addOffset);
163        void parse(xml::CXMLNode& node);
164
165        void setVirtualVariableGroup(CVariableGroup* newVVariableGroup);
166        CVariableGroup* getVirtualVariableGroup(void) const;
167        vector<CVariable*> getAllVariables(void) const;
168        virtual void solveDescInheritance(bool apply, const CAttributeMap* const parent = 0);
169
170        CVariable* addVariable(const string& id = "");
171        CVariableGroup* addVariableGroup(const string& id = "");
172        void sendAddVariable(const string& id = "");
173        void sendAddVariable(const string& id, CContextClient* client);
174        void sendAddVariableGroup(const string& id = "");
175        static void recvAddVariable(CEventServer& event);
176        void recvAddVariable(CBufferIn& buffer);
177        static void recvAddVariableGroup(CEventServer& event);
178        void recvAddVariableGroup(CBufferIn& buffer);
179        void sendAddAllVariables();
180        void sendAddAllVariables(CContextClient* client);
181
182        const std::vector<StdString>& getRefDomainAxisIds();
183
184        const string& getExpression(void);
185        bool hasExpression(void) const;
186
187      public:
188         /// Propriétés privées ///
189         CVariableGroup* vVariableGroup;
190
191         CGrid*  grid;
192         CFile*  file;
193
194         CDuration freq_operation_srv, freq_write_srv;
195
196         bool written; //<! Was the field written at least once
197         int nstep, nstepMax;
198         bool isEOF;
199         CDate lastlast_Write_srv, last_Write_srv, last_operation_srv;
200         CDate lastDataRequestedFromServer, lastDataReceivedFromServer;
201         bool wasDataAlreadyReceivedFromServer;
202
203         map<int,boost::shared_ptr<func::CFunctor> > foperation_srv;
204
205         map<int, CArray<double,1> > data_srv;
206         string content;
207
208         bool areAllReferenceSolved;
209         bool isReferenceSolved;
210         std::vector<StdString> domAxisScalarIds_;
211         bool useCompressedOutput;
212
213         // Two variables to identify the time_counter meta data written in file, which has no time_counter
214         bool hasTimeInstant;
215         bool hasTimeCentered;
216
217         DECLARE_REF_FUNC(Field,field)
218
219      private:
220         //! The type of operation attached to the field
221         func::CFunctor::ETimeType operationTimeType;
222
223         //! The output pin of the filter providing the instant data for the field
224         boost::shared_ptr<COutputPin> instantDataFilter;
225         //! The output pin of the filters providing the result of the field's temporal operation
226         std::map<CDuration, boost::shared_ptr<COutputPin>, DurationFakeLessComparator> temporalDataFilters;
227         //! The output pin of the filter providing the instant data for self references
228         boost::shared_ptr<COutputPin> selfReferenceFilter;
229         //! The source filter for data provided by the client
230         boost::shared_ptr<CSourceFilter> clientSourceFilter;
231         //! The source filter for data provided by the server
232         boost::shared_ptr<CSourceFilter> serverSourceFilter;
233         //! The terminal filter which stores the instant data
234         boost::shared_ptr<CStoreFilter> storeFilter;
235         //! The terminal filter which writes the data to file
236         boost::shared_ptr<CFileWriterFilter> fileWriterFilter;
237   }; // class CField
238
239   ///--------------------------------------------------------------
240
241   // Declare/Define CFieldGroup and CFieldDefinition
242   DECLARE_GROUP(CField);
243
244   ///-----------------------------------------------------------------
245
246   template <>
247      void CGroupTemplate<CField, CFieldGroup, CFieldAttributes>::solveRefInheritance(void);
248
249   ///-----------------------------------------------------------------
250} // namespace xios
251
252
253#endif // __XIOS_CField__
Note: See TracBrowser for help on using the repository browser.