[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" |
---|
[1134] | 14 | #ifdef _usingEP |
---|
| 15 | #include "ep_declaration.hpp" |
---|
| 16 | #endif |
---|
[219] | 17 | |
---|
[335] | 18 | namespace xios { |
---|
[509] | 19 | |
---|
[219] | 20 | /// ////////////////////// Déclarations ////////////////////// /// |
---|
| 21 | |
---|
| 22 | class CFileGroup; |
---|
| 23 | class CFileAttributes; |
---|
| 24 | class CFile; |
---|
| 25 | |
---|
[640] | 26 | class CGarbageCollector; |
---|
| 27 | |
---|
[219] | 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 | |
---|
[509] | 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 | */ |
---|
[219] | 45 | class CFile |
---|
| 46 | : public CObjectTemplate<CFile> |
---|
| 47 | , public CFileAttributes |
---|
| 48 | { |
---|
| 49 | /// typedef /// |
---|
| 50 | typedef CObjectTemplate<CFile> SuperClass; |
---|
| 51 | typedef CFileAttributes SuperClassAttribute; |
---|
[509] | 52 | |
---|
[219] | 53 | public : |
---|
[300] | 54 | enum EEventId |
---|
| 55 | { |
---|
[651] | 56 | EVENT_ID_ADD_FIELD, EVENT_ID_ADD_FIELD_GROUP, EVENT_ID_ADD_VARIABLE, |
---|
[509] | 57 | EVENT_ID_ADD_VARIABLE_GROUP, EVENT_ID_CREATE_ENABLED_FIELDS |
---|
[651] | 58 | }; |
---|
[509] | 59 | |
---|
[219] | 60 | typedef CFileAttributes RelAttributes; |
---|
| 61 | typedef CFileGroup RelGroup; |
---|
| 62 | |
---|
| 63 | /// Constructeurs /// |
---|
| 64 | CFile(void); |
---|
[651] | 65 | explicit CFile(const StdString& id); |
---|
| 66 | CFile(const CFile& file); // Not implemented yet. |
---|
| 67 | CFile(const CFile* const file); // Not implemented yet. |
---|
[219] | 68 | |
---|
[509] | 69 | /// Destructeur /// |
---|
| 70 | virtual ~CFile(void); |
---|
| 71 | |
---|
| 72 | public: |
---|
[219] | 73 | /// Accesseurs /// |
---|
[1090] | 74 | const StdString getFileOutputName(void) const; |
---|
[337] | 75 | boost::shared_ptr<CDataOutput> getDataOutput(void) const; |
---|
[599] | 76 | boost::shared_ptr<CDataInput> getDataInput(void) const; |
---|
[347] | 77 | CFieldGroup* getVirtualFieldGroup(void) const; |
---|
[472] | 78 | CVariableGroup* getVirtualVariableGroup(void) const; |
---|
[347] | 79 | std::vector<CField*> getAllFields(void) const; |
---|
[472] | 80 | std::vector<CVariable*> getAllVariables(void) const; |
---|
[219] | 81 | |
---|
[347] | 82 | std::vector<CField* > getEnabledFields(int default_outputlevel = 5, |
---|
| 83 | int default_level = 1, |
---|
| 84 | bool default_enabled = true); |
---|
[219] | 85 | |
---|
| 86 | public : |
---|
[509] | 87 | // Some functions to verify state of file |
---|
[651] | 88 | bool isSyncTime(void); |
---|
| 89 | bool checkSplit(void); |
---|
| 90 | bool checkSync(void); |
---|
| 91 | void checkFile(void); |
---|
| 92 | void initFile(void); |
---|
[219] | 93 | |
---|
| 94 | /// Mutateurs /// |
---|
[509] | 95 | // Set some root definitions in a file |
---|
[347] | 96 | void setVirtualFieldGroup(CFieldGroup* newVFieldGroup); |
---|
[472] | 97 | void setVirtualVariableGroup(CVariableGroup* newVVariableGroup); |
---|
[509] | 98 | |
---|
[300] | 99 | void createHeader(void); |
---|
[599] | 100 | void openInReadMode(void); |
---|
[651] | 101 | void close(void); |
---|
[775] | 102 | void readAttributesOfEnabledFieldsInReadMode(); |
---|
[509] | 103 | |
---|
| 104 | // Some processing on file |
---|
[445] | 105 | void solveFieldRefInheritance(bool apply); |
---|
[651] | 106 | void processEnabledFile(void); |
---|
[823] | 107 | void solveOnlyRefOfEnabledFields(bool sendToServer); |
---|
| 108 | void generateNewTransformationGridDest(); |
---|
[509] | 109 | void solveAllRefOfEnabledFields(bool sendToServer); |
---|
[640] | 110 | void buildFilterGraphOfEnabledFields(CGarbageCollector& gc); |
---|
[598] | 111 | void prefetchEnabledReadModeFields(); |
---|
| 112 | void prefetchEnabledReadModeFieldsIfNeeded(); |
---|
[219] | 113 | |
---|
[509] | 114 | // Add component into file |
---|
[651] | 115 | CField* addField(const string& id = ""); |
---|
| 116 | CFieldGroup* addFieldGroup(const string& id = ""); |
---|
| 117 | CVariable* addVariable(const string& id = ""); |
---|
| 118 | CVariableGroup* addVariableGroup(const string& id = ""); |
---|
[509] | 119 | |
---|
| 120 | // Send info to serever |
---|
| 121 | void sendEnabledFields(); |
---|
[651] | 122 | void sendAddField(const string& id = ""); |
---|
| 123 | void sendAddFieldGroup(const string& id = ""); |
---|
[509] | 124 | void sendAddAllVariables(); |
---|
[651] | 125 | void sendAddVariable(const string& id = ""); |
---|
| 126 | void sendAddVariableGroup(const string& id = ""); |
---|
[509] | 127 | |
---|
| 128 | // Receive info from client |
---|
[651] | 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); |
---|
[509] | 137 | |
---|
| 138 | // Dispatch event |
---|
[651] | 139 | static bool dispatchEvent(CEventServer& event); |
---|
[509] | 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 /// |
---|
[651] | 149 | virtual void solveDescInheritance(bool apply, const CAttributeMap* const parent = 0); |
---|
[509] | 150 | |
---|
| 151 | /// Autres /// |
---|
[651] | 152 | virtual void parse(xml::CXMLNode& node); |
---|
[509] | 153 | virtual StdString toString(void) const; |
---|
| 154 | public: |
---|
| 155 | |
---|
[651] | 156 | CDate lastSync; |
---|
| 157 | CDate lastSplit; |
---|
[609] | 158 | int nbAxis, nbDomains; |
---|
[651] | 159 | bool isOpen; |
---|
| 160 | bool allDomainEmpty; |
---|
[1134] | 161 | ep_lib::MPI_Comm fileComm; |
---|
[509] | 162 | |
---|
[219] | 163 | private : |
---|
| 164 | /// Propriétés privées /// |
---|
[347] | 165 | CFieldGroup* vFieldGroup; |
---|
[651] | 166 | CVariableGroup* vVariableGroup; |
---|
[337] | 167 | boost::shared_ptr<CDataOutput> data_out; |
---|
[599] | 168 | boost::shared_ptr<CDataInput> data_in; |
---|
[347] | 169 | std::vector<CField*> enabledFields; |
---|
[219] | 170 | |
---|
[509] | 171 | public: |
---|
[651] | 172 | // virtual void toBinary (StdOStream& os) const; |
---|
| 173 | // virtual void fromBinary(StdIStream& is); |
---|
[509] | 174 | |
---|
[219] | 175 | }; // class CFile |
---|
| 176 | |
---|
| 177 | ///-------------------------------------------------------------- |
---|
| 178 | |
---|
| 179 | // Declare/Define CFileGroup and CFileDefinition |
---|
| 180 | DECLARE_GROUP(CFile); |
---|
| 181 | |
---|
| 182 | ///-------------------------------------------------------------- |
---|
| 183 | |
---|
[335] | 184 | } // namespace xios |
---|
[219] | 185 | |
---|
[591] | 186 | #endif // __XIOS_CFile__ |
---|