[219] | 1 | #ifndef __XMLIO_CFile__ |
---|
| 2 | #define __XMLIO_CFile__ |
---|
| 3 | |
---|
[335] | 4 | /// xios headers /// |
---|
[219] | 5 | #include "xmlioserver_spl.hpp" |
---|
| 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 { |
---|
[219] | 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 | class CFile |
---|
| 34 | : public CObjectTemplate<CFile> |
---|
| 35 | , public CFileAttributes |
---|
| 36 | { |
---|
| 37 | /// typedef /// |
---|
| 38 | typedef CObjectTemplate<CFile> SuperClass; |
---|
| 39 | typedef CFileAttributes SuperClassAttribute; |
---|
[300] | 40 | |
---|
[219] | 41 | public : |
---|
[300] | 42 | enum EEventId |
---|
| 43 | { |
---|
[472] | 44 | EVENT_ID_ADD_FIELD=0,EVENT_ID_ADD_FIELD_GROUP, EVENT_ID_ADD_VARIABLE,EVENT_ID_ADD_VARIABLE_GROUP |
---|
[300] | 45 | } ; |
---|
| 46 | |
---|
[219] | 47 | typedef CFileAttributes RelAttributes; |
---|
| 48 | typedef CFileGroup RelGroup; |
---|
| 49 | |
---|
| 50 | /// Constructeurs /// |
---|
| 51 | CFile(void); |
---|
| 52 | explicit CFile(const StdString & id); |
---|
| 53 | CFile(const CFile & file); // Not implemented yet. |
---|
| 54 | CFile(const CFile * const file); // Not implemented yet. |
---|
| 55 | |
---|
| 56 | /// Accesseurs /// |
---|
[337] | 57 | boost::shared_ptr<CDataOutput> getDataOutput(void) const; |
---|
[347] | 58 | CFieldGroup* getVirtualFieldGroup(void) const; |
---|
[472] | 59 | CVariableGroup* getVirtualVariableGroup(void) const; |
---|
[347] | 60 | std::vector<CField*> getAllFields(void) const; |
---|
[472] | 61 | std::vector<CVariable*> getAllVariables(void) const; |
---|
[219] | 62 | |
---|
[347] | 63 | std::vector<CField* > getEnabledFields(int default_outputlevel = 5, |
---|
| 64 | int default_level = 1, |
---|
| 65 | bool default_enabled = true); |
---|
[219] | 66 | |
---|
| 67 | public : |
---|
| 68 | |
---|
| 69 | /// Mutateurs /// |
---|
[347] | 70 | void setVirtualFieldGroup(CFieldGroup* newVFieldGroup); |
---|
[300] | 71 | void setVirtualFieldGroup(void); |
---|
[472] | 72 | void setVirtualVariableGroup(CVariableGroup* newVVariableGroup); |
---|
| 73 | void setVirtualVariableGroup(void); |
---|
[459] | 74 | void processEnabledFile(void) ; |
---|
| 75 | void processEnabledFields(void) ; |
---|
[300] | 76 | void createHeader(void); |
---|
[286] | 77 | void close(void) ; |
---|
| 78 | |
---|
[219] | 79 | /// Traitements /// |
---|
[445] | 80 | virtual void solveDescInheritance(bool apply, const CAttributeMap * const parent = 0); |
---|
| 81 | void solveFieldRefInheritance(bool apply); |
---|
[219] | 82 | void solveEFGridRef(void); |
---|
| 83 | void solveEFOperation(void); |
---|
[459] | 84 | void solveEFExpression(void); |
---|
[219] | 85 | |
---|
| 86 | /// Destructeur /// |
---|
| 87 | virtual ~CFile(void); |
---|
| 88 | |
---|
| 89 | /// Autres /// |
---|
| 90 | virtual void parse(xml::CXMLNode & node); |
---|
| 91 | virtual StdString toString(void) const; |
---|
| 92 | |
---|
[369] | 93 | // virtual void toBinary (StdOStream & os) const; |
---|
| 94 | // virtual void fromBinary(StdIStream & is); |
---|
[219] | 95 | |
---|
| 96 | /// Accesseurs statiques /// |
---|
| 97 | static StdString GetName(void); |
---|
| 98 | static StdString GetDefName(void); |
---|
| 99 | |
---|
| 100 | static ENodeType GetType(void); |
---|
[300] | 101 | |
---|
[379] | 102 | bool allDomainEmpty ; |
---|
[347] | 103 | CField* addField(const string& id="") ; |
---|
| 104 | CFieldGroup* addFieldGroup(const string& id="") ; |
---|
[472] | 105 | CVariable* addVariable(const string& id="") ; |
---|
| 106 | CVariableGroup* addVariableGroup(const string& id="") ; |
---|
[300] | 107 | void sendAddField(const string& id="") ; |
---|
| 108 | void sendAddFieldGroup(const string& id="") ; |
---|
| 109 | static void recvAddField(CEventServer& event) ; |
---|
| 110 | void recvAddField(CBufferIn& buffer) ; |
---|
| 111 | static void recvAddFieldGroup(CEventServer& event) ; |
---|
| 112 | void recvAddFieldGroup(CBufferIn& buffer) ; |
---|
[472] | 113 | |
---|
| 114 | void sendAddVariable(const string& id="") ; |
---|
| 115 | void sendAddVariableGroup(const string& id="") ; |
---|
| 116 | static void recvAddVariable(CEventServer& event) ; |
---|
| 117 | void recvAddVariable(CBufferIn& buffer) ; |
---|
| 118 | static void recvAddVariableGroup(CEventServer& event) ; |
---|
| 119 | void recvAddVariableGroup(CBufferIn& buffer) ; |
---|
[300] | 120 | static bool dispatchEvent(CEventServer& event) ; |
---|
[472] | 121 | |
---|
[318] | 122 | bool isSyncTime(void) ; |
---|
[321] | 123 | bool checkSplit(void) ; |
---|
| 124 | bool checkSync(void) ; |
---|
| 125 | void checkFile(void) ; |
---|
| 126 | void initFile(void) ; |
---|
[343] | 127 | CDate* lastSync ; |
---|
| 128 | CDate* lastSplit ; |
---|
| 129 | CDuration syncFreq ; |
---|
| 130 | CDuration splitFreq ; |
---|
| 131 | CDuration outputFreq ; |
---|
[318] | 132 | int nbDomain ; |
---|
[321] | 133 | bool isOpen ; |
---|
[379] | 134 | MPI_Comm fileComm ; |
---|
[219] | 135 | private : |
---|
| 136 | |
---|
| 137 | /// Propriétés privées /// |
---|
[347] | 138 | CFieldGroup* vFieldGroup; |
---|
[472] | 139 | CVariableGroup* vVariableGroup ; |
---|
[337] | 140 | boost::shared_ptr<CDataOutput> data_out; |
---|
[347] | 141 | std::vector<CField*> enabledFields; |
---|
[219] | 142 | |
---|
| 143 | }; // class CFile |
---|
| 144 | |
---|
| 145 | ///-------------------------------------------------------------- |
---|
| 146 | |
---|
| 147 | // Declare/Define CFileGroup and CFileDefinition |
---|
| 148 | DECLARE_GROUP(CFile); |
---|
| 149 | |
---|
| 150 | ///-------------------------------------------------------------- |
---|
| 151 | |
---|
[335] | 152 | } // namespace xios |
---|
[219] | 153 | |
---|
| 154 | #endif // __XMLIO_CFile__ |
---|