source: XIOS/trunk/src/node/file.hpp @ 598

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

Add the infrastructure to request fields from the server.

This will be used to read input files so add a new file attribute mode to define whether data is written or read from a file.

Currently the data is not actually read and random data is transfered for those fields in read mode.

  • 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
File size: 6.0 KB
Line 
1#ifndef __XIOS_CFile__
2#define __XIOS_CFile__
3
4/// XIOS headers ///
5#include "xios_spl.hpp"
6#include "field.hpp"
7#include "data_output.hpp"
8#include "declare_group.hpp"
9#include "date.hpp"
10#include "attribute_enum.hpp"
11#include "attribute_enum_impl.hpp"
12#include "mpi.hpp"
13
14
15
16namespace xios {
17
18   /// ////////////////////// Déclarations ////////////////////// ///
19
20   class CFileGroup;
21   class CFileAttributes;
22   class CFile;
23
24   ///--------------------------------------------------------------
25
26   // Declare/Define CFileAttribute
27   BEGIN_DECLARE_ATTRIBUTE_MAP(CFile)
28#  include "file_attribute.conf"
29   END_DECLARE_ATTRIBUTE_MAP(CFile)
30
31   ///--------------------------------------------------------------
32
33   /*!
34   \class CFile
35   This class corresponds to file component of the xml.
36   The class contains all the nessceary information to write data into a netcdf file: The most important thing
37   is the field(s) which will be written into file. Besides, there are some options to write
38   data into file, e.g: writting into only one file or multiple file; splitting a running into several files.
39   Moreover, there are some other attributes of netcdf file which are also stored in this class
40   */
41   class CFile
42      : public CObjectTemplate<CFile>
43      , public CFileAttributes
44   {
45         /// typedef ///
46         typedef CObjectTemplate<CFile>   SuperClass;
47         typedef CFileAttributes SuperClassAttribute;
48
49      public :
50         enum EEventId
51         {
52           EVENT_ID_ADD_FIELD=0,EVENT_ID_ADD_FIELD_GROUP, EVENT_ID_ADD_VARIABLE,
53           EVENT_ID_ADD_VARIABLE_GROUP, EVENT_ID_CREATE_ENABLED_FIELDS
54         } ;
55
56         typedef CFileAttributes RelAttributes;
57         typedef CFileGroup      RelGroup;
58
59         /// Constructeurs ///
60         CFile(void);
61         explicit CFile(const StdString & id);
62         CFile(const CFile & file);       // Not implemented yet.
63         CFile(const CFile * const file); // Not implemented yet.
64
65         /// Destructeur ///
66         virtual ~CFile(void);
67
68      public:
69         /// Accesseurs ///
70         boost::shared_ptr<CDataOutput> getDataOutput(void) const;
71         CFieldGroup* getVirtualFieldGroup(void) const;
72         CVariableGroup* getVirtualVariableGroup(void) const;
73         std::vector<CField*> getAllFields(void) const;
74         std::vector<CVariable*> getAllVariables(void) const;
75
76         std::vector<CField* > getEnabledFields(int default_outputlevel = 5,
77                                                int default_level = 1,
78                                                bool default_enabled = true);
79
80      public :
81         // Some functions to verify state of file
82         bool isSyncTime(void) ;
83         bool checkSplit(void) ;
84         bool checkSync(void) ;
85         void checkFile(void) ;
86         void initFile(void) ;
87
88         /// Mutateurs ///
89         // Set some root definitions in a file
90         void setVirtualFieldGroup(CFieldGroup* newVFieldGroup);
91         void setVirtualFieldGroup(void);
92         void setVirtualVariableGroup(CVariableGroup* newVVariableGroup);
93         void setVirtualVariableGroup(void);
94
95         void createHeader(void);
96         void close(void) ;
97
98         // Some processing on file
99         void solveFieldRefInheritance(bool apply);
100         void solveEFGridRef(void);
101         void solveEFOperation(void);
102         void solveEFExpression(void);
103         void processEnabledFile(void) ;
104         void processEnabledFields(void) ;
105         void solveAllRefOfEnabledFields(bool sendToServer);
106         void buildAllExpressionOfEnabledFields();
107         void prefetchEnabledReadModeFields();
108         void prefetchEnabledReadModeFieldsIfNeeded();
109
110         // Add component into file
111         CField* addField(const string& id="") ;
112         CFieldGroup* addFieldGroup(const string& id="") ;
113         CVariable* addVariable(const string& id="") ;
114         CVariableGroup* addVariableGroup(const string& id="") ;
115
116         // Send info to serever
117         void sendEnabledFields();
118         void sendAddField(const string& id="") ;
119         void sendAddFieldGroup(const string& id="") ;
120         void sendAddAllVariables();
121         void sendAddVariable(const string& id="") ;
122         void sendAddVariableGroup(const string& id="") ;
123
124         // Receive info from client
125         static void recvAddField(CEventServer& event) ;
126         void recvAddField(CBufferIn& buffer) ;
127         static void recvAddFieldGroup(CEventServer& event) ;
128         void recvAddFieldGroup(CBufferIn& buffer) ;
129         static void recvAddVariable(CEventServer& event) ;
130         void recvAddVariable(CBufferIn& buffer) ;
131         static void recvAddVariableGroup(CEventServer& event) ;
132         void recvAddVariableGroup(CBufferIn& buffer) ;
133
134         // Dispatch event
135         static bool dispatchEvent(CEventServer& event) ;
136
137      public:
138         /// Accesseurs statiques ///
139         static StdString GetName(void);
140         static StdString GetDefName(void);
141
142         static ENodeType GetType(void);
143      public:
144         /// Traitements ///
145         virtual void solveDescInheritance(bool apply, const CAttributeMap * const parent = 0);
146
147          /// Autres ///
148         virtual void parse(xml::CXMLNode & node);
149         virtual StdString toString(void) const;
150      public:
151
152         CDate* lastSync ;
153         CDate* lastSplit ;
154         int nbDomain ;
155         bool isOpen ;
156         bool allDomainEmpty ;
157         MPI_Comm fileComm ;
158
159      private :
160         /// Propriétés privées ///
161         CFieldGroup* vFieldGroup;
162         CVariableGroup* vVariableGroup ;
163         boost::shared_ptr<CDataOutput> data_out;
164         std::vector<CField*> enabledFields;
165
166      public:
167        //         virtual void toBinary  (StdOStream & os) const;
168        //         virtual void fromBinary(StdIStream & is);
169
170   }; // class CFile
171
172   ///--------------------------------------------------------------
173
174   // Declare/Define CFileGroup and CFileDefinition
175   DECLARE_GROUP(CFile);
176
177   ///--------------------------------------------------------------
178
179} // namespace xios
180
181#endif // __XIOS_CFile__
Note: See TracBrowser for help on using the repository browser.