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

Last change on this file since 327 was 327, checked in by ymipsl, 12 years ago

port to gfortran/g++

YM

File size: 5.0 KB
Line 
1#ifndef __XMLIO_CField__
2#define __XMLIO_CField__
3
4/// xmlioserver 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 "context.hpp"
14
15
16namespace xmlioserver {
17namespace tree {
18   
19   /// ////////////////////// Déclarations ////////////////////// ///
20
21   class CFieldGroup;
22   class CFieldAttributes;
23   class CField;
24
25   class CFile;
26   class CGrid;
27   class CContext ;
28   ///--------------------------------------------------------------
29
30   // Declare/Define CFieldAttribute
31   BEGIN_DECLARE_ATTRIBUTE_MAP(CField)
32#  include "field_attribute.conf"
33   END_DECLARE_ATTRIBUTE_MAP(CField)
34
35   ///--------------------------------------------------------------
36   class CField
37      : public CObjectTemplate<CField>
38      , public CFieldAttributes
39   {
40         /// friend ///
41         friend class CFile;
42
43         /// typedef ///
44         typedef CObjectTemplate<CField>   SuperClass;
45         typedef CFieldAttributes SuperClassAttribute;
46
47      public :
48
49         typedef CFieldAttributes RelAttributes;
50         typedef CFieldGroup      RelGroup;
51
52         enum EEventId
53         {
54           EVENT_ID_UPDATE_DATA
55         } ;
56         
57         /// Constructeurs ///
58         CField(void);
59         explicit CField(const StdString & id);
60         CField(const CField & field);       // Not implemented yet.
61         CField(const CField * const field); // Not implemented yet.
62
63         /// Accesseurs ///
64               boost::shared_ptr<CField> getDirectFieldReference(void) const;
65         const boost::shared_ptr<CField> getBaseFieldReference(void)   const;
66         const std::vector<boost::shared_ptr<CField> > & getAllReference(void) const;
67
68         boost::shared_ptr<CGrid> getRelGrid(void) const ;
69         boost::shared_ptr<CFile> getRelFile(void) const ;
70
71      public :
72
73         StdSize getNStep(void) const;
74
75         const date::CDuration & getFreqOperation(void) const;
76         const date::CDuration & getFreqWrite(void) const;
77
78         boost::shared_ptr<date::CDate> getLastWriteDate(void) const;
79         boost::shared_ptr<date::CDate> getLastOperationDate(void) const;
80
81         boost::shared_ptr<func::CFunctor> getFieldOperation(void) const;
82         
83         ARRAY(double, 1) getData(void) const;
84
85         const StdString & getBaseFieldId(void) const;
86
87         /// Mutateur ///
88         void setRelFile(const boost::shared_ptr<CFile> _file);
89         void incrementNStep(void);
90         void resetNStep() ;
91
92         template <StdSize N> bool updateData(const ARRAY(double, N)   data);
93         
94         bool updateDataServer
95               (const date::CDate & currDate,
96                const std::deque<ARRAY(double, 1)> storedClient);
97 
98       public :
99
100         /// Test ///
101         bool hasDirectFieldReference(void) const;
102         bool isActive(void) const;
103
104         /// Traitements ///
105         void solveRefInheritance(void);
106         void solveGridReference(void);
107         void solveOperation(void);
108
109         virtual void fromBinary(StdIStream & is);
110
111         /// Destructeur ///
112         virtual ~CField(void);
113
114         /// Accesseurs statiques ///
115         static StdString GetName(void);
116         static StdString GetDefName(void);
117         
118         static ENodeType GetType(void);
119         
120        template <StdSize N> void setData(const ARRAY(double, N) _data) ;
121        static bool dispatchEvent(CEventServer& event) ;
122        void sendUpdateData(void) ;
123        static void recvUpdateData(CEventServer& event) ;
124        void recvUpdateData(vector<int>& ranks, vector<CBufferIn*>& buffers) ;
125        void writeField(void) ;
126        void outputField(ARRAY(double,3) fieldOut) ;
127        void outputField(ARRAY(double,2) fieldOut) ;
128       
129      public :
130
131         /// Propriétés privées ///
132         
133         std::vector<boost::shared_ptr<CField> > refObject;
134         boost::shared_ptr<CField> baseRefObject;
135         boost::shared_ptr<CGrid>  grid ;
136         boost::shared_ptr<CFile>  file;
137
138         date::CDuration freq_operation, freq_write;
139         date::CDuration freq_operation_srv, freq_write_srv;
140
141         StdSize nstep;
142         boost::shared_ptr<date::CDate>    last_Write, last_operation;
143         boost::shared_ptr<date::CDate>    last_Write_srv, last_operation_srv;
144         
145         boost::shared_ptr<func::CFunctor> foperation;
146         map<int,boost::shared_ptr<func::CFunctor> > foperation_srv;
147         
148         ARRAY(double, 1) data;
149         map<int,ARRAY(double,1)> data_srv ;
150
151   }; // class CField
152
153   ///--------------------------------------------------------------
154
155   // Declare/Define CFieldGroup and CFieldDefinition
156   DECLARE_GROUP(CField);
157
158   } // namespace tree
159
160   ///-----------------------------------------------------------------
161
162   template <>
163      void CGroupTemplate<CField, CFieldGroup, CFieldAttributes>::solveRefInheritance(void);
164
165   ///-----------------------------------------------------------------
166} // namespace xmlioserver
167
168
169#endif // __XMLIO_CField__
Note: See TracBrowser for help on using the repository browser.