OSDN Git Service

FIRST REPOSITORY
[eos/hostdependOTHERS.git] / I386LINUX / util / I386LINUX / include / mico / intercept.h
1 // -*- c++ -*-
2 /*
3  *  MICO --- an Open Source CORBA implementation
4  *  Copyright (c) 1997-2001 by The Mico Team
5  *
6  *  This library is free software; you can redistribute it and/or
7  *  modify it under the terms of the GNU Library General Public
8  *  License as published by the Free Software Foundation; either
9  *  version 2 of the License, or (at your option) any later version.
10  *
11  *  This library is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  *  Library General Public License for more details.
15  *
16  *  You should have received a copy of the GNU Library General Public
17  *  License along with this library; if not, write to the Free
18  *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  *
20  *  For more information, visit the MICO Home Page at
21  *  http://www.mico.org/
22  */
23
24 #ifndef __mico_intercept_h__
25 #define __mico_intercept_h__
26
27 // mapped by hand from intercept.idl
28
29 // workaround for flaw in X11 headers
30 #undef Status
31
32 namespace Interceptor {
33     enum Status {
34         INVOKE_CONTINUE = 0,
35         INVOKE_ABORT,
36         INVOKE_RETRY,
37         INVOKE_BREAK
38     };
39
40
41     class Root;
42     typedef Root *Root_ptr;
43     typedef ObjVar<Root> Root_var;
44
45     class Root : public CORBA::ServerlessObject {
46     public:
47         typedef CORBA::ULong Priority;
48         //const Priority LowestPriority = 0;
49         //const Priority HighestPriority = 0x7fffffffL;
50         enum {
51             LowestPriority = 0,
52             HighestPriority = 0x7fffffff
53         };
54     private:
55         Priority _prio;
56         CORBA::Boolean _is_active;
57     public:
58         Root ();
59         Root (Priority p);
60         virtual ~Root ();
61
62         virtual const char *_repoid() const;
63         static Root_ptr _nil ()
64         {
65             return 0;
66         }
67         static Root_ptr _duplicate (Root_ptr o)
68         {
69             if (o)
70                 o->_ref();
71             return o;
72         }
73         static Root_ptr _narrow (Root_ptr);
74
75         Priority prio();
76
77         virtual void activate (Priority p);
78         virtual void deactivate ();
79         CORBA::Boolean is_active ();
80     };
81
82     
83     class Context;
84     typedef Context *Context_ptr;
85     typedef ObjVar<Context> Context_var;
86     typedef ObjOut<Context> Context_out;
87
88     class Context : public CORBA::ServerlessObject {
89     public:
90         Context ();
91         virtual ~Context ();
92
93         virtual const char *_repoid() const;
94         static Context_ptr _nil ()
95         {
96             return 0;
97         }
98         static Context_ptr _duplicate (Context_ptr o)
99         {
100             if (o)
101                 o->_ref();
102             return o;
103         }
104         static Context_ptr _narrow (Context_ptr);
105
106         void destroy ();
107     };
108
109     
110     typedef IOP::ServiceID ServiceID;
111     typedef SequenceTmpl<CORBA::Octet,MICO_TID_OCTET> ContextData;
112     typedef TSeqVar<ContextData> ContextData_var;
113
114
115     class LWRootRequest;
116     typedef LWRootRequest *LWRootRequest_ptr;
117     typedef ObjVar<LWRootRequest> LWRootRequest_var;
118     typedef ObjOut<LWRootRequest> LWRootRequest_out;
119
120     class LWRootRequest : public CORBA::ServerlessObject {
121     private:
122         typedef std::map<Root_ptr, Context_var, std::less<Root_ptr> > CtxMap;
123         CtxMap _ctxs;
124         IOP::ServiceContextList &_svc;
125         CORBA::String_var &_op;
126         CORBA::Object_var &_obj;
127     public:
128         LWRootRequest (CORBA::Object_var &obj,
129                        CORBA::String_var &op,
130                        IOP::ServiceContextList &svc);
131         virtual ~LWRootRequest ();
132
133         virtual const char *_repoid() const;
134         static LWRootRequest_ptr _nil ()
135         {
136             return 0;
137         }
138         static LWRootRequest_ptr _duplicate (LWRootRequest_ptr o)
139         {
140             if (o)
141                 o->_ref();
142             return o;
143         }
144         static LWRootRequest_ptr _narrow (LWRootRequest_ptr);
145
146         CORBA::Object_ptr target();
147         void target (CORBA::Object_ptr);
148         CORBA::Identifier operation();
149         void operation (const CORBA::Identifier);
150
151         void set_service_context (ServiceID id,
152                                   CORBA::Long flags,
153                                   const ContextData &d);
154         ContextData *get_service_context (ServiceID id,
155                                           CORBA::Long flags);
156         void remove_service_context (ServiceID id);
157         CORBA::Boolean has_service_context (ServiceID id);
158
159         void set_context (Root_ptr interceptor, Context_ptr ctx);
160         Context_ptr get_context (Root_ptr interceptor);
161     };
162
163     
164     class LWRequest;
165     typedef LWRequest *LWRequest_ptr;
166     typedef ObjVar<LWRequest> LWRequest_var;
167     typedef ObjOut<LWRequest> LWRequest_out;
168
169     class LWRequest : public LWRootRequest {
170         CORBA::Request_ptr _req;
171     public:
172         LWRequest (CORBA::Object_var &obj,
173                    CORBA::String_var &op,
174                    IOP::ServiceContextList &svc,
175                    CORBA::Request_ptr req);
176         virtual ~LWRequest ();
177
178         virtual const char *_repoid() const;
179         static LWRequest_ptr _nil ()
180         {
181             return 0;
182         }
183         static LWRequest_ptr _duplicate (LWRequest_ptr o)
184         {
185             if (o)
186                 o->_ref();
187             return o;
188         }
189         static LWRequest_ptr _narrow (LWRootRequest_ptr);
190
191         CORBA::Request_ptr request ();
192     };
193
194     
195     class LWServerRequest;
196     typedef LWServerRequest *LWServerRequest_ptr;
197     typedef ObjVar<LWServerRequest> LWServerRequest_var;
198     typedef ObjOut<LWServerRequest> LWServerRequest_out;
199
200     class LWServerRequest : public LWRootRequest {
201         CORBA::ServerRequest_ptr _req;
202         CORBA::Object_var _obj;
203         CORBA::String_var _op;
204     public:
205         LWServerRequest (CORBA::Object_ptr obj,
206                          const char *op,
207                          IOP::ServiceContextList &svc,
208                          CORBA::ServerRequest_ptr req);
209         virtual ~LWServerRequest ();
210
211         virtual const char *_repoid() const;
212         static LWServerRequest_ptr _nil ()
213         {
214             return 0;
215         }
216         static LWServerRequest_ptr _duplicate (LWServerRequest_ptr o)
217         {
218             if (o)
219                 o->_ref();
220             return o;
221         }
222         static LWServerRequest_ptr _narrow (LWRootRequest_ptr);
223
224         CORBA::ServerRequest_ptr request ();
225     };
226
227
228     class ClientInterceptor;
229     typedef ClientInterceptor *ClientInterceptor_ptr;
230     typedef ObjVar<ClientInterceptor> ClientInterceptor_var;
231     typedef ObjOut<ClientInterceptor> ClientInterceptor_out;
232
233     class ClientInterceptor : public Root {
234         static std::list<ClientInterceptor_ptr> *_interceptors;
235         static std::list<ClientInterceptor_ptr> &_ics ();
236     public:
237         ClientInterceptor ();
238         ClientInterceptor (Priority p);
239         virtual ~ClientInterceptor ();
240
241         virtual const char *_repoid() const;
242         static ClientInterceptor_ptr _nil ()
243         {
244             return 0;
245         }
246         static ClientInterceptor_ptr _duplicate (ClientInterceptor_ptr o)
247         {
248             if (o)
249                 o->_ref();
250             return o;
251         }
252         static ClientInterceptor_ptr _narrow (Root_ptr);
253
254         virtual Status initialize_request (LWRequest_ptr req,
255                                            CORBA::Environment_ptr env);
256         virtual Status after_marshal (LWRequest_ptr req,
257                                       CORBA::Environment_ptr env);
258         virtual Status output_message (CORBA::Buffer *buf,
259                                        CORBA::Environment_ptr env);
260         virtual Status input_message (CORBA::Buffer *buf,
261                                       CORBA::Environment_ptr env);
262         virtual Status before_unmarshal (LWRequest_ptr req,
263                                          CORBA::Environment_ptr env);
264         virtual Status finish_request (LWRequest_ptr req,
265                                        CORBA::Environment_ptr env);
266
267         // override Root:: methods
268         void activate (Priority p);
269         void deactivate ();
270
271         typedef Status (ClientInterceptor::*InterceptorMethod1) (
272             LWRequest_ptr,
273             CORBA::Environment_ptr);
274
275         typedef Status (ClientInterceptor::*InterceptorMethod2) (
276             CORBA::Buffer *,
277             CORBA::Environment_ptr);
278
279         static CORBA::Boolean _exec (
280             LWRequest_ptr,
281             CORBA::Environment_ptr,
282             InterceptorMethod1 m);
283
284         static CORBA::Boolean _exec (
285             CORBA::Buffer *,
286             CORBA::Environment_ptr,
287             InterceptorMethod2 m);
288
289         static CORBA::Boolean _exec_initialize_request (
290             LWRequest_ptr,
291             CORBA::Environment_ptr);
292
293         static CORBA::Boolean _exec_after_marshal (
294             LWRequest_ptr,
295             CORBA::Environment_ptr);
296
297         static CORBA::Boolean _exec_output_message (
298             CORBA::Buffer *,
299             CORBA::Environment_ptr);
300
301         static CORBA::Boolean _exec_input_message (
302             CORBA::Buffer *,
303             CORBA::Environment_ptr);
304
305         static CORBA::Boolean _exec_before_unmarshal (
306             LWRequest_ptr,
307             CORBA::Environment_ptr);
308
309         static CORBA::Boolean _exec_finish_request (
310             LWRequest_ptr,
311             CORBA::Environment_ptr);
312
313         static LWRequest_ptr _create_request (
314             CORBA::Object_var &obj,
315             CORBA::String_var &op,
316             IOP::ServiceContextList &svc,
317             CORBA::Request_ptr req);
318
319         static CORBA::Boolean _idle ()
320         { return _ics().size() == 0; }
321     };
322
323
324     class ServerInterceptor;
325     typedef ServerInterceptor *ServerInterceptor_ptr;
326     typedef ObjVar<ServerInterceptor> ServerInterceptor_var;
327     typedef ObjOut<ServerInterceptor> ServerInterceptor_out;
328
329     class ServerInterceptor : public Root {
330         static std::list<ServerInterceptor_ptr> *_interceptors;
331         static std::list<ServerInterceptor_ptr> &_ics ();
332     public:
333         ServerInterceptor ();
334         ServerInterceptor (Priority p);
335         virtual ~ServerInterceptor ();
336
337         virtual const char *_repoid() const;
338         static ServerInterceptor_ptr _nil ()
339         {
340             return 0;
341         }
342         static ServerInterceptor_ptr _duplicate (ServerInterceptor_ptr o)
343         {
344             if (o)
345                 o->_ref();
346             return o;
347         }
348         static ServerInterceptor_ptr _narrow (Root_ptr);
349
350         virtual Status input_message (CORBA::Buffer *buf,
351                                       CORBA::Environment_ptr env);
352         virtual Status initialize_request (LWServerRequest_ptr req,
353                                            CORBA::Environment_ptr env);
354         virtual Status after_unmarshal (LWServerRequest_ptr req,
355                                         CORBA::Environment_ptr env);
356         virtual Status before_marshal (LWServerRequest_ptr req,
357                                        CORBA::Environment_ptr env);
358         virtual Status finish_request (LWServerRequest_ptr req,
359                                        CORBA::Environment_ptr env);
360         virtual Status output_message (CORBA::Buffer *buf,
361                                        CORBA::Environment_ptr env);
362
363         // override Root:: methods
364         void activate (Priority p);
365         void deactivate ();
366
367         typedef Status (ServerInterceptor::*InterceptorMethod1) (
368             LWServerRequest_ptr,
369             CORBA::Environment_ptr);
370
371         typedef Status (ServerInterceptor::*InterceptorMethod2) (
372             CORBA::Buffer *,
373             CORBA::Environment_ptr);
374
375         static CORBA::Boolean _exec (
376             LWServerRequest_ptr,
377             CORBA::Environment_ptr,
378             InterceptorMethod1 m);
379
380         static CORBA::Boolean _exec (
381             CORBA::Buffer *,
382             CORBA::Environment_ptr,
383             InterceptorMethod2 m);
384
385         static CORBA::Boolean _exec_input_message (
386             CORBA::Buffer *,
387             CORBA::Environment_ptr);
388
389         static CORBA::Boolean _exec_initialize_request (
390             LWServerRequest_ptr,
391             CORBA::Environment_ptr env);
392
393         static CORBA::Boolean _exec_after_unmarshal (
394             LWServerRequest_ptr,
395             CORBA::Environment_ptr env);
396
397         static CORBA::Boolean _exec_before_marshal (
398             LWServerRequest_ptr,
399             CORBA::Environment_ptr env);
400
401         static CORBA::Boolean _exec_finish_request (
402             LWServerRequest_ptr,
403             CORBA::Environment_ptr env);
404
405         static CORBA::Boolean _exec_output_message (
406             CORBA::Buffer *,
407             CORBA::Environment_ptr);
408
409         static LWServerRequest_ptr _create_request (
410             CORBA::Object_ptr obj,
411             const char *op,
412             IOP::ServiceContextList &svc,
413             CORBA::ServerRequest_ptr req);
414
415         static CORBA::Boolean _idle ()
416         { return _ics().size() == 0; }
417     };
418
419     
420     class InitInterceptor;
421     typedef InitInterceptor *InitInterceptor_ptr;
422     typedef ObjVar<InitInterceptor> InitInterceptor_var;
423     typedef ObjOut<InitInterceptor> InitInterceptor_out;
424
425     class InitInterceptor : public Root {
426         static std::list<InitInterceptor_ptr> *_interceptors;
427         static std::list<InitInterceptor_ptr> &_ics ();
428     public:
429         InitInterceptor ();
430         InitInterceptor (Priority p);
431         virtual ~InitInterceptor ();
432
433         virtual const char *_repoid() const;
434         static InitInterceptor_ptr _nil ()
435         {
436             return 0;
437         }
438         static InitInterceptor_ptr _duplicate (InitInterceptor_ptr o)
439         {
440             if (o)
441                 o->_ref();
442             return o;
443         }
444         static InitInterceptor_ptr _narrow (Root_ptr);
445
446         virtual Status initialize (CORBA::ORB_ptr orb,
447                                    const char *id,
448                                    int &argc, char *argv[]);
449
450         // override Root:: methods
451         void activate (Priority p);
452         void deactivate ();
453
454         static CORBA::Boolean _exec_initialize (CORBA::ORB_ptr orb,
455                                                 const char *id,
456                                                 int &argc, char *argv[]);
457     };
458
459
460     class BOAInterceptor;
461     typedef BOAInterceptor *BOAInterceptor_ptr;
462     typedef ObjVar<BOAInterceptor> BOAInterceptor_var;
463     typedef ObjOut<BOAInterceptor> BOAInterceptor_out;
464
465     class BOAInterceptor : public Root {
466         static std::list<BOAInterceptor_ptr> *_interceptors;
467         static std::list<BOAInterceptor_ptr> &_ics ();
468     public:
469         BOAInterceptor ();
470         BOAInterceptor (Priority p);
471         virtual ~BOAInterceptor ();
472
473         virtual const char *_repoid() const;
474         static BOAInterceptor_ptr _nil ()
475         {
476             return 0;
477         }
478         static BOAInterceptor_ptr _duplicate (BOAInterceptor_ptr o)
479         {
480             if (o)
481                 o->_ref();
482             return o;
483         }
484         static BOAInterceptor_ptr _narrow (Root_ptr);
485
486         virtual Status restore (CORBA::Object_ptr obj);
487         virtual Status create (CORBA::Object_ptr obj);
488         virtual Status bind (const char *repoid,
489                              const CORBA::ORB::ObjectTag &);
490
491         // override Root:: methods
492         void activate (Priority p);
493         void deactivate ();
494
495         static CORBA::Boolean _exec_restore (CORBA::Object_ptr obj);
496         static CORBA::Boolean _exec_create (CORBA::Object_ptr obj);
497         static CORBA::Boolean _exec_bind (const char *repoid,
498                                           const CORBA::ORB::ObjectTag &);
499     };
500
501     class ConnInterceptor;
502     typedef ConnInterceptor *ConnInterceptor_ptr;
503     typedef ObjVar<ConnInterceptor> ConnInterceptor_var;
504     typedef ObjOut<ConnInterceptor> ConnInterceptor_out;
505
506     class ConnInterceptor : public Root {
507         static std::list<ConnInterceptor_ptr> *_interceptors;
508         static std::list<ConnInterceptor_ptr> &_ics ();
509     public:
510         ConnInterceptor ();
511         ConnInterceptor (Priority p);
512         virtual ~ConnInterceptor ();
513
514         virtual const char *_repoid() const;
515         static ConnInterceptor_ptr _nil ()
516         {
517             return 0;
518         }
519         static ConnInterceptor_ptr _duplicate (ConnInterceptor_ptr o)
520         {
521             if (o)
522                 o->_ref();
523             return o;
524         }
525         static ConnInterceptor_ptr _narrow (Root_ptr);
526
527         virtual Status client_connect (const char *addr);
528         virtual Status client_disconnect (const char *addr);
529
530         // override Root:: methods
531         void activate (Priority p);
532         void deactivate ();
533
534         static CORBA::Boolean _exec_client_connect (const char *addr);
535         static CORBA::Boolean _exec_client_disconnect (const char *addr);
536     };
537
538
539 #endif // __mico_intercept_h__