OpenDDS  Snapshot(2023/04/28-20:55)
DWMonitorImpl.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 "DWMonitorImpl.h"
9 #include "monitorC.h"
10 #include "monitorTypeSupportImpl.h"
12 #include <dds/DdsDcpsInfrastructureC.h>
13 
15 
16 namespace OpenDDS {
17 namespace DCPS {
18 
20  OpenDDS::DCPS::DataWriterReportDataWriter_ptr dw_writer)
21  : dw_(dw)
22  , dw_writer_(DataWriterReportDataWriter::_duplicate(dw_writer))
23 {
24 }
25 
27 {
28 }
29 
30 void
32  if (!CORBA::is_nil(dw_writer_.in())) {
34  report.dp_id = dw_->get_dp_id();
35  DDS::Publisher_var pub = dw_->get_publisher();
36  report.pub_handle = pub->get_instance_handle();
37  report.dw_id = dw_->get_guid();
38  DDS::Topic_var topic = dw_->get_topic();
39  OpenDDS::DCPS::TopicImpl* ti = dynamic_cast<TopicImpl*>(topic.in());
40  if (!ti) {
41  ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) DWMonitorImpl::report():")
42  ACE_TEXT(" failed to obtain TopicImpl.\n")));
43  return;
44  }
45  report.topic_id = ti->get_id();
46  DataWriterImpl::InstanceHandleVec instances;
47  dw_->get_instance_handles(instances);
48  CORBA::ULong length = 0;
49  report.instances.length(static_cast<CORBA::ULong>(instances.size()));
50  for (DataWriterImpl::InstanceHandleVec::iterator iter = instances.begin();
51  iter != instances.end();
52  ++iter) {
53  report.instances[length++] = *iter;
54  }
55  DCPS::RepoIdSet readers;
56  dw_->get_readers(readers);
57  length = 0;
58  report.associations.length(static_cast<CORBA::ULong>(readers.size()));
59  for (DCPS::RepoIdSet::iterator iter = readers.begin();
60  iter != readers.end();
61  ++iter) {
62  report.associations[length].dr_id = *iter;
63  length++;
64  }
65  dw_writer_->write(report, DDS::HANDLE_NIL);
66  }
67 }
68 
69 } // namespace DCPS
70 } // namespace OpenDDS
71 
#define ACE_ERROR(X)
const InstanceHandle_t HANDLE_NIL
GuidSet RepoIdSet
Definition: GuidUtils.h:113
T * _duplicate(T *st)
OpenDDS::DCPS::DataWriterReportDataWriter_var dw_writer_
Definition: DWMonitorImpl.h:33
Implements the DDS::Topic interface.
Definition: TopicImpl.h:37
GUID_t topic_id
GUID for the Topic this Data Writer is using.
Definition: monitor.idl:121
Implements the OpenDDS::DCPS::DataWriterRemote interfaces and DDS::DataWriter interfaces.
virtual DDS::Topic_ptr get_topic()
void get_readers(RepoIdSet &readers)
GUID_t dp_id
GUID of the Domain Participant this Data Writer belongs to.
Definition: monitor.idl:115
ACE_CDR::ULong ULong
DWAssociations associations
Sequence of Data Reader GUIDs that this Data Writer is associated with.
Definition: monitor.idl:125
void get_instance_handles(InstanceHandleVec &instance_handles)
ACE_TEXT("TCP_Factory")
virtual DDS::Publisher_ptr get_publisher()
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
LM_ERROR
The Internal API and Implementation of OpenDDS.
Definition: AddressCache.h:28
key GUID_t dw_id
GUID for the Data Writer.
Definition: monitor.idl:119
DDS::InstanceHandleSeq instances
Sequence of instances that this Data Writer has registered.
Definition: monitor.idl:123
Boolean is_nil(T x)
DDS::InstanceHandle_t pub_handle
Instance handle of this Data Writer&#39;s Publisher.
Definition: monitor.idl:117
GUID_t get_id() const
Definition: TopicImpl.cpp:172
DWMonitorImpl(DataWriterImpl *dw, OpenDDS::DCPS::DataWriterReportDataWriter_ptr dw_writer)