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