3 // ===================================================================
5 * @file Transport_Selection_Guard.h
7 * @author Iliyan Jeliazkov <iliyan@ociweb.com>
9 // ===================================================================
11 #ifndef TAO_TRANSPORT_SELECTION_GUARD_H
12 #define TAO_TRANSPORT_SELECTION_GUARD_H
14 #include /**/ "ace/pre.h"
16 #include "tao/TAO_Export.h"
18 #if !defined (ACE_LACKS_PRAGMA_ONCE)
20 #endif /* ACE_LACKS_PRAGMA_ONCE */
22 #include "tao/orbconf.h"
24 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
26 // Forward declarations
33 * @class Transport_Selection_Guard
35 * @brief Used by the Transport Current feature to keep track of
36 * which Transport is currently active.
38 * Whenever a Transport is selected: during an upcall, or prior to a
39 * client invocation an instance of this class is created [on the
40 * stack, or as a member of another class] to keep track of the said
41 * Transport. The class implements the RAII idiom, which makes it
42 * possible to build a stack of these instances as the thread is
43 * doing nested upcalls or client invocations.
45 * It utilizes TAO_TSS_Resources::tsg_ member pointer to keep track
46 * of stack-linked Transport_Selection_Guard instances.
48 * If the Transport Current feature is disabled most methods are
49 * no-ops and add no overhead on the critical path.
53 * https://htmlpreview.github.io/?https://github.com/DOCGroup/ACE_TAO/blob/master/TAO/docs/transport_current/index.html
56 class TAO_Export Transport_Selection_Guard
59 static Transport_Selection_Guard
* current (TAO_ORB_Core
* core
,
64 Transport_Selection_Guard (TAO_Transport
* t
);
67 ~Transport_Selection_Guard ();
70 TAO_Transport
* operator-> () const
76 TAO_Transport
& operator* () const
82 TAO_Transport
* get () const
88 Transport_Selection_Guard
& set (TAO_Transport
* t
)
94 Transport_Selection_Guard
& operator=(const Transport_Selection_Guard
& rhs
) {
97 #if TAO_HAS_TRANSPORT_CURRENT == 1
99 #endif /* TAO_HAS_TRANSPORT_CURRENT == 1 */
106 Transport_Selection_Guard (const Transport_Selection_Guard
&) = delete;
108 #if TAO_HAS_TRANSPORT_CURRENT == 1
109 /// This is pointing to the guard that was active prior to
110 /// instantiating us.
111 Transport_Selection_Guard
* prev_
;
113 #endif /* TAO_HAS_TRANSPORT_CURRENT == 1 */
115 /// The "real" Transport, i.e. the one selected at present
116 TAO_Transport
* curr_
;
118 friend TAO_Export
bool
119 operator== (const Transport_Selection_Guard
& lhs
,
120 const TAO_Transport
* rhs
);
122 friend TAO_Export
bool
123 operator== (const TAO_Transport
* lhs
,
124 const Transport_Selection_Guard
& rhs
);
126 friend TAO_Export
bool
127 operator!= (const Transport_Selection_Guard
& lhs
,
128 const TAO_Transport
* rhs
);
130 friend TAO_Export
bool
131 operator!= (const TAO_Transport
* lhs
,
132 const Transport_Selection_Guard
& rhs
);
134 template <class U
> inline friend bool
135 operator== (const Transport_Selection_Guard
& lhs
,
138 return lhs
.curr_
== rhs
;
141 template <class U
> inline friend bool
142 operator== (const U
* lhs
,
143 const Transport_Selection_Guard
& rhs
)
145 return lhs
== rhs
.curr_
;
148 template <class U
> inline friend bool
149 operator!= (const Transport_Selection_Guard
& lhs
,
152 return lhs
.curr_
!= rhs
;
155 template <class U
> inline friend bool
156 operator!= (const U
* lhs
,
157 const Transport_Selection_Guard
& rhs
)
159 return lhs
!= rhs
.curr_
;
164 operator== (const Transport_Selection_Guard
& lhs
,
165 const TAO_Transport
* rhs
);
168 operator== (const TAO_Transport
* lhs
,
169 const Transport_Selection_Guard
& rhs
);
172 operator!= (const Transport_Selection_Guard
& lhs
,
173 const TAO_Transport
* rhs
);
176 operator!= (const TAO_Transport
* lhs
,
177 const Transport_Selection_Guard
& rhs
);
178 } /* namespace TAO */
180 TAO_END_VERSIONED_NAMESPACE_DECL
182 #include /**/ "ace/post.h"
184 #endif /* TAO_TRANSPORT_SELECTION_GUARD_H */