1 // -*- Mode: C++; -*-
2 // Package : omniORB
3 // callHandle.h Created on: 16/05/2001
4 // Author : Duncan Grisby (dpg1)
5 //
6 // Copyright (C) 2006-2013 Apasphere Ltd
7 // Copyright (C) 2001 AT&T Laboratories Cambridge
8 //
9 // This file is part of the omniORB library
10 //
11 // The omniORB library is free software; you can redistribute it and/or
12 // modify it under the terms of the GNU Lesser General Public
13 // License as published by the Free Software Foundation; either
14 // version 2.1 of the License, or (at your option) any later version.
15 //
16 // This library is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 // Lesser General Public License for more details.
20 //
21 // You should have received a copy of the GNU Lesser General Public
22 // License along with this library. If not, see http://www.gnu.org/licenses/
23 //
24 //
25 // Description:
26 //
27 // Call handle used during remote or in-process operation dispatch.
28
29 #ifndef __OMNIORB_CALLHANDLE_H__
30 #define __OMNIORB_CALLHANDLE_H__
31
32 #include <omniORB4/callDescriptor.h>
33 #include <omniORB4/IOP_S.h>
34
35 OMNI_NAMESPACE_BEGIN(omni)
36 class omniOrbPOA;
37 class giopConnection;
OMNI_NAMESPACE_END(omni)38 OMNI_NAMESPACE_END(omni)
39
40 class omniLocalIdentity;
41
42 class omniCallHandle {
43 public:
44
45 inline omniCallHandle(_OMNI_NS(IOP_S)* iop_s_, omni_thread* self_thread)
46 : pd_iop_s(iop_s_),
47 pd_call_desc(0),
48 pd_op(iop_s_->operation_name()),
49 pd_postinvoke_hook(0),
50 pd_poa(0),
51 pd_localId(0),
52 pd_mainthread_mu(0),
53 pd_self_thread(self_thread),
54 pd_try_direct(0)
55 {}
56
57 inline omniCallHandle(omniCallDescriptor* call_desc_,
58 _CORBA_Boolean try_direct_)
59 : pd_iop_s(0),
60 pd_call_desc(call_desc_),
61 pd_op(call_desc_->op()),
62 pd_postinvoke_hook(0),
63 pd_poa(0),
64 pd_localId(0),
65 pd_mainthread_mu(0),
66 pd_self_thread(0),
67 pd_try_direct(try_direct_)
68 {}
69
70 inline const char* operation_name() const { return pd_op; }
71 inline _OMNI_NS(IOP_S*) iop_s() const { return pd_iop_s; }
72 inline omniCallDescriptor* call_desc() const { return pd_call_desc; }
73 inline _CORBA_Boolean try_direct() const { return pd_try_direct; }
74
75 // Accessors for connection details. Return zero in the case of an
76 // in-process call.
77 _OMNI_NS(giopConnection)* connection();
78 const char* myaddress();
79 const char* peeraddress();
80 const char* peeridentity();
81 void* peerdetails();
82
83 // Call entry-point
84 void upcall(omniServant* servant, omniCallDescriptor& desc);
85
86 // Class PostInvokeHook is used to insert extra processing after the
87 // upcall is made but before the results are marshalled. It is used
88 // in ServantLocator dispatch.
89 class PostInvokeHook {
90 public:
91 virtual void postinvoke() = 0;
92 virtual ~PostInvokeHook();
93 };
94
95 inline void postinvoke_hook(PostInvokeHook* hook) {
96 pd_postinvoke_hook = hook;
97 }
98
99 void SkipRequestBody();
100 // SkipRequestBody is called if an exception occurs while
101 // unmarshalling arguments. It skips any remaining input data so the
102 // exception may be returned as soon as possible.
103
104 inline void poa(_OMNI_NS(omniOrbPOA)* poa_) { pd_poa = poa_; }
105 inline void localId(omniLocalIdentity* id) { pd_localId = id; }
106
107 inline void mainThread(omni_tracedmutex* mu, omni_tracedcondition* cond) {
108 pd_mainthread_mu = mu;
109 pd_mainthread_cond = cond;
110 }
111
112 // Accessors
113 inline PostInvokeHook* postinvoke_hook() { return pd_postinvoke_hook; }
114 inline _OMNI_NS(omniOrbPOA)* poa() { return pd_poa; }
115 inline omniLocalIdentity* localId() { return pd_localId; }
116 inline omni_tracedmutex* mainthread_mu() { return pd_mainthread_mu; }
117 inline omni_tracedcondition* mainthread_cond() { return pd_mainthread_cond; }
118
119 private:
120 _OMNI_NS(IOP_S)* pd_iop_s;
121 omniCallDescriptor* pd_call_desc;
122 const char* pd_op;
123 PostInvokeHook* pd_postinvoke_hook;
124 _OMNI_NS(omniOrbPOA)* pd_poa;
125 omniLocalIdentity* pd_localId;
126 omni_tracedmutex* pd_mainthread_mu;
127 omni_tracedcondition* pd_mainthread_cond;
128 omni_thread* pd_self_thread;
129 _CORBA_Boolean pd_try_direct;
130
131 private:
132 // Not implemented
133 omniCallHandle(const omniCallHandle&);
134 omniCallHandle& operator=(const omniCallHandle&);
135 };
136
137
138
139 #endif // __OMNIORB_CALLHANDLE_H__
140