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

Generated on 10 Aug 2018 for OpenDDS by  doxygen 1.6.1