1 | #ifndef __XMLIO_CFile__ |
---|
2 | #define __XMLIO_CFile__ |
---|
3 | |
---|
4 | /// xios headers /// |
---|
5 | #include "xmlioserver_spl.hpp" |
---|
6 | #include "field.hpp" |
---|
7 | #include "data_output.hpp" |
---|
8 | #include "declare_group.hpp" |
---|
9 | #include "date.hpp" |
---|
10 | #include "attribute_enum.hpp" |
---|
11 | #include "attribute_enum_impl.hpp" |
---|
12 | #include "mpi.hpp" |
---|
13 | |
---|
14 | |
---|
15 | |
---|
16 | namespace xios { |
---|
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; |
---|
40 | |
---|
41 | public : |
---|
42 | enum EEventId |
---|
43 | { |
---|
44 | EVENT_ID_ADD_FIELD=0,EVENT_ID_ADD_FIELD_GROUP, EVENT_ID_ADD_VARIABLE,EVENT_ID_ADD_VARIABLE_GROUP |
---|
45 | } ; |
---|
46 | |
---|
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 /// |
---|
57 | boost::shared_ptr<CDataOutput> getDataOutput(void) const; |
---|
58 | CFieldGroup* getVirtualFieldGroup(void) const; |
---|
59 | CVariableGroup* getVirtualVariableGroup(void) const; |
---|
60 | std::vector<CField*> getAllFields(void) const; |
---|
61 | std::vector<CVariable*> getAllVariables(void) const; |
---|
62 | |
---|
63 | std::vector<CField* > getEnabledFields(int default_outputlevel = 5, |
---|
64 | int default_level = 1, |
---|
65 | bool default_enabled = true); |
---|
66 | |
---|
67 | public : |
---|
68 | |
---|
69 | /// Mutateurs /// |
---|
70 | void setVirtualFieldGroup(CFieldGroup* newVFieldGroup); |
---|
71 | void setVirtualFieldGroup(void); |
---|
72 | void setVirtualVariableGroup(CVariableGroup* newVVariableGroup); |
---|
73 | void setVirtualVariableGroup(void); |
---|
74 | void processEnabledFile(void) ; |
---|
75 | void processEnabledFields(void) ; |
---|
76 | void createHeader(void); |
---|
77 | void close(void) ; |
---|
78 | |
---|
79 | /// Traitements /// |
---|
80 | virtual void solveDescInheritance(bool apply, const CAttributeMap * const parent = 0); |
---|
81 | void solveFieldRefInheritance(bool apply); |
---|
82 | void solveEFGridRef(void); |
---|
83 | void solveEFOperation(void); |
---|
84 | void solveEFExpression(void); |
---|
85 | |
---|
86 | /// Destructeur /// |
---|
87 | virtual ~CFile(void); |
---|
88 | |
---|
89 | /// Autres /// |
---|
90 | virtual void parse(xml::CXMLNode & node); |
---|
91 | virtual StdString toString(void) const; |
---|
92 | |
---|
93 | // virtual void toBinary (StdOStream & os) const; |
---|
94 | // virtual void fromBinary(StdIStream & is); |
---|
95 | |
---|
96 | /// Accesseurs statiques /// |
---|
97 | static StdString GetName(void); |
---|
98 | static StdString GetDefName(void); |
---|
99 | |
---|
100 | static ENodeType GetType(void); |
---|
101 | |
---|
102 | bool allDomainEmpty ; |
---|
103 | CField* addField(const string& id="") ; |
---|
104 | CFieldGroup* addFieldGroup(const string& id="") ; |
---|
105 | CVariable* addVariable(const string& id="") ; |
---|
106 | CVariableGroup* addVariableGroup(const string& id="") ; |
---|
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) ; |
---|
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) ; |
---|
120 | static bool dispatchEvent(CEventServer& event) ; |
---|
121 | |
---|
122 | bool isSyncTime(void) ; |
---|
123 | bool checkSplit(void) ; |
---|
124 | bool checkSync(void) ; |
---|
125 | void checkFile(void) ; |
---|
126 | void initFile(void) ; |
---|
127 | CDate* lastSync ; |
---|
128 | CDate* lastSplit ; |
---|
129 | CDuration syncFreq ; |
---|
130 | CDuration splitFreq ; |
---|
131 | CDuration outputFreq ; |
---|
132 | int nbAxis, nbDomains; |
---|
133 | bool isOpen ; |
---|
134 | MPI_Comm fileComm ; |
---|
135 | private : |
---|
136 | |
---|
137 | /// Propriétés privées /// |
---|
138 | CFieldGroup* vFieldGroup; |
---|
139 | CVariableGroup* vVariableGroup ; |
---|
140 | boost::shared_ptr<CDataOutput> data_out; |
---|
141 | std::vector<CField*> enabledFields; |
---|
142 | |
---|
143 | }; // class CFile |
---|
144 | |
---|
145 | ///-------------------------------------------------------------- |
---|
146 | |
---|
147 | // Declare/Define CFileGroup and CFileDefinition |
---|
148 | DECLARE_GROUP(CFile); |
---|
149 | |
---|
150 | ///-------------------------------------------------------------- |
---|
151 | |
---|
152 | } // namespace xios |
---|
153 | |
---|
154 | #endif // __XMLIO_CFile__ |
---|