2 #include "ace/Get_Opt.h"
4 const ACE_TCHAR
*ior
= ACE_TEXT("file://test.ior");
7 parse_args (int argc
, ACE_TCHAR
*argv
[])
9 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:"));
12 while ((c
= get_opts ()) != -1)
16 ior
= get_opts
.optarg
;
21 ACE_ERROR_RETURN ((LM_ERROR
,
28 // Indicates successful parsing of the command line
33 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
37 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) client - test started.\n"));
40 CORBA::ORB_init (argc
, argv
);
42 if (parse_args (argc
, argv
) != 0)
45 // Create and register factories.
47 OBV_AnyTest::VA_init
*va_factory
= 0;
48 ACE_NEW_RETURN (va_factory
,
50 1); // supplied by mapping
52 orb
->register_value_factory (va_factory
->tao_repository_id (),
54 va_factory
->_remove_ref (); // release ownership
57 OBV_AnyTest::VB_init
*vb_factory
= 0;
58 ACE_NEW_RETURN (vb_factory
,
60 1); // supplied by mapping
62 orb
->register_value_factory (vb_factory
->tao_repository_id (),
64 vb_factory
->_remove_ref (); // release ownership
68 OBV_AnyTest::VA_var va1
, va2
;
69 ACE_NEW_RETURN (va1
.inout (), OBV_OBV_AnyTest::VA
, 1);
70 ACE_NEW_RETURN (va2
.inout (), OBV_OBV_AnyTest::VA
, 1);
72 const CORBA::ULong magic
= 3145;
79 // Test both copying and non-copying version of operator<<=
82 OBV_AnyTest::VA
*pva
= va2
._retn();
85 OBV_AnyTest::VA
* dst
= 0;
87 if (!(a1
>>= dst
) || dst
->id () != magic
)
89 ACE_ERROR_RETURN ((LM_DEBUG
,
90 "(%P|%t) client - test failed.\n"),
94 if (!(a2
>>= dst
) || dst
->id () != magic
)
96 ACE_ERROR_RETURN ((LM_DEBUG
,
97 "(%P|%t) client - test failed.\n"),
102 // It should be possible to extract to a base type
103 OBV_AnyTest::VB_var vb1
;
104 ACE_NEW_RETURN (vb1
.inout (), OBV_OBV_AnyTest::VB
, 1);
108 CORBA::ValueBase_var target
;
109 if (!(a1
>>= CORBA::Any::to_value(target
.out())))
111 ACE_ERROR_RETURN ((LM_DEBUG
,
112 "(%P|%t) client - base extraction test failed.\n"),
115 dst
= OBV_AnyTest::VA::_downcast(target
.in());
116 if (dst
== 0 || dst
->id() != magic
)
118 ACE_ERROR_RETURN ((LM_DEBUG
,
119 "(%P|%t) client - base extraction test failed.\n"),
124 // Now do remote test
126 CORBA::Object_var tmp
=
127 orb
->string_to_object(ior
);
129 OBV_AnyTest::Test_var test
=
130 OBV_AnyTest::Test::_narrow(tmp
.in ());
132 if (CORBA::is_nil (test
.in ()))
134 ACE_ERROR_RETURN ((LM_DEBUG
,
135 "Nil OBV_AnyTest::Test reference <%s>\n",
142 CORBA::Any_var result
= test
->get_something (
145 if (!(result
.inout () >>= dst
) || dst
->id () != magic
)
147 ACE_ERROR_RETURN ((LM_DEBUG
,
148 "(%P|%t) client - test 1 failed.\n"),
153 OBV_AnyTest::VB
* dst_vb
= 0;
154 result
= test
->get_something (
157 if (!(result
.inout () >>= dst_vb
) || dst_vb
->id () != magic
)
159 ACE_ERROR_RETURN ((LM_DEBUG
,
160 "(%P|%t) client - test 2 failed.\n"),
164 // STEP 3. A sanity check demonstrating base-type pointer to
165 // derived type allowed.
166 OBV_AnyTest::VA_var dst_va
= test
->get_vb();
167 if (dst_va
->id () != magic
)
169 ACE_ERROR_RETURN ((LM_DEBUG
,
170 "(%P|%t) client - test 3 failed.\n"),
174 #if !defined (TAO_HAS_OPTIMIZED_VALUETYPE_MARSHALING)
175 // @@ There's still a problem here with the optimized valuetype
176 // marshaling and passing values through anys. The problem is
177 // that while the Any in fact contains all of the required type
178 // information, there is no way to share that with the
179 // ValueBase::_tao_unmarshal_pre() which needs the type info in
180 // order to select the appropriate value factory.
182 // STEP 4. get a VB, but extract to a VA*.
183 result
= test
->get_something (
186 if (!(result
.inout () >>= CORBA::Any::to_value(target
.out())))
188 ACE_ERROR_RETURN ((LM_DEBUG
,
189 "(%P|%t) client - test 4 extraction failed.\n"),
192 dst_va
= OBV_AnyTest::VA::_downcast(target
._retn());
193 if (dst_va
== 0 || dst_va
->id() != magic
)
195 ACE_ERROR_RETURN ((LM_DEBUG
,
196 "(%P|%t) client - test 4 failed.\n"),
199 #endif /* TAO_HAS_OPTIMIZED_VALUETYPE_MARSHALING */
205 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) client - test finished.\n"));
207 catch (const CORBA::Exception
& ex
)
209 ex
._tao_print_exception ("Exception caught in client:");