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