2 //=============================================================================
6 * tests object references
8 * @author Aniruddha Gokhale
10 //=============================================================================
16 // ************************************************************************
18 // ************************************************************************
20 Test_ObjRef::Test_ObjRef ()
21 : opname_ (CORBA::string_dup ("test_objref"))
25 Test_ObjRef::~Test_ObjRef ()
27 CORBA::string_free (this->opname_
);
32 Test_ObjRef::opname () const
38 Test_ObjRef::dii_req_invoke (CORBA::Request
*req
)
40 req
->add_in_arg ("s1") <<= this->in_
.in ();
41 req
->add_inout_arg ("s2") <<= this->inout_
.in ();
42 req
->add_out_arg ("s3") <<= this->out_
.in ();
44 req
->set_return_type (_tc_Coffee
);
49 req
->return_value () >>= tmp
;
50 this->ret_
= Coffee::_duplicate (tmp
);
52 CORBA::NamedValue_ptr o2
=
53 req
->arguments ()->item (1);
54 *o2
->value () >>= tmp
;
55 this->inout_
= Coffee::_duplicate (tmp
);
57 CORBA::NamedValue_ptr o3
=
58 req
->arguments ()->item (2);
59 *o3
->value () >>= tmp
;
60 this->out_
= Coffee::_duplicate (tmp
);
63 static const char *Coffee_Flavor
[] = {
69 "Swiss Chocolate Mocha"
73 Test_ObjRef::init_parameters (Param_Test_ptr objref
)
76 Generator
*gen
= GENERATOR::instance (); // value generator
78 char msg_str
[256] = "";
82 ACE_OS::strcpy (msg_str
, "make_cofee");
84 // first get a Coffee object
85 this->in_
= objref
->make_coffee ();
87 // Get some index into Coffee_Flavor [].
88 CORBA::ULong index
= (CORBA::ULong
) (gen
->gen_long () % 6);
89 desc
.name
= Coffee_Flavor
[index
];
91 // set the attribute of the object
92 ACE_OS::strcpy (msg_str
, "set coffee attribute");
93 this->in_
->description (desc
); // set the attribute for the in object
95 this->inout_
= Coffee::_nil ();
96 this->out_
= Coffee::_nil ();
97 this->ret_
= Coffee::_nil ();
101 catch (const CORBA::Exception
& ex
)
103 ex
._tao_print_exception (msg_str
);
109 Test_ObjRef::reset_parameters ()
111 // Environemnt variable
113 Generator
*gen
= GENERATOR::instance (); // value generator
115 // Get some index into Coffee_Flavor [].
116 CORBA::ULong index
= (CORBA::ULong
) (gen
->gen_long () % 6);
117 desc
.name
= Coffee_Flavor
[index
];
121 // set the attribute of the object
122 this->in_
->description (desc
); // set the attribute for the in object
124 catch (const CORBA::Exception
& ex
)
126 ex
._tao_print_exception ("set coffee attribute");
130 this->inout_
= Coffee::_nil ();
131 this->out_
= Coffee::_nil ();
132 this->ret_
= Coffee::_nil ();
138 Test_ObjRef::run_sii_test (Param_Test_ptr objref
)
143 objref
->test_objref (this->in_
.in (),
144 this->inout_
.inout (),
149 catch (const CORBA::Exception
& ex
)
151 ex
._tao_print_exception ("Test_ObjRef::run_sii_test\n");
157 Test_ObjRef::check_validity ()
159 // Environemnt variable
163 if (CORBA::is_nil (this->in_
.in ())
164 || CORBA::is_nil (this->inout_
.in ())
165 || CORBA::is_nil (this->out_
.in ())
166 || CORBA::is_nil (this->ret_
.in ()))
168 ACE_ERROR ((LM_ERROR
, "Nil object references returned\n"));
171 Coffee::Desc_var in_desc
=
172 this->in_
->description ();
174 const char *in
= in_desc
->name
.in ();
176 Coffee::Desc_var inout_desc
=
177 this->inout_
->description ();
179 const char *inout
= inout_desc
->name
.in ();
181 Coffee::Desc_var out_desc
=
182 this->out_
->description ();
184 const char *out
= out_desc
->name
.in ();
186 Coffee::Desc_var ret_desc
= this->out_
->description ();
188 const char* ret
= ret_desc
->name
.in ();
191 if (!ACE_OS::strcmp (in
, inout
) &&
192 !ACE_OS::strcmp (in
, out
) &&
193 !ACE_OS::strcmp (in
, ret
))
196 catch (const CORBA::Exception
& ex
)
198 ex
._tao_print_exception ("Retrieving description");
206 Test_ObjRef::check_validity (CORBA::Request_ptr
)
208 return this->check_validity ();
212 Test_ObjRef::print_values ()
216 Coffee::Desc_var in_desc
;
217 Coffee::Desc_var inout_desc
;
218 Coffee::Desc_var out_desc
;
219 Coffee::Desc_var ret_desc
;
222 const char *inout
= 0;
226 if (!CORBA::is_nil (this->in_
.in ()))
229 this->in_
->description ();
230 in
= in_desc
->name
.in ();
233 if (!CORBA::is_nil (this->inout_
.in ()))
236 this->inout_
->description ();
237 inout
= inout_desc
->name
.in ();
240 if (!CORBA::is_nil (this->out_
.in ()))
243 this->out_
->description ();
244 out
= out_desc
->name
.in ();
247 if (!CORBA::is_nil (this->ret_
.in ()))
250 this->ret_
->description ();
251 ret
= ret_desc
->name
.in ();
254 catch (const CORBA::Exception
& ex
)
256 ex
._tao_print_exception ("Retrieving Description");
261 ACE_DEBUG ((LM_DEBUG
,
266 "ret = %C*=*=*=*=*=\n",
267 in
?in
:"ERROR(null string)",
268 inout
?inout
:"ERROR(null string)",
269 out
?out
:"ERROR(null string)",
270 ret
?ret
:"ERROR(null string)"