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

Last change on this file since 707 was 707, checked in by rlacroix, 9 years ago

Append mode: Detect the correct restart point and erase some records if need be.

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