summaryrefslogtreecommitdiff
path: root/TAO/Benchmark/Marshal_Test/Orbix/orbix_marshal_impl.cpp
blob: 877b8bd1626da0c7a3f655cdd626089de93af496 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
#include "orbix_marshal_impl.h"

#if !defined (__ACE_INLINE__)
#include "orbix_marshal_impl.i"
#endif /* __ACE_INLINE__ */

// All the methods of the SSI class
void
Marshal_SSI_Impl::test_short (CORBA::Short s1,
			      CORBA::Short &s2,
			      CORBA::Environment &IT_env)
{
  s2 = 2*s1;
}

void
Marshal_SSI_Impl::test_long (CORBA::Long l1,
			     CORBA::Long &l2,
			     CORBA::Environment &IT_env)
{
  l2 = 3*l1;
}

void
Marshal_SSI_Impl::test_octet (CORBA::Octet o1,
			      CORBA::Octet &o2,
			      CORBA::Environment &IT_env)
{
  o2 = o1;
}

void
Marshal_SSI_Impl::test_char (CORBA::Char c1,
			     CORBA::Char &c2,
			     CORBA::Environment &IT_env)
{
  c2 = c1;
}

void
Marshal_SSI_Impl::test_double (CORBA::Double d1,
			       CORBA::Double &d2,
			       CORBA::Environment &IT_env)
{
  d2 = d1/2;
}

void
Marshal_SSI_Impl::test_struct (const Marshal::Marshal_Struct& ms1,
			       Marshal::Marshal_Struct& ms2,
			       CORBA::Environment &IT_env)
{
  ms2.s = ms1.s;
  ms2.l = ms1.l;
  ms2.c = ms1.c;
  ms2.o = ms1.o;
  ms2.d = ms1.d;
}

void
Marshal_SSI_Impl::test_union (const Marshal::Marshal_Union& u1,
			      Marshal::Marshal_Union& u2,
			      CORBA::Environment &IT_env)
{
  switch (u1._d ())
    {
    case Marshal::e_0th:
      u2.s (u1.s ()); // set short
      break;
    case Marshal::e_1st:
      u2.l (u1.l ()); // set long
      break;
    case Marshal::e_2nd:
      u2.c (u1.c ()); // set char
      break;
    case Marshal::e_3rd:
      u2.o (u1.o ()); // set octet
      break;
    case Marshal::e_4th:
      u2.d (u1.d ()); // set double
      break;
    case Marshal::e_5th:
    default:
      u2.ms (u1. ms ()); // set structs
      break;
    }
}

void
Marshal_SSI_Impl::test_any (const CORBA::Any &a1,
			    CORBA::Any *&a2,
			    CORBA::Environment &IT_env)
{
  a2 = new CORBA::Any (a1.type (), (void *)a1.value ()); // will do a deep copy
}

void 
Marshal_SSI_Impl::test_sequence (const Marshal::AnySeq& as1,
				 Marshal::AnySeq *& as2,
				 CORBA::Environment &IT_env)
{
  as2 = new Marshal::AnySeq (as1);
}

void 
Marshal_SSI_Impl::test_recursive (const Marshal::Marshal_Recursive &mr1,
				  Marshal::Marshal_Recursive *&mr2,
				  CORBA::Environment &IT_env)
{
}

//----------------------------------------------------------------------------
//the methods of the DSI implementation class

void
Marshal_DSI_Impl::invoke (CORBA::ServerRequest& req, CORBA::Environment_ptr
			  ep, CORBA::Environment &IT_env)
{
  ACE_DEBUG ((LM_DEBUG, "************ inside invoke **********\n"));
  // parse the incoming request and find out for what operation it is. We use a
  // simple linear search here
  if (!ACE_OS::strcmp (req.op_name (IT_env), "test_short"))
    {
      test_short_skel (req);
    }
  else if (!ACE_OS::strcmp (req.op_name (), "test_long"))
    {
    }
  else if (!ACE_OS::strcmp (req.op_name (), "test_octet"))
    {
    }
  else if (!ACE_OS::strcmp (req.op_name (), "test_char"))
    {
    }
  else if (!ACE_OS::strcmp (req.op_name (), "test_double"))
    {
    }
  else if (!ACE_OS::strcmp (req.op_name (), "test_struct"))
    {
    }
  else if (!ACE_OS::strcmp (req.op_name (), "test_union"))
    {
    }
  else if (!ACE_OS::strcmp (req.op_name (), "test_any"))
    {
    }
  else if (!ACE_OS::strcmp (req.op_name (), "test_sequence"))
    {
    }
}

void
Marshal_DSI_Impl::test_short (CORBA::Short s1,
			      CORBA::Short &s2)
{
  s2 = 5*s1;
}

void
Marshal_DSI_Impl::test_long (CORBA::Long l1,
			     CORBA::Long &l2)
{
  l2 = l1;
}

void
Marshal_DSI_Impl::test_octet (CORBA::Octet o1,
			      CORBA::Octet &o2)
{
  o2 = o1;
}

void
Marshal_DSI_Impl::test_char (CORBA::Char c1,
			     CORBA::Char &c2)
{
  c2 = c1;
}

void
Marshal_DSI_Impl::test_double (CORBA::Double d1,
			       CORBA::Double &d2)
{
  d2 = d1;
}

void
Marshal_DSI_Impl::test_struct (const Marshal::Marshal_Struct& ms1,
			       Marshal::Marshal_Struct& ms2)
{
  ms2.s = ms1.s;
  ms2.l = ms1.l;
  ms2.c = ms1.c;
  ms2.o = ms1.o;
  ms2.d = ms1.d;
}

void
Marshal_DSI_Impl::test_union (const Marshal::Marshal_Union& u1,
			      Marshal::Marshal_Union& u2)
{
  switch (u1._d ())
    {
    case Marshal::e_0th:
      u2.s (u1.s ()); // set short
      break;
    case Marshal::e_1st:
      u2.l (u1.l ()); // set long
      break;
    case Marshal::e_2nd:
      u2.c (u1.c ()); // set char
      break;
    case Marshal::e_3rd:
      u2.o (u1.o ()); // set octet
      break;
    case Marshal::e_4th:
      u2.d (u1.d ()); // set double
      break;
    case Marshal::e_5th:
    default:
      u2.ms (u1. ms ()); // set structs
      break;
    }
}

void
Marshal_DSI_Impl::test_any (const CORBA::Any &a1,
			    CORBA::Any *&a2)
{
  a2 = new CORBA::Any (a1.type (), (void *)a1.value ()); // will do a deep copy
}

void 
Marshal_DSI_Impl::test_sequence (const Marshal::AnySeq& as1,
				 Marshal::AnySeq *& as2)
{
  as2 = new Marshal::AnySeq (as1);
}

void 
Marshal_DSI_Impl::test_recursive (const Marshal::Marshal_Recursive &mr1,
				  Marshal::Marshal_Recursive *&mr2)
{
}

// all the helper functions for the DSI class
void 
Marshal_DSI_Impl::test_short_skel (CORBA::ServerRequest& req)
{
  CORBA::NVList_ptr short_nv;
  CORBA::Any *any_s1, *any_s2;
  CORBA::Short s1 = 0, s2 = 0;

  orb_->create_list (2, short_nv); // parse 2 args
  any_s1 = new CORBA::Any (CORBA::_tc_short, &s1, 0);
  any_s2 = new CORBA::Any (CORBA::_tc_short, &s2, 0);
  short_nv->add_value ("s1", *any_s1, CORBA::ARG_IN);
  short_nv->add_value ("s2", *any_s2, CORBA::ARG_OUT);

  req.params (short_nv);

  test_short (s1, s2);
  ACE_DEBUG ((LM_DEBUG, ">>>>>>>s1 = %d and s2 = %d\n<<<<<<<<", s1, s2));
}

void 
Marshal_DSI_Impl::test_long_skel (CORBA::ServerRequest& req)
{
}

void 
Marshal_DSI_Impl::test_octet_skel (CORBA::ServerRequest& req)
{
}

void 
Marshal_DSI_Impl::test_char_skel (CORBA::ServerRequest& req)
{
}

void 
Marshal_DSI_Impl::test_double_skel (CORBA::ServerRequest& req)
{
}

void 
Marshal_DSI_Impl::test_struct_skel (CORBA::ServerRequest& req)
{
}

void 
Marshal_DSI_Impl::test_union_skel (CORBA::ServerRequest& req)
{
}

void 
Marshal_DSI_Impl::test_any_skel (CORBA::ServerRequest& req)
{
}

void 
Marshal_DSI_Impl::test_sequence_skel (CORBA::ServerRequest& req)
{
}

void 
Marshal_DSI_Impl::test_recursive_skel (CORBA::ServerRequest& req)
{
}