00001
00002
00003
00004
00005
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 namespace OpenDDS {
00015 namespace DCPS {
00016
00017
00018 DWMonitorImpl::DWMonitorImpl(DataWriterImpl* dw,
00019 OpenDDS::DCPS::DataWriterReportDataWriter_ptr dw_writer)
00020 : dw_(dw),
00021 dw_writer_(DataWriterReportDataWriter::_duplicate(dw_writer))
00022 {
00023 }
00024
00025 DWMonitorImpl::~DWMonitorImpl()
00026 {
00027 }
00028
00029 void
00030 DWMonitorImpl::report() {
00031 if (!CORBA::is_nil(this->dw_writer_.in())) {
00032 DataWriterReport report;
00033 report.dp_id = this->dw_->get_dp_id();
00034 DDS::Publisher_var pub = this->dw_->get_publisher();
00035 report.pub_handle = pub->get_instance_handle();
00036 report.dw_id = this->dw_->get_publication_id();
00037 DDS::Topic_var topic = this->dw_->get_topic();
00038 report.topic_id = dynamic_cast<TopicImpl*>(topic.in())->get_id();
00039 DataWriterImpl::InstanceHandleVec instances;
00040 this->dw_->get_instance_handles(instances);
00041 CORBA::ULong length = 0;
00042 report.instances.length(static_cast<CORBA::ULong>(instances.size()));
00043 for (DataWriterImpl::InstanceHandleVec::iterator iter = instances.begin();
00044 iter != instances.end();
00045 ++iter) {
00046 report.instances[length++] = *iter;
00047 }
00048 DCPS::RepoIdSet readers;
00049 this->dw_->get_readers(readers);
00050 length = 0;
00051 report.associations.length(static_cast<CORBA::ULong>(readers.size()));
00052 for (DCPS::RepoIdSet::iterator iter = readers.begin();
00053 iter != readers.end();
00054 ++iter) {
00055 report.associations[length].dr_id = *iter;
00056 length++;
00057 }
00058 this->dw_writer_->write(report, DDS::HANDLE_NIL);
00059 }
00060 }
00061
00062
00063 }
00064 }
00065