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

Last change on this file since 467 was 464, checked in by ymipsl, 10 years ago

Enhancement : Add scale_factor and add_offset attribute to field output
Operation (field-add_offset)/scale_factor would be computed before output write.
If field attribute prec=2 the field would be rounded to nearest integer value and output as short int (2 bytes).

YM

File size: 5.9 KB
RevLine 
[219]1#ifndef __XMLIO_CField__
2#define __XMLIO_CField__
3
[335]4/// xios headers ///
[219]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"
[231]12#include "calendar_util.hpp"
[369]13#include "array_new.hpp"
14#include "attribute_array.hpp"
[459]15#include "expr_node.hpp"
[300]16//#include "context.hpp"
[219]17
[300]18
[335]19namespace xios {
[219]20   
21   /// ////////////////////// Déclarations ////////////////////// ///
22
23   class CFieldGroup;
24   class CFieldAttributes;
25   class CField;
26
27   class CFile;
28   class CGrid;
[300]29   class CContext ;
[219]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
[300]54         enum EEventId
55         {
56           EVENT_ID_UPDATE_DATA
57         } ;
58         
[219]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 ///
[347]66         CField* getDirectFieldReference(void) const;
67         CField* getBaseFieldReference(void)   const;
[459]68         void addReference(CField* field) ;
[347]69         const std::vector<CField*> & getAllReference(void) const;
[219]70
[347]71         CGrid* getRelGrid(void) const ;
72         CFile* getRelFile(void) const ;
[219]73
74      public :
75
[266]76         StdSize getNStep(void) const;
77
[343]78         const CDuration & getFreqOperation(void) const;
79         const CDuration & getFreqWrite(void) const;
[219]80
[343]81         boost::shared_ptr<CDate> getLastWriteDate(void) const;
82         boost::shared_ptr<CDate> getLastOperationDate(void) const;
[219]83
84         boost::shared_ptr<func::CFunctor> getFieldOperation(void) const;
85         
[369]86         CArray<double, 1> getData(void) const;
[219]87
88         const StdString & getBaseFieldId(void) const;
89
90         /// Mutateur ///
[347]91         void setRelFile(CFile* _file);
[266]92         void incrementNStep(void);
[321]93         void resetNStep() ;
[219]94
[369]95         template <int N> bool updateData(const CArray<double, N>&   data);
[459]96         bool updateDataFromExpression(const CArray<double, 1>&   data);
[460]97         void setDataFromExpression(const CArray<double, 1>& _data) ;         
[300]98         
[219]99         bool updateDataServer
[343]100               (const CDate & currDate,
[369]101                const std::deque< CArray<double, 1>* > storedClient);
[300]102 
103       public :
[219]104
105         /// Test ///
106         bool hasDirectFieldReference(void) const;
[310]107         bool isActive(void) const;
[459]108         bool active ;
109         bool hasOutputFile ;
[460]110         bool hasFieldOut ;
[219]111
112         /// Traitements ///
[459]113         void processEnabledField(void) ;
[445]114         void solveRefInheritance(bool apply);
[219]115         void solveGridReference(void);
116         void solveOperation(void);
117
[369]118//         virtual void fromBinary(StdIStream & is);
[219]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);
[300]128         
[369]129        template <int N> void setData(const CArray<double, N>& _data) ;
[300]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) ;
[369]135        void outputField(CArray<double,3>& fieldOut) ;
136        void outputField(CArray<double,2>& fieldOut) ;
[464]137        void scaleFactorAddOffset(double scaleFactor, double addOffset) ;
[459]138        void parse(xml::CXMLNode & node) ;
139        CArray<double,1>* getInstantData(void)  ;
[300]140      public :
[219]141
142         /// Propriétés privées ///
143         
[347]144         std::vector<CField*> refObject;
145         CField* baseRefObject;
146         CGrid*  grid ;
147         CFile*  file;
[460]148         CField* fieldOut ;
[219]149
[343]150         CDuration freq_operation, freq_write;
151         CDuration freq_operation_srv, freq_write_srv;
[219]152
[266]153         StdSize nstep;
[343]154         boost::shared_ptr<CDate>    last_Write, last_operation;
155         boost::shared_ptr<CDate>    lastlast_Write_srv,last_Write_srv, last_operation_srv;
[300]156         
[219]157         boost::shared_ptr<func::CFunctor> foperation;
[300]158         map<int,boost::shared_ptr<func::CFunctor> > foperation_srv;
[219]159         
[369]160         CArray<double, 1> data;
[459]161         CArray<double, 1> instantData;
162         bool hasInstantData ;
[369]163         map<int, CArray<double,1>* > data_srv ;
[436]164         bool isOnceOperation ;
165         bool isFirstOperation ;
[459]166         string content ;
167         
168         list< pair<CField *,int> > fieldDependency ;
169         void buildExpression(void) ;
170         void addDependency(CField* field, int slotId) ;
171         void resetSlots(void) ;
172         vector<bool> slots ;
173         CDate* slotUpdateDate ;
174         CFieldNode * expression ;
175         bool hasExpression ;
176         bool slotsFull(void) ;
177         void setSlot(int slotId);
178         bool processed ;
[219]179
180   }; // class CField
181
182   ///--------------------------------------------------------------
183
184   // Declare/Define CFieldGroup and CFieldDefinition
185   DECLARE_GROUP(CField);
186
187   ///-----------------------------------------------------------------
188
189   template <>
190      void CGroupTemplate<CField, CFieldGroup, CFieldAttributes>::solveRefInheritance(void);
191
192   ///-----------------------------------------------------------------
[335]193} // namespace xios
[219]194
195
196#endif // __XMLIO_CField__
Note: See TracBrowser for help on using the repository browser.