OpenDDS  Snapshot(2023/04/28-20:55)
SubscriberMonitorImpl.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 
9 #include "monitorC.h"
10 #include "monitorTypeSupportImpl.h"
12 #include <dds/DdsDcpsInfrastructureC.h>
14 
16 
17 namespace OpenDDS {
18 namespace DCPS {
19 
20 
22  OpenDDS::DCPS::SubscriberReportDataWriter_ptr sub_writer)
23  : sub_(sub),
24  sub_writer_(SubscriberReportDataWriter::_duplicate(sub_writer))
25 {
26 }
27 
29 {
30 }
31 
32 void
34  if (!CORBA::is_nil(this->sub_writer_.in())) {
36  report.handle = sub_->get_instance_handle();
37  DDS::DomainParticipant_var dp = sub_->get_participant();
38  OpenDDS::DCPS::DomainParticipantImpl* dpi = dynamic_cast<DomainParticipantImpl*>(dp.in());
39  if (!dpi) {
40  ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) SubscriberMonitorImpl::report():")
41  ACE_TEXT(" failed to obtain DomainParticipantImpl.\n")));
42  return;
43  }
44  report.dp_id = dpi->get_id();
45  TransportImpl_rch ti; //TODO: transport = sub_->get_transport_impl();
46  // TODO: remove transport_id and replace with name
47  report.transport_id = 0;
48  SubscriberImpl::SubscriptionIdVec readers;
49  sub_->get_subscription_ids(readers);
50  CORBA::ULong length = 0;
51  report.readers.length(static_cast<CORBA::ULong>(readers.size()));
52  for (SubscriberImpl::SubscriptionIdVec::iterator iter = readers.begin();
53  iter != readers.end();
54  ++iter) {
55  report.readers[length++] = *iter;
56  }
57  this->sub_writer_->write(report, DDS::HANDLE_NIL);
58  }
59 }
60 
61 
62 } // namespace DCPS
63 } // namespace OpenDDS
64 
Implements the OpenDDS::DCPS::DomainParticipant interfaces.
#define ACE_ERROR(X)
const InstanceHandle_t HANDLE_NIL
key GUID_t dp_id
GUID of the Domain Participant this Subscriber belongs to.
Definition: monitor.idl:101
virtual DDS::InstanceHandle_t get_instance_handle()
SubscriberMonitorImpl(SubscriberImpl *sub, OpenDDS::DCPS::SubscriberReportDataWriter_ptr sub_writer)
T * _duplicate(T *st)
ACE_CDR::ULong ULong
void get_subscription_ids(SubscriptionIdVec &subs)
key DDS::InstanceHandle_t handle
Instance handle of this Subscriber. Unique within the DP.
Definition: monitor.idl:99
ACE_TEXT("TCP_Factory")
virtual DDS::DomainParticipant_ptr get_participant()
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
LM_ERROR
The Internal API and Implementation of OpenDDS.
Definition: AddressCache.h:28
Boolean is_nil(T x)
OpenDDS::DCPS::SubscriberReportDataWriter_var sub_writer_