summaryrefslogtreecommitdiff
path: root/CIAO/connectors/dds4ccm/impl/ndds/DataReader.cpp
blob: 9fb0b784d05b2f616cacf139d43d3cdea9a4a623 (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
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
// $Id$

#include "DataReader.h"
#include "DataReaderListener.h"
#include "StatusCondition.h"
#include "ReadCondition.h"
#include "QueryCondition.h"
#include "SampleLostStatus.h"
#include "SubscriptionMatchedStatus.h"
#include "RequestedDeadlineMissedStatus.h"
#include "SampleRejectedStatus.h"
#include "LivelinessChangedStatus.h"
#include "RequestedIncompatibleQosStatus.h"
#include "Duration_t.h"
#include "InstanceHandle_t.h"
#include "InstanceHandleSeq.h"
#include "Subscriber.h"
#include "TopicDescription.h"
#include "DataReaderQos.h"
#include "StringSeq.h"

#include "dds4ccm/impl/logger/Log_Macros.h"

namespace CIAO
{
  namespace DDS4CCM
  {
    namespace RTI
    {
      RTI_DataReader_i::RTI_DataReader_i (void)
        : impl_ (0)
      {
      }

      RTI_DataReader_i::~RTI_DataReader_i (void)
      {
      }

      ::DDS::ReturnCode_t
      RTI_DataReader_i::enable (void)
      {
        return this->impl ()->enable ();
      }

      ::DDS::StatusCondition_ptr
      RTI_DataReader_i::get_statuscondition (void)
      {
#if defined (CIAO_DDS4CCM_NDDS) && (CIAO_DDS4CCM_NDDS==1)
        ::DDS::StatusCondition_var retval = ::DDS::StatusCondition::_nil ();
        ACE_NEW_THROW_EX (retval,
                          RTI_StatusCondition_i (),
                          CORBA::NO_MEMORY ());

        DDSStatusCondition* sc = this->impl ()->get_statuscondition ();
        RTI_StatusCondition_i *rti_sc = dynamic_cast < RTI_StatusCondition_i *> (retval.in ());
        rti_sc->set_impl (sc);
        return retval._retn ();
#else
        return this->impl ()->get_statuscondition ();
#endif
      }

      ::DDS::StatusMask
      RTI_DataReader_i::get_status_changes (void)
      {
        return this->impl ()->get_status_changes ();
      }

      DDS_INSTANCE_HANDLE_T_RETN
      RTI_DataReader_i::get_instance_handle (void)
      {
#if defined (CIAO_DDS4CCM_NDDS) && (CIAO_DDS4CCM_NDDS==1)
        ::DDS_InstanceHandle_t const rtihandle = this->impl ()->get_instance_handle ();
        ::DDS::InstanceHandle_t handle;
        handle <<= rtihandle;
        return handle;
#else
        return this->impl ()->get_instance_handle ();
#endif
      }

      ::DDS::ReadCondition_ptr
      RTI_DataReader_i::create_readcondition (
        ::DDS::SampleStateMask sample_states,
        ::DDS::ViewStateMask view_states,
        ::DDS::InstanceStateMask instance_states)
      {
#if defined (CIAO_DDS4CCM_NDDS) && (CIAO_DDS4CCM_NDDS==1)
        ::DDS::ReadCondition_var retval = ::DDS::ReadCondition::_nil ();
        ACE_NEW_THROW_EX (retval,
                          RTI_ReadCondition_i (),
                          CORBA::NO_MEMORY ());

        DDSReadCondition* rc = this->impl ()->create_readcondition (sample_states, view_states, instance_states);
        RTI_ReadCondition_i *rti_rc = dynamic_cast < RTI_ReadCondition_i *>(retval.in ());
        rti_rc->set_impl (rc);
        return retval._retn ();
#else
        return this->impl ()->create_readcondition (sample_states, view_states, instance_states);
#endif
      }

      ::DDS::QueryCondition_ptr
      RTI_DataReader_i::create_querycondition (
        ::DDS::SampleStateMask sample_states,
        ::DDS::ViewStateMask view_states,
        ::DDS::InstanceStateMask instance_states,
        const char * query_expression,
        const ::DDS::StringSeq & query_parameters)
      {
#if defined (CIAO_DDS4CCM_NDDS) && (CIAO_DDS4CCM_NDDS==1)
        DDS_StringSeq parameters;
        parameters <<= query_parameters;

        ::DDS::QueryCondition_var retval = ::DDS::QueryCondition::_nil ();
        ACE_NEW_THROW_EX (retval,
                          RTI_QueryCondition_i (),
                          CORBA::NO_MEMORY ());

        DDSQueryCondition* qc = this->impl ()->create_querycondition (
                                       sample_states,
                                       view_states,
                                       instance_states,
                                       query_expression,
                                       parameters);

        RTI_QueryCondition_i *rti_qc = dynamic_cast < RTI_QueryCondition_i *> (retval.in ());
        rti_qc->set_impl (qc);
        return retval._retn ();
#else
        return this->impl ()->create_querycondition (
                                       sample_states,
                                       view_states,
                                       instance_states,
                                       query_expression,
                                       query_parameters);
#endif
      }

      ::DDS::ReturnCode_t
      RTI_DataReader_i::delete_readcondition (
        ::DDS::ReadCondition_ptr a_condition)
      {
#if defined (CIAO_DDS4CCM_NDDS) && (CIAO_DDS4CCM_NDDS==1)
        RTI_ReadCondition_i *rc = dynamic_cast< RTI_ReadCondition_i *> (a_condition);
        if (!rc)
          {
            return ::DDS::RETCODE_BAD_PARAMETER;
          }
        return this->impl ()->delete_readcondition (rc->get_impl ());
#else
        return this->impl ()->delete_readcondition (a_condition);
#endif
      }

      ::DDS::ReturnCode_t
      RTI_DataReader_i::delete_contained_entities (void)
      {
        return this->impl ()->delete_contained_entities ();
      }

      ::DDS::ReturnCode_t
      RTI_DataReader_i::set_qos (
        const ::DDS::DataReaderQos &qos)
      {
#if defined (CIAO_DDS4CCM_NDDS) && (CIAO_DDS4CCM_NDDS==1)
        ::DDS_DataReaderQos ddsqos;
        ddsqos <<= qos;
        return this->impl ()->set_qos (ddsqos);
#else
        return this->impl ()->set_qos (qos);
#endif
      }

      ::DDS::ReturnCode_t
      RTI_DataReader_i::get_qos (
        ::DDS::DataReaderQos &qos)
      {
#if defined (CIAO_DDS4CCM_NDDS) && (CIAO_DDS4CCM_NDDS==1)
        ::DDS_DataReaderQos ddsqos;
        ::DDS_ReturnCode_t const retval = this->impl ()->get_qos (ddsqos);
        qos <<= ddsqos;
        return retval;
#else
        return this->impl ()->get_qos (qos);
#endif
      }

      ::DDS::ReturnCode_t
      RTI_DataReader_i::set_listener (
        ::DDS::DataReaderListener_ptr a_listener,
        ::DDS::StatusMask mask)
      {
        DDS4CCM_TRACE ("RTI_DataReader_i::set_listener");

#if defined (CIAO_DDS4CCM_NDDS) && (CIAO_DDS4CCM_NDDS==1)
        RTI_DataReaderListener_i *rti_drl = 0;
        if (!CORBA::is_nil (a_listener))
          {
            ACE_NEW_THROW_EX (rti_drl,
                              RTI_DataReaderListener_i (a_listener),
                              CORBA::NO_MEMORY ());
          }
        return this->impl ()->set_listener (rti_drl, mask);
#else
        return this->impl ()->set_listener (a_listener, mask);
#endif
      }

      ::DDS::DataReaderListener_ptr
      RTI_DataReader_i::get_listener (void)
      {
        DDS4CCM_TRACE ("RTI_DataReader_i::get_listener");

#if defined (CIAO_DDS4CCM_NDDS) && (CIAO_DDS4CCM_NDDS==1)
        DDSDataReaderListener *drl = this->impl ()->get_listener ();
        RTI_DataReaderListener_i *rti_drl = dynamic_cast <RTI_DataReaderListener_i *> (drl);
        if (!rti_drl)
          {
            DDS4CCM_DEBUG (6, (LM_DEBUG, "RTI_DataReader_i::get_listener - "
                                      "DDS returned a NIL listener.\n"));
            return ::DDS::DataReaderListener::_nil ();
          }
        return rti_drl->get_datareaderlistener ();
#else
        return this->impl ()->get_listener ();
#endif
      }

      ::DDS::TopicDescription_ptr
      RTI_DataReader_i::get_topicdescription (void)
      {
#if defined (CIAO_DDS4CCM_NDDS) && (CIAO_DDS4CCM_NDDS==1)
        ::DDS::TopicDescription_var dds_td = ::DDS::TopicDescription::_nil ();
        ACE_NEW_THROW_EX (dds_td,
                          RTI_TopicDescription_i (),
                          CORBA::NO_MEMORY ());

        ::DDSTopicDescription* td = this->impl ()->get_topicdescription ();
        RTI_TopicDescription_i *rti_td = dynamic_cast < RTI_TopicDescription_i *>(dds_td.in ());
        rti_td->set_impl (td);
        return dds_td._retn ();
#else
        return this->impl ()->get_topicdescription ();
#endif
      }

      ::DDS::Subscriber_ptr
      RTI_DataReader_i::get_subscriber (void)
      {
#if defined (CIAO_DDS4CCM_NDDS) && (CIAO_DDS4CCM_NDDS==1)
        ::DDS::Subscriber_var dds_td = ::DDS::Subscriber::_nil ();
        ACE_NEW_THROW_EX (dds_td,
                          RTI_Subscriber_i (),
                          CORBA::NO_MEMORY ());

        ::DDSSubscriber* subscriber = this->impl ()->get_subscriber ();
        RTI_Subscriber_i *sub = dynamic_cast < RTI_Subscriber_i *>(dds_td.in ());
        sub->set_impl (subscriber);
        return dds_td._retn ();
#else
        return this->impl ()->get_subscriber ();
#endif
      }

      ::DDS::ReturnCode_t
      RTI_DataReader_i::get_sample_rejected_status (
        ::DDS::SampleRejectedStatus & status)
      {
#if defined (CIAO_DDS4CCM_NDDS) && (CIAO_DDS4CCM_NDDS==1)
        DDS_SampleRejectedStatus rtistatus;
        ::DDS::ReturnCode_t const retval = this->impl ()->get_sample_rejected_status (rtistatus);
        rtistatus >>= status;
        return retval;
#else
        return this->impl ()->get_sample_rejected_status (status);
#endif
      }

      ::DDS::ReturnCode_t
      RTI_DataReader_i::get_liveliness_changed_status (
        ::DDS::LivelinessChangedStatus & status)
      {
#if defined (CIAO_DDS4CCM_NDDS) && (CIAO_DDS4CCM_NDDS==1)
        DDS_LivelinessChangedStatus rtistatus;
        ::DDS::ReturnCode_t const retval = this->impl ()->get_liveliness_changed_status (rtistatus);
        rtistatus >>= status;
        return retval;
#else
        return this->impl ()->get_liveliness_changed_status (status);
#endif
      }

      ::DDS::ReturnCode_t
      RTI_DataReader_i::get_requested_deadline_missed_status (
        ::DDS::RequestedDeadlineMissedStatus & status)
      {
#if defined (CIAO_DDS4CCM_NDDS) && (CIAO_DDS4CCM_NDDS==1)
        DDS_RequestedDeadlineMissedStatus rtistatus;
        ::DDS::ReturnCode_t const retval = this->impl ()->get_requested_deadline_missed_status (rtistatus);
        rtistatus >>= status;
        return retval;
#else
        return this->impl ()->get_requested_deadline_missed_status (status);
#endif
      }

      ::DDS::ReturnCode_t
      RTI_DataReader_i::get_requested_incompatible_qos_status (
        ::DDS::RequestedIncompatibleQosStatus & status)
      {
#if defined (CIAO_DDS4CCM_NDDS) && (CIAO_DDS4CCM_NDDS==1)
        DDS_RequestedIncompatibleQosStatus rtistatus;
        ::DDS::ReturnCode_t const retval = this->impl ()->get_requested_incompatible_qos_status (rtistatus);
        rtistatus >>= status;
        return retval;
#else
        return this->impl ()->get_requested_incompatible_qos_status (status);
#endif
      }

      ::DDS::ReturnCode_t
      RTI_DataReader_i::get_subscription_matched_status (
        ::DDS::SubscriptionMatchedStatus & status)
      {
#if defined (CIAO_DDS4CCM_NDDS) && (CIAO_DDS4CCM_NDDS==1)
        ::DDS_SubscriptionMatchedStatus ddsstatus;
        ::DDS::ReturnCode_t const retval = this->impl ()->get_subscription_matched_status (ddsstatus);
        ddsstatus >>= status;
        return retval;
#else
        return this->impl ()->get_subscription_matched_status (status);
#endif
      }

      ::DDS::ReturnCode_t
      RTI_DataReader_i::get_sample_lost_status (
        ::DDS::SampleLostStatus & status)
      {
#if defined (CIAO_DDS4CCM_NDDS) && (CIAO_DDS4CCM_NDDS==1)
        DDS_SampleLostStatus rtistatus;
        ::DDS::ReturnCode_t const retval = this->impl ()->get_sample_lost_status (rtistatus);
        rtistatus >>= status;
        return retval;
#else
        return this->impl ()->get_sample_lost_status (status);
#endif
      }

      ::DDS::ReturnCode_t
      RTI_DataReader_i::wait_for_historical_data (
        const ::DDS::Duration_t & max_wait)
      {
#if defined (CIAO_DDS4CCM_NDDS) && (CIAO_DDS4CCM_NDDS==1)
       ::DDS_Duration_t rtiduration;
       rtiduration <<= max_wait;
       return this->impl ()->wait_for_historical_data (rtiduration);
#else
       return this->impl ()->wait_for_historical_data (max_wait);
#endif
      }

      ::DDS::ReturnCode_t
      RTI_DataReader_i::get_matched_publications (
        ::DDS::InstanceHandleSeq & publication_handles)
      {
#if defined (CIAO_DDS4CCM_NDDS) && (CIAO_DDS4CCM_NDDS==1)
        ::DDS_InstanceHandleSeq rtiseq;
        ::DDS::ReturnCode_t const retval = this->impl ()->get_matched_publications (rtiseq);
        rtiseq >>= publication_handles;
        return retval;
#else
        return this->impl ()->get_matched_publications (publication_handles);
#endif
      }

      ::DDS::ReturnCode_t
      RTI_DataReader_i::get_matched_publication_data (
        ::DDS::PublicationBuiltinTopicData & publication_data,
        DDS_INSTANCE_HANDLE_T_IN publication_handle)
      {
#if defined (CIAO_DDS4CCM_NDDS) && (CIAO_DDS4CCM_NDDS==1)
        ACE_UNUSED_ARG (publication_data);
        ACE_UNUSED_ARG (publication_handle);
        throw CORBA::NO_IMPLEMENT ();
        // Add your implementation here
#else
        return this->impl ()->get_matched_publication_data (publication_data, publication_handle);
#endif
      }

      DDSDataReader *
      RTI_DataReader_i::get_impl (void)
      {
        return this->impl_;
      }

      void
      RTI_DataReader_i::set_impl (DDSDataReader * dr)
      {
        this->impl_ = dr;
      }

      DDSDataReader *
      RTI_DataReader_i::impl (void)
      {
        if (!this->impl_)
          {
            throw ::CORBA::BAD_INV_ORDER ();
          }
        return this->impl_;
      }

    }
  }
}