summaryrefslogtreecommitdiff
path: root/TAO/tao/Interceptor.h
blob: 5fc085863d46ee2596a7721fcb94fa30df2f9a11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
// This may look like C, but it's really -*- C++ -*-
// $Id$

// ============================================================================
//
// = LIBRARY
//    TAO
//
// = FILENAME
//    Interceptor.h
//
// = DESCRIPTION
//     This file contains two helper classes to simplify the support of
//     interceptors in tao_idl generated code.  All the helper classes
//     implementations are in Interceptor.i file.
//
//     A series of TAO_INTERCEPTOR* macros are also defined in the file.
//     These macros allows us to disable/enable support of interceptors
//     easily.
//
//     I also put some default no-op implementation of the interceptor
//     servants.
//
// = AUTHOR
//     Nanbor Wang <nanbor@cs.wustl.edu>
//
// ============================================================================

#ifndef TAO_INTERCEPTOR_H
#define TAO_INTERCEPTOR_H

#include "tao/InterceptorS.h"

#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

#if defined (TAO_HAS_INTERCEPTORS)
# define TAO_INTERCEPTOR(X) X
# define TAO_INTERCEPTOR_CHECK ACE_TRY_CHECK
# define TAO_INTERCEPTOR_CHECK_RETURN(X) ACE_TRY_CHECK
# define TAO_INTERCEPTOR_THROW(X) ACE_TRY_THROW(X)
# define TAO_INTERCEPTOR_THROW_RETURN(X,Y) ACE_TRY_THROW(X)
#else
# define TAO_INTERCEPTOR(X)
# define TAO_INTERCEPTOR_CHECK ACE_CHECK
# define TAO_INTERCEPTOR_CHECK_RETURN(X) ACE_CHECK_RETURN (X)
# define TAO_INTERCEPTOR_THROW(X) ACE_THROW(X)
# define TAO_INTERCEPTOR_THROW_RETURN(X,Y) ACE_THROW_RETURN(X,Y)
#endif /* TAO_HAS_INTERCEPTORS */

#if defined (TAO_HAS_INTERCEPTORS)
class TAO_Export TAO_ClientRequestInterceptor_Adapter
{
  // = TITLE
  //   TAO_ClientRequestInterceptor_Adapter
  //
  // = DESCRIPTION
  //   A convenient helper class to invoke the client-side request
  //   interceptor(s) in tao_idl generated code.  Currently, TAO only
  //   supports registerring of one interceptor.  The class will only
  //   invoke the interceptor if there's one.
  //
  //   In the future, when we extend TAO's interceptor registering
  //   mechanism, this class will be modified to invoke several
  //   interceptors in series.
public:
  TAO_ClientRequestInterceptor_Adapter
    (PortableInterceptor::ClientRequestInterceptor_ptr interceptor);

  ~TAO_ClientRequestInterceptor_Adapter (void);

  void preinvoke (CORBA::ULong,
                  CORBA::Boolean,
                  CORBA::Object_ptr,
                  const char *,
                  IOP::ServiceContextList &,
                  CORBA::NVList_ptr &,
                  PortableInterceptor::Cookies &,
                  CORBA::Environment &);

  void postinvoke (CORBA::ULong,
                   CORBA::Boolean,
                   CORBA::Object_ptr,
                   const char *,
                   IOP::ServiceContextList &,
                   CORBA::NVList_ptr &,
                   PortableInterceptor::Cookies &,
                   CORBA::Environment &);

  void exception_occurred (CORBA::ULong,
                           CORBA::Boolean,
                           CORBA::Object_ptr,
                           const char *,
                           //IOP::ServiceContextList &,
                           //CORBA::Exception_ptr &,
                           PortableInterceptor::Cookies &,
                           CORBA::Environment &);

private:
  PortableInterceptor::ClientRequestInterceptor_var interceptor_;
};

class TAO_Export TAO_ServerRequestInterceptor_Adapter
{
  // = TITLE
  //   TAO_ServerRequestInterceptor_Adapter
  //
  // = DESCRIPTION
  //   A convenient helper class to invoke the server-side request
  //   interceptor(s) in tao_idl generated code.  Currently, TAO only
  //   supports registerring of one interceptor.  The class will only
  //   invoke the interceptor if there's one.
  //
  //   In the future, when we extend TAO's interceptor registering
  //   mechanism, this class will be modified to invoke several
  //   interceptors in series.
public:
  TAO_ServerRequestInterceptor_Adapter
    (PortableInterceptor::ServerRequestInterceptor_ptr interceptor);

  ~TAO_ServerRequestInterceptor_Adapter (void);

  void preinvoke (CORBA::ULong,
                  CORBA::Boolean,
                  CORBA::Object_ptr,
                  const char *,
                  IOP::ServiceContextList &,
                  CORBA::NVList_ptr &,
                  PortableInterceptor::Cookies &,
                  CORBA::Environment &);

  void postinvoke (CORBA::ULong,
                   CORBA::Boolean,
                   CORBA::Object_ptr,
                   const char *,
                   IOP::ServiceContextList &,
                   CORBA::NVList_ptr &,
                   PortableInterceptor::Cookies &,
                   CORBA::Environment &);

  void exception_occurred (CORBA::ULong,
                           CORBA::Boolean,
                           CORBA::Object_ptr,
                           const char *,
                           //IOP::ServiceContextList &,
                           //CORBA::Exception_ptr &,
                           PortableInterceptor::Cookies &,
                           CORBA::Environment &);

private:
  PortableInterceptor::ServerRequestInterceptor_var interceptor_;
};
#endif /* TAO_HAS_INTERCEPTORS */

#if defined (__ACE_INLINE__)
#include "tao/Interceptor.i"
#endif /* defined INLINE */

#endif /* TAO_INTERCEPTOR_H */