00001 /* 00002 * 00003 * 00004 * Distributed under the OpenDDS License. 00005 * See: http://www.opendds.org/license.html 00006 */ 00007 00008 #include "PublisherMonitorImpl.h" 00009 #include "monitorC.h" 00010 #include "monitorTypeSupportImpl.h" 00011 #include "dds/DCPS/PublisherImpl.h" 00012 #include <dds/DdsDcpsInfrastructureC.h> 00013 #include <dds/DCPS/DomainParticipantImpl.h> 00014 00015 namespace OpenDDS { 00016 namespace DCPS { 00017 00018 00019 PublisherMonitorImpl::PublisherMonitorImpl(PublisherImpl* pub, 00020 OpenDDS::DCPS::PublisherReportDataWriter_ptr pub_writer) 00021 : pub_(pub), 00022 pub_writer_(PublisherReportDataWriter::_duplicate(pub_writer)) 00023 { 00024 } 00025 00026 PublisherMonitorImpl::~PublisherMonitorImpl() 00027 { 00028 } 00029 00030 void 00031 PublisherMonitorImpl::report() { 00032 if (!CORBA::is_nil(this->pub_writer_.in())) { 00033 PublisherReport report; 00034 report.handle = pub_->get_instance_handle(); 00035 DDS::DomainParticipant_var dp = pub_->get_participant(); 00036 report.dp_id = dynamic_cast<DomainParticipantImpl*>(dp.in())->get_id(); 00037 TransportImpl_rch ti; //TODO: transport = pub_->get_transport_impl(); 00038 // TODO: remove/replace 00039 report.transport_id = 0; 00040 PublisherImpl::PublicationIdVec writers; 00041 pub_->get_publication_ids(writers); 00042 CORBA::ULong length = 0; 00043 report.writers.length(static_cast<CORBA::ULong>(writers.size())); 00044 for (PublisherImpl::PublicationIdVec::iterator iter = writers.begin(); 00045 iter != writers.end(); 00046 ++iter) { 00047 report.writers[length++] = *iter; 00048 } 00049 this->pub_writer_->write(report, DDS::HANDLE_NIL); 00050 } 00051 } 00052 00053 00054 } // namespace DCPS 00055 } // namespace OpenDDS 00056