source: XIOS/dev/branch_yushan/src/node/file.hpp @ 1037

Last change on this file since 1037 was 1037, checked in by yushan, 7 years ago

initialize the branch

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