SubscriberMonitorImpl.cpp

Go to the documentation of this file.
00001 /*
00002  *
00003  *
00004  * Distributed under the OpenDDS License.
00005  * See: http://www.opendds.org/license.html
00006  */
00007 
00008 #include "SubscriberMonitorImpl.h"
00009 #include "monitorC.h"
00010 #include "monitorTypeSupportImpl.h"
00011 #include "dds/DCPS/SubscriberImpl.h"
00012 #include <dds/DdsDcpsInfrastructureC.h>
00013 #include <dds/DCPS/DomainParticipantImpl.h>
00014 
00015 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
00016 
00017 namespace OpenDDS {
00018 namespace DCPS {
00019 
00020 
00021 SubscriberMonitorImpl::SubscriberMonitorImpl(SubscriberImpl* sub,
00022               OpenDDS::DCPS::SubscriberReportDataWriter_ptr sub_writer)
00023   : sub_(sub),
00024     sub_writer_(SubscriberReportDataWriter::_duplicate(sub_writer))
00025 {
00026 }
00027 
00028 SubscriberMonitorImpl::~SubscriberMonitorImpl()
00029 {
00030 }
00031 
00032 void
00033 SubscriberMonitorImpl::report() {
00034   if (!CORBA::is_nil(this->sub_writer_.in())) {
00035     SubscriberReport report;
00036     report.handle = sub_->get_instance_handle();
00037     DDS::DomainParticipant_var dp = sub_->get_participant();
00038     OpenDDS::DCPS::DomainParticipantImpl* dpi = dynamic_cast<DomainParticipantImpl*>(dp.in());
00039     if (!dpi) {
00040       ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) SubscriberMonitorImpl::report():")
00041         ACE_TEXT(" failed to obtain DomainParticipantImpl.\n")));
00042       return;
00043     }
00044     report.dp_id   = dpi->get_id();
00045     TransportImpl_rch ti; //TODO: transport    = sub_->get_transport_impl();
00046     // TODO: remove transport_id and replace with name
00047     report.transport_id = 0;
00048     SubscriberImpl::SubscriptionIdVec readers;
00049     sub_->get_subscription_ids(readers);
00050     CORBA::ULong length = 0;
00051     report.readers.length(static_cast<CORBA::ULong>(readers.size()));
00052     for (SubscriberImpl::SubscriptionIdVec::iterator iter = readers.begin();
00053          iter != readers.end();
00054          ++iter) {
00055       report.readers[length++] = *iter;
00056     }
00057     this->sub_writer_->write(report, DDS::HANDLE_NIL);
00058   }
00059 }
00060 
00061 
00062 } // namespace DCPS
00063 } // namespace OpenDDS
00064 
00065 OPENDDS_END_VERSIONED_NAMESPACE_DECL
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 10 Aug 2018 for OpenDDS by  doxygen 1.6.1