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 |
---|
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 | std::vector<CField*> getAllFields(void) const; |
---|
60 | |
---|
61 | std::vector<CField* > getEnabledFields(int default_outputlevel = 5, |
---|
62 | int default_level = 1, |
---|
63 | bool default_enabled = true); |
---|
64 | |
---|
65 | public : |
---|
66 | |
---|
67 | /// Mutateurs /// |
---|
68 | void setVirtualFieldGroup(CFieldGroup* newVFieldGroup); |
---|
69 | void setVirtualFieldGroup(void); |
---|
70 | |
---|
71 | void createHeader(void); |
---|
72 | void close(void) ; |
---|
73 | |
---|
74 | /// Traitements /// |
---|
75 | virtual void solveDescInheritance(const CAttributeMap * const parent = 0); |
---|
76 | void solveFieldRefInheritance(void); |
---|
77 | void solveEFGridRef(void); |
---|
78 | void solveEFOperation(void); |
---|
79 | |
---|
80 | /// Destructeur /// |
---|
81 | virtual ~CFile(void); |
---|
82 | |
---|
83 | /// Autres /// |
---|
84 | virtual void parse(xml::CXMLNode & node); |
---|
85 | virtual StdString toString(void) const; |
---|
86 | |
---|
87 | // virtual void toBinary (StdOStream & os) const; |
---|
88 | // virtual void fromBinary(StdIStream & is); |
---|
89 | |
---|
90 | /// Accesseurs statiques /// |
---|
91 | static StdString GetName(void); |
---|
92 | static StdString GetDefName(void); |
---|
93 | |
---|
94 | static ENodeType GetType(void); |
---|
95 | |
---|
96 | bool allDomainEmpty ; |
---|
97 | CField* addField(const string& id="") ; |
---|
98 | CFieldGroup* addFieldGroup(const string& id="") ; |
---|
99 | void sendAddField(const string& id="") ; |
---|
100 | void sendAddFieldGroup(const string& id="") ; |
---|
101 | static void recvAddField(CEventServer& event) ; |
---|
102 | void recvAddField(CBufferIn& buffer) ; |
---|
103 | static void recvAddFieldGroup(CEventServer& event) ; |
---|
104 | void recvAddFieldGroup(CBufferIn& buffer) ; |
---|
105 | static bool dispatchEvent(CEventServer& event) ; |
---|
106 | bool isSyncTime(void) ; |
---|
107 | bool checkSplit(void) ; |
---|
108 | bool checkSync(void) ; |
---|
109 | void checkFile(void) ; |
---|
110 | void initFile(void) ; |
---|
111 | CDate* lastSync ; |
---|
112 | CDate* lastSplit ; |
---|
113 | CDuration syncFreq ; |
---|
114 | CDuration splitFreq ; |
---|
115 | CDuration outputFreq ; |
---|
116 | int nbDomain ; |
---|
117 | bool isOpen ; |
---|
118 | MPI_Comm fileComm ; |
---|
119 | private : |
---|
120 | |
---|
121 | /// Propriétés privées /// |
---|
122 | CFieldGroup* vFieldGroup; |
---|
123 | boost::shared_ptr<CDataOutput> data_out; |
---|
124 | std::vector<CField*> enabledFields; |
---|
125 | |
---|
126 | }; // class CFile |
---|
127 | |
---|
128 | ///-------------------------------------------------------------- |
---|
129 | |
---|
130 | // Declare/Define CFileGroup and CFileDefinition |
---|
131 | DECLARE_GROUP(CFile); |
---|
132 | |
---|
133 | ///-------------------------------------------------------------- |
---|
134 | |
---|
135 | } // namespace xios |
---|
136 | |
---|
137 | #endif // __XMLIO_CFile__ |
---|