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

Last change on this file since 459 was 459, checked in by ymipsl, 10 years ago

Add new parsing expression functionnalities
(modified files)

YM

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