source: XIOS/trunk/src/node/file.hpp @ 321

Last change on this file since 321 was 321, checked in by ymipsl, 12 years ago

Add splitting file functionality
new file attribut "split_freq" to put the frequency of splitting

YM

File size: 4.2 KB
Line 
1#ifndef __XMLIO_CFile__
2#define __XMLIO_CFile__
3
4/// xmlioserver 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
11
12
13namespace xmlioserver {
14namespace tree {
15   
16   /// ////////////////////// Déclarations ////////////////////// ///
17
18   class CFileGroup;
19   class CFileAttributes;
20   class CFile;
21
22   ///--------------------------------------------------------------
23
24   // Declare/Define CFileAttribute
25   BEGIN_DECLARE_ATTRIBUTE_MAP(CFile)
26#  include "file_attribute.conf"
27   END_DECLARE_ATTRIBUTE_MAP(CFile)
28
29   ///--------------------------------------------------------------
30
31   class CFile
32      : public CObjectTemplate<CFile>
33      , public CFileAttributes
34   {
35         /// typedef ///
36         typedef CObjectTemplate<CFile>   SuperClass;
37         typedef CFileAttributes SuperClassAttribute;
38     
39      public :
40         enum EEventId
41         {
42           EVENT_ID_ADD_FIELD=0,EVENT_ID_ADD_FIELD_GROUP
43         } ;
44         
45         typedef CFileAttributes RelAttributes;
46         typedef CFileGroup      RelGroup;
47
48         /// Constructeurs ///
49         CFile(void);
50         explicit CFile(const StdString & id);
51         CFile(const CFile & file);       // Not implemented yet.
52         CFile(const CFile * const file); // Not implemented yet.
53
54         /// Accesseurs ///
55         boost::shared_ptr<io::CDataOutput> getDataOutput(void) const;
56         boost::shared_ptr<CFieldGroup> getVirtualFieldGroup(void) const;
57         std::vector<boost::shared_ptr<CField> > getAllFields(void) const;
58
59         std::vector<boost::shared_ptr<CField> >
60            getEnabledFields(int default_outputlevel = 5,
61                             int default_level = 1,
62                             bool default_enabled = true);
63
64      public :
65
66         /// Mutateurs ///
67         void setVirtualFieldGroup(boost::shared_ptr<CFieldGroup> newVFieldGroup);
68         void setVirtualFieldGroup(void);
69
70         void createHeader(void);
71         void close(void) ;
72         
73         /// Traitements ///
74         virtual void solveDescInheritance(const CAttributeMap * const parent = 0);
75         void solveFieldRefInheritance(void);
76         void solveEFGridRef(void);
77         void solveEFOperation(void);
78
79         /// Destructeur ///
80         virtual ~CFile(void);
81
82         /// Autres ///
83         virtual void parse(xml::CXMLNode & node);
84         virtual StdString toString(void) const;
85         
86         virtual void toBinary  (StdOStream & os) const;
87         virtual void fromBinary(StdIStream & is);
88
89         /// Accesseurs statiques ///
90         static StdString GetName(void);
91         static StdString GetDefName(void);
92         
93         static ENodeType GetType(void);
94         
95         bool AllDomainEmpty ;
96         shared_ptr<CField> addField(const string& id="") ;
97         shared_ptr<CFieldGroup> addFieldGroup(const string& id="") ;
98         void sendAddField(const string& id="") ;
99         void sendAddFieldGroup(const string& id="") ;
100         static void recvAddField(CEventServer& event) ;
101         void recvAddField(CBufferIn& buffer) ;
102         static void recvAddFieldGroup(CEventServer& event) ;
103         void recvAddFieldGroup(CBufferIn& buffer) ;
104         static bool dispatchEvent(CEventServer& event) ;
105         bool isSyncTime(void) ;
106         bool checkSplit(void) ;
107         bool checkSync(void) ;
108         void checkFile(void) ;
109         void initFile(void) ;
110         date::CDate* lastSync ;
111         date::CDate* lastSplit ;
112         date::CDuration syncFreq ;
113         date::CDuration splitFreq ;
114         date::CDuration outputFreq ;
115         int nbDomain ;
116         bool isOpen ;
117      private :
118
119         /// Propriétés privées ///
120         boost::shared_ptr<CFieldGroup> vFieldGroup;
121         boost::shared_ptr<io::CDataOutput> data_out;
122         std::vector<boost::shared_ptr<CField> > enabledFields;
123
124   }; // class CFile
125
126   ///--------------------------------------------------------------
127
128   // Declare/Define CFileGroup and CFileDefinition
129   DECLARE_GROUP(CFile);
130
131   ///--------------------------------------------------------------
132
133} // namespace tree
134} // namespace xmlioserver
135
136#endif // __XMLIO_CFile__
Note: See TracBrowser for help on using the repository browser.