source: XIOS/trunk/src/node/context.hpp @ 335

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

Change namespace xmlioserver -> xios

YM

File size: 5.0 KB
Line 
1#ifndef __XMLIO_CContext__
2#define __XMLIO_CContext__
3
4/// xios headers ///
5#include "xmlioserver_spl.hpp"
6#include "node_type.hpp"
7#include "calendar.hpp"
8
9#include "declare_group.hpp"
10//#include "context_client.hpp"
11//#include "context_server.hpp"
12#include "data_output.hpp"
13
14#include <mpi.h>
15
16namespace xios {
17namespace data {
18    class CDataTreatment;
19} // namespace tree
20} // namespace xios
21
22namespace xios {
23   class CContextClient ;
24   class CContextServer ;
25   
26namespace tree {
27   
28   /// ////////////////////// Déclarations ////////////////////// ///
29   class CContextGroup;
30   class CContextAttributes;
31   class CContext;
32 
33   ///--------------------------------------------------------------
34
35   // Declare/Define CFileAttribute
36   BEGIN_DECLARE_ATTRIBUTE_MAP(CContext)
37#  include "context_attribute.conf"
38   END_DECLARE_ATTRIBUTE_MAP(CContext)
39
40   ///--------------------------------------------------------------
41
42   class CContext
43      : public CObjectTemplate<CContext>
44      , public CContextAttributes
45   {
46         public :
47         enum EEventId
48         {
49           EVENT_ID_CLOSE_DEFINITION,EVENT_ID_UPDATE_CALENDAR,
50           EVENT_ID_CREATE_FILE_HEADER,EVENT_ID_CONTEXT_FINALIZE
51         } ;
52         
53         /// typedef ///
54         typedef CObjectTemplate<CContext>   SuperClass;
55         typedef CContextAttributes SuperClassAttribute;
56
57      public :
58
59         typedef CContextAttributes RelAttributes;
60         typedef CContext           RelGroup;
61
62         //---------------------------------------------------------
63
64      public :
65
66         /// Constructeurs ///
67         CContext(void);
68         explicit CContext(const StdString & id);
69         CContext(const CContext & context);       // Not implemented yet.
70         CContext(const CContext * const context); // Not implemented yet.
71
72         /// Destructeur ///
73         virtual ~CContext(void);
74
75         //---------------------------------------------------------
76
77      public :
78     
79         /// Mutateurs ///
80         void setCalendar(boost::shared_ptr<date::CCalendar> newCalendar);
81         void setDataTreatment(boost::shared_ptr<data::CDataTreatment> datat);
82     
83         /// Accesseurs ///
84         boost::shared_ptr<date::CCalendar>      getCalendar(void) const;
85         boost::shared_ptr<data::CDataTreatment> getDataTreatment(void) const;
86
87         /// Accesseurs statiques ///
88         static StdString GetName(void);
89         static StdString GetDefName(void);         
90         static ENodeType GetType(void);         
91
92         static boost::shared_ptr<CContextGroup> GetContextGroup(void);
93
94      public :
95
96         /// Traitements ///
97         virtual void solveDescInheritance(const CAttributeMap * const parent = 0);
98         void solveFieldRefInheritance(void);
99         void solveCalendar(void);
100
101         /// Autres méthodes statiques ///
102         static void ShowTree(StdOStream & out = std::clog);
103         static void CleanTree(void);
104
105         /// Test ///
106         virtual bool hasChild(void) const;
107
108         bool eventLoop(void) ;
109         bool serverLoop(void) ;
110         void clientLoop(void) ;
111         void initServer(MPI_Comm intraComm, MPI_Comm interComm) ;
112         void initClient(MPI_Comm intraComm, MPI_Comm interComm) ;
113         CContextServer* server ;
114         CContextClient* client ;
115         bool hasClient ;
116         bool hasServer ;
117         void finalize(void) ;
118         void closeDefinition(void) ;
119         void findAllEnabledFields(void);
120         void solveAllGridRef(void);
121         void solveAllOperation(void);
122         void solveAllInheritance(void) ;
123         void findEnabledFiles(void);
124         void closeAllFile(void) ;
125         void updateCalendar(int step) ;
126         void createFileHeader(void ) ;
127      // dispatch event
128         static bool dispatchEvent(CEventServer& event) ;
129         void sendCloseDefinition(void) ;
130         void sendUpdateCalendar(int step) ;
131         void sendCreateFileHeader(void) ;
132         static void recvUpdateCalendar(CEventServer& event) ;
133         void recvUpdateCalendar(CBufferIn& buffer) ;
134         static void recvCloseDefinition(CEventServer& event) ;
135         static void recvCreateFileHeader(CEventServer& event) ;
136         void recvCreateFileHeader(CBufferIn& buffer) ;
137         static shared_ptr<CContext> current(void) ;
138         
139      public :
140     
141         /// Autres ///
142         virtual void parse(xml::CXMLNode & node);
143
144         virtual StdString toString(void) const;
145         virtual void toBinary  (StdOStream & os) const;
146         virtual void fromBinary(StdIStream & is);
147         
148      public :
149     
150         boost::shared_ptr<date::CCalendar>      calendar;
151         boost::shared_ptr<data::CDataTreatment> datat;
152 
153         std::vector<boost::shared_ptr<CFile> > enabledFiles;
154
155
156   }; // class CContext
157
158   ///--------------------------------------------------------------
159
160   // Declare/Define CContextGroup and CContextDefinition
161   DECLARE_GROUP(CContext);
162
163   ///--------------------------------------------------------------
164
165} // namespace tree
166} // namespace xios
167
168#endif // __XMLIO_CContext__
Note: See TracBrowser for help on using the repository browser.