DWMonitorImpl.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 "DWMonitorImpl.h"
00009 #include "monitorC.h"
00010 #include "monitorTypeSupportImpl.h"
00011 #include "dds/DCPS/DataWriterImpl.h"
00012 #include <dds/DdsDcpsInfrastructureC.h>
00013 
00014 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
00015 
00016 namespace OpenDDS {
00017 namespace DCPS {
00018 
00019 DWMonitorImpl::DWMonitorImpl(DataWriterImpl* dw,
00020               OpenDDS::DCPS::DataWriterReportDataWriter_ptr dw_writer)
00021   : dw_(dw),
00022     dw_writer_(DataWriterReportDataWriter::_duplicate(dw_writer))
00023 {
00024 }
00025 
00026 DWMonitorImpl::~DWMonitorImpl()
00027 {
00028 }
00029 
00030 void
00031 DWMonitorImpl::report() {
00032   if (!CORBA::is_nil(this->dw_writer_.in())) {
00033     DataWriterReport report;
00034     report.dp_id = this->dw_->get_dp_id();
00035     DDS::Publisher_var pub = this->dw_->get_publisher();
00036     report.pub_handle = pub->get_instance_handle();
00037     report.dw_id   = this->dw_->get_publication_id();
00038     DDS::Topic_var topic = this->dw_->get_topic();
00039     OpenDDS::DCPS::TopicImpl* ti = dynamic_cast<TopicImpl*>(topic.in());
00040     if (!ti) {
00041       ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) DWMonitorImpl::report():")
00042         ACE_TEXT(" failed to obtain TopicImpl.\n")));
00043       return;
00044     }
00045     report.topic_id = ti->get_id();
00046     DataWriterImpl::InstanceHandleVec instances;
00047     this->dw_->get_instance_handles(instances);
00048     CORBA::ULong length = 0;
00049     report.instances.length(static_cast<CORBA::ULong>(instances.size()));
00050     for (DataWriterImpl::InstanceHandleVec::iterator iter = instances.begin();
00051          iter != instances.end();
00052          ++iter) {
00053       report.instances[length++] = *iter;
00054     }
00055     DCPS::RepoIdSet readers;
00056     this->dw_->get_readers(readers);
00057     length = 0;
00058     report.associations.length(static_cast<CORBA::ULong>(readers.size()));
00059     for (DCPS::RepoIdSet::iterator iter = readers.begin();
00060          iter != readers.end();
00061          ++iter) {
00062       report.associations[length].dr_id = *iter;
00063       length++;
00064     }
00065     this->dw_writer_->write(report, DDS::HANDLE_NIL);
00066   }
00067 }
00068 
00069 
00070 } // namespace DCPS
00071 } // namespace OpenDDS
00072 
00073 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