2 //=============================================================================
4 * @file objref_struct.cpp
6 * test structures containing object references.
8 * @author Aniruddha Gokhale
10 //=============================================================================
14 #include "objref_struct.h"
16 // ************************************************************************
18 // ************************************************************************
20 Test_Objref_Struct::Test_Objref_Struct ()
21 : opname_ (CORBA::string_dup ("test_objref_struct")),
22 inout_ (new Param_Test::Objref_Struct
),
23 out_ (new Param_Test::Objref_Struct
),
24 ret_ (new Param_Test::Objref_Struct
)
28 Test_Objref_Struct::~Test_Objref_Struct ()
30 CORBA::string_free (this->opname_
);
32 // the other data members will be freed as they are "_var"s and objects
33 // (rather than pointers to objects)
37 Test_Objref_Struct::opname () const
43 Test_Objref_Struct::dii_req_invoke (CORBA::Request
*req
)
45 req
->add_in_arg ("s1") <<= this->in_
;
46 req
->add_inout_arg ("s2") <<= this->inout_
.in ();
47 req
->add_out_arg ("s3") <<= this->out_
.in ();
49 req
->set_return_type (Param_Test::_tc_Objref_Struct
);
53 const Param_Test::Objref_Struct
*tmp
= 0;
54 req
->return_value () >>= tmp
;
55 this->ret_
= new Param_Test::Objref_Struct (*tmp
);
57 CORBA::NamedValue_ptr o2
=
58 req
->arguments ()->item (1);
59 *o2
->value () >>= tmp
;
60 this->inout_
= new Param_Test::Objref_Struct (*tmp
);
62 CORBA::NamedValue_ptr o3
=
63 req
->arguments ()->item (2);
64 *o3
->value () >>= tmp
;
65 this->out_
= new Param_Test::Objref_Struct (*tmp
);
69 Test_Objref_Struct::init_parameters (Param_Test_ptr objref
)
73 Generator
*gen
= GENERATOR::instance (); // value generator
75 // Set the long member.
76 this->in_
.x
= gen
->gen_long ();
78 this->in_
.y
= objref
->make_coffee ();
81 d
.name
= gen
->gen_string ();
83 this->in_
.y
->description (d
);
87 this->inout_
->y
= Coffee::_nil ();
90 dd
.name
= CORBA::string_dup ("");
94 catch (const CORBA::Exception
& ex
)
96 ex
._tao_print_exception ("Test_Objref_Struct::init_parameters\n");
102 Test_Objref_Struct::reset_parameters ()
104 this->inout_
= new Param_Test::Objref_Struct
; // delete the previous ones
105 this->out_
= new Param_Test::Objref_Struct
;
106 this->ret_
= new Param_Test::Objref_Struct
;
110 this->inout_
->y
= Coffee::_nil ();
113 dd
.name
= CORBA::string_dup ("");
119 Test_Objref_Struct::run_sii_test (Param_Test_ptr objref
)
123 Param_Test::Objref_Struct_out
out (this->out_
.out ());
125 this->ret_
= objref
->test_objref_struct (this->in_
,
126 this->inout_
.inout (),
131 catch (const CORBA::Exception
& ex
)
133 ex
._tao_print_exception ("Test_Objref_Struct::run_sii_test\n");
139 Test_Objref_Struct::check_validity ()
141 if (this->in_
.x
!= this->inout_
->x
142 || this->in_
.x
!= this->out_
->x
143 || this->in_
.x
!= this->ret_
->x
)
149 if (CORBA::is_nil (this->in_
.y
.in ())
150 || CORBA::is_nil (this->out_
->y
.in ())
151 || CORBA::is_nil (this->ret_
->y
.in ())
152 || CORBA::is_nil (this->inout_
->y
.in ()))
157 Coffee::Desc_var s_in
= this->in_
.y
->description ();
159 Coffee::Desc_var s_out
= this->out_
->y
->description ();
161 Coffee::Desc_var s_inout
= this->inout_
->y
->description ();
163 Coffee::Desc_var s_ret
= this->ret_
->y
->description ();
165 if (ACE_OS::strcmp (s_in
->name
, s_out
->name
) != 0
166 || ACE_OS::strcmp (s_in
->name
, s_inout
->name
) != 0
167 || ACE_OS::strcmp (s_in
->name
, s_ret
->name
) != 0 )
174 catch (const CORBA::Exception
& ex
)
176 ex
._tao_print_exception ("Test_Objref_Struct::check_validity\n");
182 Test_Objref_Struct::check_validity (CORBA::Request_ptr
/*req*/)
184 return this->check_validity ();
188 Test_Objref_Struct::print_values ()
190 ACE_DEBUG ((LM_DEBUG
,
191 "\n*=*=*=*=*=*=*=*=*=*=\n"
204 Coffee::Desc_var s_in
=
205 this->in_
.y
->description ();
207 Coffee::Desc_var s_inout
= new Coffee::Desc
;
208 Coffee::Desc_var s_out
= new Coffee::Desc
;
209 Coffee::Desc_var s_ret
= new Coffee::Desc
;
210 s_inout
->name
= CORBA::string_dup ("");
211 s_out
->name
= CORBA::string_dup ("");
212 s_ret
->name
= CORBA::string_dup ("");
214 if (!CORBA::is_nil (this->out_
->y
.in ()))
216 s_out
= this->out_
->y
->description ();
219 if (!CORBA::is_nil (this->inout_
->y
.in ()))
221 s_inout
= this->inout_
->y
->description ();
224 if (!CORBA::is_nil (this->ret_
->y
.in ()))
226 s_ret
= this->ret_
->y
->description ();
229 ACE_DEBUG ((LM_DEBUG
,
230 "\n*=*=*=*=*=*=*=*=*=*=\n"
238 s_ret
->name
.in () ));
240 catch (const CORBA::Exception
& ex
)
242 ex
._tao_print_exception ("Test_Objref_Struct::print_values\n");