summaryrefslogtreecommitdiff
path: root/performance-tests/Sequence_Latency/DSI/Roundtrip.cpp
blob: 044389579ff84fec65c63184fa65e130d064d30e (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
//
// $Id$
//

#include "TestC.h"
#include "tao/AnyTypeCode/TypeCode_Constants.h"
#include "tao/AnyTypeCode/NVList.h"
#include "tao/AnyTypeCode/SystemExceptionA.h"
#include "Roundtrip.h"
#include "tao/DynamicInterface/Server_Request.h"

Roundtrip::Roundtrip (CORBA::ORB_ptr orb)
  : orb_ (CORBA::ORB::_duplicate (orb))
{
}

void
Roundtrip::invoke (CORBA::ServerRequest_ptr request)
{
  if (ACE_OS::strcmp ("shutdown", request->operation ()) == 0)
    {
      this->orb_->shutdown (0);

      return;
    }
  else if (ACE_OS::strcmp ("_is_a", request->operation ()) == 0)
    {
      CORBA::NVList_ptr list;
      this->orb_->create_list (0, list);

      CORBA::Any type_id;
      type_id._tao_set_typecode (CORBA::_tc_string);
      list->add_value ("type_id", type_id, CORBA::ARG_IN);

      request->arguments (list);

      CORBA::NamedValue_ptr nv = list->item (0);

      const char *arg;
      *(nv->value ()) >>= arg;

      CORBA::Boolean type_matches = 0;
      if (ACE_OS::strcmp (arg, "IDL:Test/Roundtrip:1.0") == 0
          || ACE_OS::strcmp (arg, "IDL:omg.org/CORBA/Object:1.0") == 0
          || ACE_OS::strcmp (arg, "") == 0)
        type_matches = 1;

      CORBA::Any result;
      result <<= CORBA::Any::from_boolean (type_matches);

      request->set_result (result);

      return;
    }
  else if (ACE_OS::strcmp ("test_octet_method", request->operation ()) == 0)
    {
      CORBA::NVList_ptr list;
      this->orb_->create_list (0, list);

      // Set up the argument list

      CORBA::Any octet_load;
      octet_load._tao_set_typecode (Test::_tc_octet_load);
      list->add_value ("octet_load", octet_load, CORBA::ARG_IN);

      CORBA::Any send_time;
      send_time._tao_set_typecode (CORBA::_tc_ulonglong);
      list->add_value ("send_time", send_time, CORBA::ARG_IN);

      request->arguments (list);

      // Set up the return value

      CORBA::NamedValue_ptr nv = list->item (1);

      request->set_result (*(nv->value ()));

      return;
    }
  else if (ACE_OS::strcmp ("test_long_method", request->operation ()) == 0)
    {
      CORBA::NVList_ptr list;
      this->orb_->create_list (0, list);

      // Set up the argument list

      CORBA::Any long_load;
      long_load._tao_set_typecode (Test::_tc_long_load);
      list->add_value ("long_load", long_load, CORBA::ARG_IN);

      CORBA::Any send_time;
      send_time._tao_set_typecode (CORBA::_tc_ulonglong);
      list->add_value ("send_time", send_time, CORBA::ARG_IN);

      request->arguments (list);

      // Set up the return value

      CORBA::NamedValue_ptr nv = list->item (1);

      request->set_result (*(nv->value ()));

      return;
    }
  else if (ACE_OS::strcmp ("test_short_method", request->operation ()) == 0)
    {
      CORBA::NVList_ptr list;
      this->orb_->create_list (0, list);

      // Set up the argument list

      CORBA::Any short_load;
      short_load._tao_set_typecode (Test::_tc_short_load);
      list->add_value ("short_load", short_load, CORBA::ARG_IN);

      CORBA::Any send_time;
      send_time._tao_set_typecode (CORBA::_tc_ulonglong);
      list->add_value ("send_time", send_time, CORBA::ARG_IN);

      request->arguments (list);

      // Set up the return value

      CORBA::NamedValue_ptr nv = list->item (1);

      request->set_result (*(nv->value ()));

      return;
    }
  else if (ACE_OS::strcmp ("test_char_method", request->operation ()) == 0)
    {
      CORBA::NVList_ptr list;
      this->orb_->create_list (0, list);

      // Set up the argument list

      CORBA::Any char_load;
      char_load._tao_set_typecode (Test::_tc_char_load);
      list->add_value ("char_load", char_load, CORBA::ARG_IN);

      CORBA::Any send_time;
      send_time._tao_set_typecode (CORBA::_tc_ulonglong);
      list->add_value ("send_time", send_time, CORBA::ARG_IN);

      request->arguments (list);

      // Set up the return value

      CORBA::NamedValue_ptr nv = list->item (1);

      request->set_result (*(nv->value ()));

      return;
    }
  else if (ACE_OS::strcmp ("test_longlong_method", request->operation ()) == 0)
    {
      CORBA::NVList_ptr list;
      this->orb_->create_list (0, list);

      // Set up the argument list

      CORBA::Any longlong_load;
      longlong_load._tao_set_typecode (Test::_tc_longlong_load);
      list->add_value ("longlong_load", longlong_load, CORBA::ARG_IN);

      CORBA::Any send_time;
      send_time._tao_set_typecode (CORBA::_tc_ulonglong);
      list->add_value ("send_time", send_time, CORBA::ARG_IN);

      request->arguments (list);

      // Set up the return value

      CORBA::NamedValue_ptr nv = list->item (1);

      request->set_result (*(nv->value ()));

      return;
    }
  else if (ACE_OS::strcmp ("test_double_method", request->operation ()) == 0)
    {
      CORBA::NVList_ptr list;
      this->orb_->create_list (0, list);

      // Set up the argument list

      CORBA::Any double_load;
      double_load._tao_set_typecode (Test::_tc_double_load);
      list->add_value ("double_load", double_load, CORBA::ARG_IN);

      CORBA::Any send_time;
      send_time._tao_set_typecode (CORBA::_tc_ulonglong);
      list->add_value ("send_time", send_time, CORBA::ARG_IN);

      request->arguments (list);

      // Set up the return value

      CORBA::NamedValue_ptr nv = list->item (1);

      request->set_result (*(nv->value ()));

      return;
    }

  CORBA::Any bad_operation;
  CORBA::BAD_OPERATION exception;
  bad_operation <<= exception;
  request->set_exception (bad_operation);
}

CORBA::RepositoryId
Roundtrip::_primary_interface (const PortableServer::ObjectId &,
                               PortableServer::POA_ptr)
{
  return CORBA::string_dup ("IDL:Test/Roundtrip:1.0");
}