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

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

Implement reading fields from NetCDF files.

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