2 //=============================================================================
4 * @file small_union.cpp
8 * @author Aniruddha Gokhale
10 //=============================================================================
14 #include "small_union.h"
16 // ************************************************************************
18 // ************************************************************************
20 size_t Test_Small_Union::counter
= 0;
22 Test_Small_Union::Test_Small_Union ()
23 : opname_ (CORBA::string_dup ("test_small_union"))
27 Test_Small_Union::~Test_Small_Union ()
29 CORBA::string_free (this->opname_
);
34 Test_Small_Union::opname () const
40 Test_Small_Union::dii_req_invoke (CORBA::Request
*req
)
42 req
->add_in_arg ("s1") <<= this->in_
;
43 req
->add_inout_arg ("s2") <<= this->inout_
;
44 req
->add_out_arg ("s3") <<= this->out_
.in ();
46 req
->set_return_type (Param_Test::_tc_Small_Union
);
50 const Param_Test::Small_Union
*tmp
= 0;
51 req
->return_value () >>= tmp
;
52 this->ret_
= new Param_Test::Small_Union (*tmp
);
54 CORBA::NamedValue_ptr o2
=
55 req
->arguments ()->item (1);
56 *o2
->value () >>= tmp
;
59 CORBA::NamedValue_ptr o3
=
60 req
->arguments ()->item (2);
61 *o3
->value () >>= tmp
;
62 this->out_
= new Param_Test::Small_Union (*tmp
);
66 Test_Small_Union::init_parameters (Param_Test_ptr objref
)
70 // get access to a Coffee Object
71 this->cobj_
= objref
->make_coffee ();
73 this->reset_parameters ();
76 catch (const CORBA::SystemException
& sysex
)
78 sysex
._tao_print_exception ("System Exception doing make_coffee");
80 catch (const CORBA::Exception
& ex
)
82 ex
._tao_print_exception (
83 "An exception caught in make_coffee");
89 Test_Small_Union::reset_parameters ()
91 Generator
*gen
= GENERATOR::instance (); // value generator
92 CORBA::ULong index
= (counter
++ % 2);
98 CORBA::Long l
= gen
->gen_long ();
99 this->in_
.the_long (l
);
100 this->inout_
.the_long (l
);
106 CORBA::Short s
= gen
->gen_short ();
107 this->in_
.the_short (s
);
108 this->inout_
.the_short (s
);
112 this->out_
= new Param_Test::Small_Union (this->in_
);
113 this->ret_
= new Param_Test::Small_Union (this->in_
);
118 Test_Small_Union::run_sii_test (Param_Test_ptr objref
)
122 this->ret_
= objref
->test_small_union (this->in_
,
128 catch (const CORBA::Exception
& ex
)
130 ex
._tao_print_exception ("Test_Small_Union::run_sii_test\n");
136 Test_Small_Union::check_validity ()
138 if (this->in_
._d () != this->inout_
._d ()
139 || this->in_
._d () != this->out_
->_d ()
140 || this->in_
._d () != this->ret_
->_d ())
142 ACE_DEBUG ((LM_DEBUG
, "mismatch of discriminators\n"));
147 switch (this->in_
._d ())
149 case Param_Test::A_LONG
:
151 CORBA::Long in
= this->in_
.the_long ();
152 CORBA::Long inout
= this->inout_
.the_long ();
153 CORBA::Long out
= this->out_
->the_long ();
154 CORBA::Long ret
= this->ret_
->the_long ();
155 if (in
!= out
|| in
!= inout
|| in
!= ret
)
160 case Param_Test::A_SHORT
:
162 CORBA::Short in
= this->in_
.the_short ();
163 CORBA::Short inout
= this->inout_
.the_short ();
164 CORBA::Short out
= this->out_
->the_short ();
165 CORBA::Short ret
= this->ret_
->the_short ();
166 if (in
!= out
|| in
!= inout
|| in
!= ret
)
179 Test_Small_Union::check_validity (CORBA::Request_ptr
/*req*/)
181 //ACE_UNUSED_ARG (req);
182 return this->check_validity ();
186 Test_Small_Union::print_values ()