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

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

Remove leftovers from the XMLIO age.

  • 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: 5.9 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
108         // Add component into file
109         CField* addField(const string& id="") ;
110         CFieldGroup* addFieldGroup(const string& id="") ;
111         CVariable* addVariable(const string& id="") ;
112         CVariableGroup* addVariableGroup(const string& id="") ;
113
114         // Send info to serever
115         void sendEnabledFields();
116         void sendAddField(const string& id="") ;
117         void sendAddFieldGroup(const string& id="") ;
118         void sendAddAllVariables();
119         void sendAddVariable(const string& id="") ;
120         void sendAddVariableGroup(const string& id="") ;
121
122         // Receive info from client
123         static void recvAddField(CEventServer& event) ;
124         void recvAddField(CBufferIn& buffer) ;
125         static void recvAddFieldGroup(CEventServer& event) ;
126         void recvAddFieldGroup(CBufferIn& buffer) ;
127         static void recvAddVariable(CEventServer& event) ;
128         void recvAddVariable(CBufferIn& buffer) ;
129         static void recvAddVariableGroup(CEventServer& event) ;
130         void recvAddVariableGroup(CBufferIn& buffer) ;
131
132         // Dispatch event
133         static bool dispatchEvent(CEventServer& event) ;
134
135      public:
136         /// Accesseurs statiques ///
137         static StdString GetName(void);
138         static StdString GetDefName(void);
139
140         static ENodeType GetType(void);
141      public:
142         /// Traitements ///
143         virtual void solveDescInheritance(bool apply, const CAttributeMap * const parent = 0);
144
145          /// Autres ///
146         virtual void parse(xml::CXMLNode & node);
147         virtual StdString toString(void) const;
148      public:
149
150         CDate* lastSync ;
151         CDate* lastSplit ;
152         int nbDomain ;
153         bool isOpen ;
154         bool allDomainEmpty ;
155         MPI_Comm fileComm ;
156
157      private :
158         /// Propriétés privées ///
159         CFieldGroup* vFieldGroup;
160         CVariableGroup* vVariableGroup ;
161         boost::shared_ptr<CDataOutput> data_out;
162         std::vector<CField*> enabledFields;
163
164      public:
165        //         virtual void toBinary  (StdOStream & os) const;
166        //         virtual void fromBinary(StdIStream & is);
167
168   }; // class CFile
169
170   ///--------------------------------------------------------------
171
172   // Declare/Define CFileGroup and CFileDefinition
173   DECLARE_GROUP(CFile);
174
175   ///--------------------------------------------------------------
176
177} // namespace xios
178
179#endif // __XIOS_CFile__
Note: See TracBrowser for help on using the repository browser.