3 #include "ace/Get_Opt.h"
4 #include "ace/OS_NS_string.h"
17 Ptest::init (int argc
, ACE_TCHAR
*argv
[])
21 this->orb_
= CORBA::ORB_init (argc
, argv
);
23 int retval
= this->parse_args (argc
, argv
);
28 CORBA::Object_var object
=
29 this->orb_
->resolve_initial_references ("InterfaceRepository");
31 if (CORBA::is_nil (object
.in ()))
35 "Null objref from resolve_initial_references\n"
40 CORBA::Repository::_narrow (object
.in ());
42 if (CORBA::is_nil (this->repo_
.in ()))
44 ACE_ERROR_RETURN ((LM_ERROR
,
45 "CORBA::Repository::_narrow failed\n"),
49 catch (const CORBA::Exception
& ex
)
51 ex
._tao_print_exception ("Ptest::init");
63 this->repo_
= CORBA::Repository::_nil ();
65 this->orb_
->destroy ();
67 this->orb_
= CORBA::ORB::_nil ();
69 catch (const CORBA::Exception
& ex
)
71 ex
._tao_print_exception ("Ptest::init");
82 if (this->query_
== 1)
91 catch (const CORBA::Exception
& ex
)
93 ex
._tao_print_exception ("Ptest::run");
101 Ptest::parse_args (int argc
,
104 ACE_Get_Opt
opts (argc
, argv
, ACE_TEXT("dq"));
107 while ((c
= opts ()) != -1)
110 case 'd': // debug flag
113 case 'q': // query toggle
118 ACE_ERROR_RETURN ((LM_ERROR
,
137 ACE_TEXT ("\n============== POPULATE ==============\n\n")
141 CORBA::StructMemberSeq
members (2);
143 members
[0].name
= CORBA::string_dup ("long_mem");
144 members
[0].type_def
= this->repo_
->get_primitive (CORBA::pk_long
);
145 members
[0].type
= members
[0].type_def
->type ();
147 members
[1].name
= CORBA::string_dup ("array_mem");
148 members
[1].type_def
= this->repo_
->create_array (5,
149 members
[0].type_def
.in ());
150 members
[1].type
= members
[1].type_def
->type ();
153 CORBA::StructDef_var svar
= this->repo_
->create_struct ("IDL:my_struct:1.0",
158 CORBA::EnumMemberSeq
def_members (2);
159 def_members
.length (2);
161 def_members
[0] = CORBA::string_dup ("ZERO");
162 def_members
[1] = CORBA::string_dup ("ONE");
164 CORBA::EnumDef_var e_def_var
= svar
->create_enum ("IDL:my_def_enum:1.0",
177 ACE_TEXT ("\n============== QUERY ==============\n\n")
181 const char *members
[] =
188 CORBA::ContainedSeq_var contents
=
189 this->repo_
->contents (CORBA::dk_all
,
192 CORBA::ULong length
= contents
->length ();
196 ACE_ERROR_RETURN ((LM_ERROR
,
197 ACE_TEXT ("ERROR: Repository::contents::length: %d")
198 ACE_TEXT (" while it's expected to be 1\n"),
205 CORBA::StructDef_var svar
=
206 CORBA::StructDef::_narrow (contents
[i
]);
208 if (CORBA::is_nil (svar
.in ()))
210 ACE_ERROR_RETURN ((LM_ERROR
,
211 ACE_TEXT ("ERROR: Struct from repo is nil\n")),
215 CORBA::StructMemberSeq_var out_members
=
218 length
= out_members
->length ();
222 ACE_ERROR_RETURN ((LM_ERROR
,
223 ACE_TEXT ("ERROR: StructDef::members::length: %d")
224 ACE_TEXT (" while it's expected to be 3\n"),
229 for (i
= 0; i
< length
; ++i
)
233 ACE_DEBUG ((LM_DEBUG
,
234 ACE_TEXT ("StructDef::members[%d]::name: %C\n"),
236 out_members
[i
].name
.in ()));
241 if (ACE_OS::strcmp (out_members
[i
].name
, "my_enum") != 0)
243 ACE_ERROR_RETURN ((LM_ERROR
,
244 ACE_TEXT ("ERROR: Incorrect struct member\n")),
250 if (ACE_OS::strcmp (out_members
[i
].name
, members
[i
]) != 0)
252 ACE_ERROR_RETURN ((LM_ERROR
,
253 ACE_TEXT ("ERROR: Incorrect struct member\n")),
259 #if defined (ACE_NDEBUG)
260 // ACE_ASSERT macro expands to nothing, so...
261 ACE_UNUSED_ARG (members
);
262 #endif /* ACE_NDEBUG */