2 #include "tao/IFR_Client/IFR_BaseC.h"
3 #include "tao/TypeCodeFactory/TypeCodeFactory_Loader.h"
5 #include "ace/Get_Opt.h"
10 const ACE_TCHAR
*ior
= ACE_TEXT("file://test.ior");
13 parse_args (int argc
, ACE_TCHAR
*argv
[])
15 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:"));
18 while ((c
= get_opts ()) != -1)
22 ior
= get_opts
.opt_arg ();
28 ACE_ERROR_RETURN ((LM_ERROR
,
36 // Successful command line parsing.
40 template<typename T
> void dump (T
*); // Forward declaration.
44 perform_invocation (Test::Hello_ptr hello
,
45 CORBA::Any
const & the_any
)
47 // Execute more than once to help verify that mutable recursive
48 // TypeCode state is managed correctly.
49 for (unsigned int n
= 0; n
< 2; ++n
)
51 CORBA::Any_var my_any
=
52 hello
->get_any (the_any
);
55 if (!(my_any
.in () >>= my_foo
))
56 throw Test::Demarshaling_From_Any_Failed ();
58 CORBA::TypeCode_var the_tc
= the_any
.type ();
59 CORBA::TypeCode_var my_tc
= my_any
->type ();
61 CORBA::Boolean
const equal_tc
=
62 the_tc
->equal (my_tc
.in ());
65 throw Test::Recursive_Type_In_Any_Test_Failed ();
67 CORBA::Boolean
const equiv_tc
=
68 the_tc
->equivalent (my_tc
.in ());
71 throw Test::Recursive_Type_In_Any_Test_Failed ();
76 nested_recursive_struct_test (CORBA::ORB_ptr
/* orb */,
77 Test::Hello_ptr hello
)
80 "Executing nested recursive struct test\n"));
84 Test::NestedRecursiveStruct5 foo5
;
88 ::perform_invocation
<Test::NestedRecursiveStruct5
> (hello
, the_any
);
95 * @brief Test method invocation functor.
97 * Test method invocation functor.
100 struct Caller
: public std::unary_function
<T
, void>
103 Caller (CORBA::ORB_ptr o
, Test::Hello_ptr h
)
104 : orb (CORBA::ORB::_duplicate (o
))
105 , hello (Test::Hello::_duplicate (h
))
110 /// Function call operator overload.
111 void operator() (T f
)
118 catch (const CORBA::Exception
& ex
)
120 ex
._tao_print_exception ("Exception thrown:");
127 Test::Hello_var hello
;
132 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
137 CORBA::ORB_init (argc
, argv
);
139 if (parse_args (argc
, argv
) != 0)
142 CORBA::Object_var tmp
=
143 orb
->string_to_object(ior
);
145 Test::Hello_var hello
=
146 Test::Hello::_narrow(tmp
.in ());
148 if (CORBA::is_nil (hello
.in ()))
150 ACE_ERROR_RETURN ((LM_DEBUG
,
151 "Nil Test::Hello reference <%s>\n",
156 typedef void (*test_func
) (CORBA::ORB_ptr
,
159 static test_func
const tests
[] =
161 nested_recursive_struct_test
164 static size_t const test_count
= sizeof (tests
) / sizeof (test_func
);
166 // Have some fun with the STL. :-)
167 Caller
<test_func
> c
=
168 std::for_each (tests
,
170 Caller
<test_func
> (orb
.in (),
174 throw Test::Recursive_Type_In_Any_Test_Failed ();
180 catch (const CORBA::Exception
& ex
)
182 ex
._tao_print_exception ("Exception caught:");