00001 /* 00002 * 00003 * 00004 * Distributed under the OpenDDS License. 00005 * See: http://www.opendds.org/license.html 00006 */ 00007 00008 #include "TopicMonitorImpl.h" 00009 #include "monitorC.h" 00010 #include "monitorTypeSupportImpl.h" 00011 #include "dds/DCPS/TopicImpl.h" 00012 #include "dds/DCPS/DomainParticipantImpl.h" 00013 #include <dds/DdsDcpsInfrastructureC.h> 00014 00015 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL 00016 00017 namespace OpenDDS { 00018 namespace DCPS { 00019 00020 00021 TopicMonitorImpl::TopicMonitorImpl(TopicImpl* topic, 00022 OpenDDS::DCPS::TopicReportDataWriter_ptr topic_writer) 00023 : topic_(topic), 00024 topic_writer_(TopicReportDataWriter::_duplicate(topic_writer)) 00025 { 00026 } 00027 00028 TopicMonitorImpl::~TopicMonitorImpl() 00029 { 00030 } 00031 00032 void 00033 TopicMonitorImpl::report() { 00034 if (!CORBA::is_nil(this->topic_writer_.in())) { 00035 TopicReport report; 00036 DDS::DomainParticipant_var dp = this->topic_->get_participant(); 00037 DomainParticipantImpl* dp_impl = 00038 dynamic_cast<DomainParticipantImpl*>(dp.in()); 00039 if (dp_impl) { 00040 report.dp_id = dp_impl->get_id(); 00041 report.topic_id = this->topic_->get_id(); 00042 report.topic_name = this->topic_->get_name(); 00043 report.type_name = this->topic_->get_type_name(); 00044 this->topic_writer_->write(report, DDS::HANDLE_NIL); 00045 } else { 00046 ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) TopicMonitorImpl::report(): ") 00047 ACE_TEXT("failed to obtain DomainParticipantImpl.\n"))); 00048 } 00049 } 00050 } 00051 00052 00053 } // namespace DCPS 00054 } // namespace OpenDDS 00055 00056 OPENDDS_END_VERSIONED_NAMESPACE_DECL