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 recursive_typecode_test (CORBA::ORB_ptr
/* orb */,
77 Test::Hello_ptr hello
)
80 "Executing recursive typecode test\n"));
84 Test::MyAttRefSequence test
;
87 attr
.attRefName
="attr";
88 attr
.attRefValue
.attrValue("value");
89 attr
.attRefQualifier
="atrQ1";
92 attr2
.attRefName
="attr2";
93 attr2
.attRefValue
.attrValue("value2");
94 attr2
.attRefQualifier
="atrQ2";
97 comp
.attRefName
="comp1";
98 comp
.attRefQualifier
="compQ";
100 Test::MyAttRef::MyAttRefValue::_compValue_seq
compSeq(1);
103 comp
.attRefValue
.compValue(compSeq
);
106 inti
.attRefName
="intval";
107 inti
.attRefValue
.intValue(0xAFFEAFFE);
116 ::perform_invocation
<Test::MyAttRefSequence
> (hello
, the_any
);
121 nested_recursive_typecode_test (CORBA::ORB_ptr
/* orb */,
122 Test::Hello_ptr hello
)
125 "Executing nested recursive typecode test\n"));
129 Test2::MyAttRefSeqStruct test
;
132 attr
.attRefName
="attr";
133 attr
.attRefValue
.attrValue("value");
134 attr
.attRefQualifier
="atrQ1";
136 Test::MyAttRef attr2
;
137 attr2
.attRefName
="attr2";
138 attr2
.attRefValue
.attrValue("value2");
139 attr2
.attRefQualifier
="atrQ2";
142 comp
.attRefName
="comp1";
143 comp
.attRefQualifier
="compQ";
145 Test::MyAttRef::MyAttRefValue::_compValue_seq
compSeq(1);
148 comp
.attRefValue
.compValue(compSeq
);
151 inti
.attRefName
="intval";
152 inti
.attRefValue
.intValue(0xAFFEAFFE);
154 test
.attRefSeq
.length(3);
155 test
.attRefSeq
[0] = comp
;
156 test
.attRefSeq
[1] = inti
;
157 test
.attRefSeq
[2] = attr
;
161 ::perform_invocation
<Test2::MyAttRefSeqStruct
> (hello
, the_any
);
168 * @brief Test method invocation functor.
170 * Test method invocation functor.
172 template <typename T
>
173 struct Caller
: public std::unary_function
<T
, void>
176 Caller (CORBA::ORB_ptr o
, Test::Hello_ptr h
)
177 : orb (CORBA::ORB::_duplicate (o
))
178 , hello (Test::Hello::_duplicate (h
))
183 /// Function call operator overload.
184 void operator() (T f
)
191 catch (const CORBA::Exception
& ex
)
193 ex
._tao_print_exception ("Exception thrown:");
200 Test::Hello_var hello
;
205 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
210 CORBA::ORB_init (argc
, argv
);
212 if (parse_args (argc
, argv
) != 0)
215 CORBA::Object_var tmp
=
216 orb
->string_to_object(ior
);
218 Test::Hello_var hello
=
219 Test::Hello::_narrow(tmp
.in ());
221 if (CORBA::is_nil (hello
.in ()))
223 ACE_ERROR_RETURN ((LM_DEBUG
,
224 "Nil Test::Hello reference <%s>\n",
229 typedef void (*test_func
) (CORBA::ORB_ptr
,
232 static test_func
const tests
[] =
234 recursive_typecode_test
,
235 nested_recursive_typecode_test
238 static size_t const test_count
= sizeof (tests
) / sizeof (test_func
);
240 // Have some fun with the STL. :-)
241 Caller
<test_func
> c
=
242 std::for_each (tests
,
244 Caller
<test_func
> (orb
.in (),
248 throw Test::Recursive_Type_In_Any_Test_Failed ();
254 catch (const CORBA::Exception
& ex
)
256 ex
._tao_print_exception ("Exception caught:");