DPMonitorImpl.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 "DPMonitorImpl.h"
00009 #include "monitorC.h"
00010 #include "monitorTypeSupportImpl.h"
00011 #include "dds/DCPS/DomainParticipantImpl.h"
00012 #include <dds/DdsDcpsInfrastructureC.h>
00013 
00014 namespace OpenDDS {
00015 namespace DCPS {
00016 
00017 
00018 DPMonitorImpl::DPMonitorImpl(DomainParticipantImpl* dp,
00019               OpenDDS::DCPS::DomainParticipantReportDataWriter_ptr dp_writer)
00020   : dp_(dp),
00021     dp_writer_(DomainParticipantReportDataWriter::_duplicate(dp_writer))
00022 {
00023   char host[256];
00024   ACE_OS::hostname(host, 256);
00025   hostname_ = host;
00026   pid_ = ACE_OS::getpid();
00027 }
00028 
00029 DPMonitorImpl::~DPMonitorImpl()
00030 {
00031 }
00032 
00033 void
00034 DPMonitorImpl::report() {
00035   if (!CORBA::is_nil(this->dp_writer_.in())) {
00036     DomainParticipantReport report;
00037     report.host       = this->hostname_.c_str();
00038     report.pid        = this->pid_;
00039     report.dp_id      = this->dp_->get_id();
00040     report.domain_id  = this->dp_->get_domain_id();
00041     DomainParticipantImpl::TopicIdVec topics;
00042     this->dp_->get_topic_ids(topics);
00043     CORBA::ULong length = 0;
00044     report.topics.length(static_cast<CORBA::ULong>(topics.size()));
00045     for (DomainParticipantImpl::TopicIdVec::iterator iter = topics.begin();
00046          iter != topics.end();
00047          ++iter) {
00048       report.topics[length++] = *iter;
00049     }
00050     this->dp_writer_->write(report, DDS::HANDLE_NIL);
00051   }
00052 }
00053 
00054 
00055 } // namespace DCPS
00056 } // namespace OpenDDS
00057 

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