DRMonitorImpl.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 "DRMonitorImpl.h"
00009 #include "monitorC.h"
00010 #include "monitorTypeSupportImpl.h"
00011 #include "dds/DCPS/DataReaderImpl.h"
00012 #include <dds/DdsDcpsInfrastructureC.h>
00013 
00014 namespace OpenDDS {
00015 namespace DCPS {
00016 
00017 
00018 DRMonitorImpl::DRMonitorImpl(DataReaderImpl* dr,
00019               OpenDDS::DCPS::DataReaderReportDataWriter_ptr dr_writer)
00020   : dr_(dr),
00021     dr_writer_(DataReaderReportDataWriter::_duplicate(dr_writer))
00022 {
00023 }
00024 
00025 DRMonitorImpl::~DRMonitorImpl()
00026 {
00027 }
00028 
00029 void
00030 DRMonitorImpl::report() {
00031   if (!CORBA::is_nil(this->dr_writer_.in())) {
00032     DataReaderReport report;
00033     report.dp_id = this->dr_->get_dp_id();
00034     DDS::Subscriber_var sub = this->dr_->get_subscriber();
00035     report.sub_handle = sub->get_instance_handle();
00036     report.dr_id   = this->dr_->get_subscription_id();
00037     report.topic_id = this->dr_->get_topic_id();
00038     DataReaderImpl::InstanceHandleVec instances;
00039     this->dr_->get_instance_handles(instances);
00040     CORBA::ULong length = 0;
00041     report.instances.length(static_cast<CORBA::ULong>(instances.size()));
00042     for (DataReaderImpl::InstanceHandleVec::iterator iter = instances.begin();
00043          iter != instances.end();
00044          ++iter) {
00045       report.instances[length++] = *iter;
00046     }
00047     DataReaderImpl::WriterStatePairVec writer_states;
00048     this->dr_->get_writer_states(writer_states);
00049     length = 0;
00050     report.associations.length(static_cast<CORBA::ULong>(writer_states.size()));
00051     for (DataReaderImpl::WriterStatePairVec::iterator iter = writer_states.begin();
00052          iter != writer_states.end();
00053          ++iter) {
00054       report.associations[length].dw_id = iter->first;
00055       report.associations[length].state = iter->second;
00056       length++;
00057     }
00058     this->dr_writer_->write(report, DDS::HANDLE_NIL);
00059   }
00060 }
00061 
00062 
00063 } // namespace DCPS
00064 } // namespace OpenDDS
00065 

Generated on Fri Feb 12 20:05:23 2016 for OpenDDS by  doxygen 1.4.7