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
|
// $Id$
#ifndef TAO_OBJECT_T_C
#define TAO_OBJECT_T_C
#include "Object_T.h"
#include "Stub.h"
ACE_RCSID (tao,
Object_T,
"$Id$")
namespace TAO
{
template<typename T>
T *
Narrow_Utils<T>::narrow (CORBA::Object_ptr obj,
const char *repo_id,
Proxy_Broker_Factory pbf
ACE_ENV_ARG_DECL)
{
if (CORBA::is_nil (obj))
{
return T::_nil ();
}
CORBA::Boolean is_it = obj->_is_a (repo_id
ACE_ENV_ARG_PARAMETER);
ACE_CHECK_RETURN (T::_nil ());
if (is_it == 0)
{
return T::_nil ();
}
return TAO::Narrow_Utils<T>::unchecked_narrow (obj,
repo_id,
pbf
ACE_ENV_ARG_PARAMETER);
}
template<typename T> T *
Narrow_Utils<T>::unchecked_narrow (CORBA::Object_ptr obj,
Proxy_Broker_Factory pbf)
{
ACE_DECLARE_NEW_CORBA_ENV;
T *proxy = 0;
ACE_TRY
{
proxy =
TAO::Narrow_Utils<T>::unchecked_narrow (obj,
0,
pbf
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
}
ACE_CATCHANY
{
// Swallow the exception
return 0;
}
ACE_ENDTRY;
ACE_CHECK_RETURN (proxy);
return proxy;
}
template<typename T> T *
Narrow_Utils<T>::unchecked_narrow (CORBA::Object_ptr obj,
const char *,
Proxy_Broker_Factory pbf
ACE_ENV_ARG_DECL)
{
if (CORBA::is_nil (obj))
{
return T::_nil ();
}
T_ptr proxy = Narrow_Utils<T>::lazy_evaluation (obj);
if (!CORBA::is_nil (proxy))
{
return proxy;
}
TAO_Stub* stub = obj->_stubobj ();
if (stub != 0)
{
stub->_incr_refcnt ();
}
bool collocated =
!CORBA::is_nil (stub->servant_orb_var ().ptr ())
&& stub->optimize_collocation_objects ()
&& obj->_is_collocated ()
&& pbf != 0;
ACE_NEW_THROW_EX (proxy,
T (stub,
collocated ? 1 : 0,
obj->_servant ()),
CORBA::NO_MEMORY ());
return proxy;
}
template<typename T>
T *
Narrow_Utils<T>::lazy_evaluation (CORBA::Object_ptr obj)
{
T_ptr default_proxy = T::_nil ();
// Code for lazily evaluated IORs.
if (!obj->is_evaluated ())
{
ACE_NEW_RETURN (default_proxy,
T (obj->steal_ior (),
obj->orb_core ()),
T::_nil ());
}
return default_proxy;
}
}
#endif /* TAO_OBJECT_T_C */
|