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

Last change on this file since 1212 was 1158, checked in by oabramkina, 7 years ago

Two server levels: merging with trunk r1137.
There are bugs.

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