[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" |
---|
[219] | 8 | #include "declare_group.hpp" |
---|
[318] | 9 | #include "date.hpp" |
---|
[369] | 10 | #include "attribute_enum.hpp" |
---|
| 11 | #include "attribute_enum_impl.hpp" |
---|
[382] | 12 | #include "mpi.hpp" |
---|
[219] | 13 | |
---|
| 14 | |
---|
[300] | 15 | |
---|
[335] | 16 | namespace xios { |
---|
[509] | 17 | |
---|
[219] | 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 | |
---|
[509] | 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 | */ |
---|
[219] | 41 | class CFile |
---|
| 42 | : public CObjectTemplate<CFile> |
---|
| 43 | , public CFileAttributes |
---|
| 44 | { |
---|
| 45 | /// typedef /// |
---|
| 46 | typedef CObjectTemplate<CFile> SuperClass; |
---|
| 47 | typedef CFileAttributes SuperClassAttribute; |
---|
[509] | 48 | |
---|
[219] | 49 | public : |
---|
[300] | 50 | enum EEventId |
---|
| 51 | { |
---|
[509] | 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 |
---|
[300] | 54 | } ; |
---|
[509] | 55 | |
---|
[219] | 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 | |
---|
[509] | 65 | /// Destructeur /// |
---|
| 66 | virtual ~CFile(void); |
---|
| 67 | |
---|
| 68 | public: |
---|
[219] | 69 | /// Accesseurs /// |
---|
[337] | 70 | boost::shared_ptr<CDataOutput> getDataOutput(void) const; |
---|
[347] | 71 | CFieldGroup* getVirtualFieldGroup(void) const; |
---|
[472] | 72 | CVariableGroup* getVirtualVariableGroup(void) const; |
---|
[347] | 73 | std::vector<CField*> getAllFields(void) const; |
---|
[472] | 74 | std::vector<CVariable*> getAllVariables(void) const; |
---|
[219] | 75 | |
---|
[347] | 76 | std::vector<CField* > getEnabledFields(int default_outputlevel = 5, |
---|
| 77 | int default_level = 1, |
---|
| 78 | bool default_enabled = true); |
---|
[219] | 79 | |
---|
| 80 | public : |
---|
[509] | 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) ; |
---|
[219] | 87 | |
---|
| 88 | /// Mutateurs /// |
---|
[509] | 89 | // Set some root definitions in a file |
---|
[347] | 90 | void setVirtualFieldGroup(CFieldGroup* newVFieldGroup); |
---|
[300] | 91 | void setVirtualFieldGroup(void); |
---|
[472] | 92 | void setVirtualVariableGroup(CVariableGroup* newVVariableGroup); |
---|
| 93 | void setVirtualVariableGroup(void); |
---|
[509] | 94 | |
---|
[300] | 95 | void createHeader(void); |
---|
[286] | 96 | void close(void) ; |
---|
[509] | 97 | |
---|
| 98 | // Some processing on file |
---|
[445] | 99 | void solveFieldRefInheritance(bool apply); |
---|
[219] | 100 | void solveEFGridRef(void); |
---|
| 101 | void solveEFOperation(void); |
---|
[459] | 102 | void solveEFExpression(void); |
---|
[509] | 103 | void processEnabledFile(void) ; |
---|
| 104 | void processEnabledFields(void) ; |
---|
| 105 | void solveAllRefOfEnabledFields(bool sendToServer); |
---|
| 106 | void buildAllExpressionOfEnabledFields(); |
---|
[219] | 107 | |
---|
[509] | 108 | // Add component into file |
---|
[347] | 109 | CField* addField(const string& id="") ; |
---|
| 110 | CFieldGroup* addFieldGroup(const string& id="") ; |
---|
[472] | 111 | CVariable* addVariable(const string& id="") ; |
---|
| 112 | CVariableGroup* addVariableGroup(const string& id="") ; |
---|
[509] | 113 | |
---|
| 114 | // Send info to serever |
---|
| 115 | void sendEnabledFields(); |
---|
[300] | 116 | void sendAddField(const string& id="") ; |
---|
| 117 | void sendAddFieldGroup(const string& id="") ; |
---|
[509] | 118 | void sendAddAllVariables(); |
---|
| 119 | void sendAddVariable(const string& id="") ; |
---|
| 120 | void sendAddVariableGroup(const string& id="") ; |
---|
| 121 | |
---|
| 122 | // Receive info from client |
---|
[300] | 123 | static void recvAddField(CEventServer& event) ; |
---|
| 124 | void recvAddField(CBufferIn& buffer) ; |
---|
| 125 | static void recvAddFieldGroup(CEventServer& event) ; |
---|
| 126 | void recvAddFieldGroup(CBufferIn& buffer) ; |
---|
[472] | 127 | static void recvAddVariable(CEventServer& event) ; |
---|
| 128 | void recvAddVariable(CBufferIn& buffer) ; |
---|
| 129 | static void recvAddVariableGroup(CEventServer& event) ; |
---|
| 130 | void recvAddVariableGroup(CBufferIn& buffer) ; |
---|
[509] | 131 | |
---|
| 132 | // Dispatch event |
---|
[300] | 133 | static bool dispatchEvent(CEventServer& event) ; |
---|
[509] | 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 | |
---|
[343] | 150 | CDate* lastSync ; |
---|
| 151 | CDate* lastSplit ; |
---|
[318] | 152 | int nbDomain ; |
---|
[321] | 153 | bool isOpen ; |
---|
[509] | 154 | bool allDomainEmpty ; |
---|
[379] | 155 | MPI_Comm fileComm ; |
---|
[509] | 156 | |
---|
[219] | 157 | private : |
---|
| 158 | /// Propriétés privées /// |
---|
[347] | 159 | CFieldGroup* vFieldGroup; |
---|
[472] | 160 | CVariableGroup* vVariableGroup ; |
---|
[337] | 161 | boost::shared_ptr<CDataOutput> data_out; |
---|
[347] | 162 | std::vector<CField*> enabledFields; |
---|
[219] | 163 | |
---|
[509] | 164 | public: |
---|
| 165 | // virtual void toBinary (StdOStream & os) const; |
---|
| 166 | // virtual void fromBinary(StdIStream & is); |
---|
| 167 | |
---|
[219] | 168 | }; // class CFile |
---|
| 169 | |
---|
| 170 | ///-------------------------------------------------------------- |
---|
| 171 | |
---|
| 172 | // Declare/Define CFileGroup and CFileDefinition |
---|
| 173 | DECLARE_GROUP(CFile); |
---|
| 174 | |
---|
| 175 | ///-------------------------------------------------------------- |
---|
| 176 | |
---|
[335] | 177 | } // namespace xios |
---|
[219] | 178 | |
---|
[591] | 179 | #endif // __XIOS_CFile__ |
---|