OpenDDS  Snapshot(2023/04/28-20:55)
DRMonitorImpl.cpp
Go to the documentation of this file.
1 /*
2  *
3  *
4  * Distributed under the OpenDDS License.
5  * See: http://www.opendds.org/license.html
6  */
7 
8 #include "DRMonitorImpl.h"
9 #include "monitorC.h"
10 #include "monitorTypeSupportImpl.h"
12 #include <dds/DdsDcpsInfrastructureC.h>
13 
15 
16 namespace OpenDDS {
17 namespace DCPS {
18 
19 
21  OpenDDS::DCPS::DataReaderReportDataWriter_ptr dr_writer)
22  : dr_(dr)
23  , dr_writer_(DataReaderReportDataWriter::_duplicate(dr_writer))
24 {
25 }
26 
28 {
29 }
30 
31 void
33  if (!CORBA::is_nil(dr_writer_.in())) {
35  report.dp_id = dr_->get_dp_id();
36  DDS::Subscriber_var sub = dr_->get_subscriber();
37  report.sub_handle = sub->get_instance_handle();
38  report.dr_id = dr_->get_guid();
39  report.topic_id = dr_->get_topic_id();
40  DataReaderImpl::InstanceHandleVec instances;
41  dr_->get_instance_handles(instances);
42  CORBA::ULong length = 0;
43  report.instances.length(static_cast<CORBA::ULong>(instances.size()));
44  for (DataReaderImpl::InstanceHandleVec::iterator iter = instances.begin();
45  iter != instances.end();
46  ++iter) {
47  report.instances[length++] = *iter;
48  }
49  DataReaderImpl::WriterStatePairVec writer_states;
50  dr_->get_writer_states(writer_states);
51  length = 0;
52  report.associations.length(static_cast<CORBA::ULong>(writer_states.size()));
53  for (DataReaderImpl::WriterStatePairVec::iterator iter = writer_states.begin();
54  iter != writer_states.end();
55  ++iter) {
56  report.associations[length].dw_id = iter->first;
57  report.associations[length].state = iter->second;
58  length++;
59  }
60  dr_writer_->write(report, DDS::HANDLE_NIL);
61  }
62 }
63 
64 } // namespace DCPS
65 } // namespace OpenDDS
66 
GUID_t topic_id
GUID for the Topic this Data Reader is using.
Definition: monitor.idl:161
const InstanceHandle_t HANDLE_NIL
DDS::InstanceHandleSeq instances
Sequence of instances that this Data Reader has received.
Definition: monitor.idl:163
virtual DDS::Subscriber_ptr get_subscriber()
void get_writer_states(WriterStatePairVec &writer_states)
T * _duplicate(T *st)
OpenDDS::DCPS::DataReaderReportDataWriter_var dr_writer_
Definition: DRMonitorImpl.h:33
ACE_CDR::ULong ULong
key GUID_t dr_id
GUID for the Data Reader.
Definition: monitor.idl:159
Implements the DDS::DataReader interface.
void get_instance_handles(InstanceHandleVec &instance_handles)
DRMonitorImpl(DataReaderImpl *dr, OpenDDS::DCPS::DataReaderReportDataWriter_ptr dr_writer)
DRAssociations associations
Sequence of Data Writer GUIDs that this Data Reader is associated with.
Definition: monitor.idl:165
GUID_t dp_id
GUID of the Domain Participant this Data Reader belongs to.
Definition: monitor.idl:155
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
The Internal API and Implementation of OpenDDS.
Definition: AddressCache.h:28
DDS::InstanceHandle_t sub_handle
Instance handle of this Data Reader&#39;s Subscriber.
Definition: monitor.idl:157
Boolean is_nil(T x)