SPMonitorImpl.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 "SPMonitorImpl.h"
00009 #include "MonitorFactoryImpl.h"
00010 #include "monitorC.h"
00011 #include "monitorTypeSupportImpl.h"
00012 #include "dds/DCPS/Service_Participant.h"
00013 #include "dds/DCPS/DomainParticipantImpl.h"
00014 #include <dds/DdsDcpsInfrastructureC.h>
00015 
00016 namespace OpenDDS {
00017 namespace DCPS {
00018 
00019 
00020 SPMonitorImpl::SPMonitorImpl(MonitorFactoryImpl* monitor_factory,
00021                              Service_Participant* /*sp*/)
00022     : monitor_factory_(monitor_factory)
00023 {
00024   char host[256];
00025   ACE_OS::hostname(host, 256);
00026   hostname_ = host;
00027   pid_ = ACE_OS::getpid();
00028 }
00029 
00030 SPMonitorImpl::~SPMonitorImpl()
00031 {
00032 }
00033 
00034 void
00035 SPMonitorImpl::report()
00036 {
00037   if (CORBA::is_nil(this->sp_writer_.in())) {
00038     this->sp_writer_ = this->monitor_factory_->get_sp_writer();
00039   }
00040 
00041   // If the SP writer is not available, it is too soon to report
00042   if (!CORBA::is_nil(this->sp_writer_.in())) {
00043     ServiceParticipantReport report;
00044     report.host = this->hostname_.c_str();
00045     report.pid  = this->pid_;
00046     DDS::DomainParticipantFactory_var pf = TheParticipantFactory;
00047     const DomainParticipantFactoryImpl::DPMap& participants =
00048       dynamic_cast<DomainParticipantFactoryImpl*>(pf.in())->participants();
00049     CORBA::ULong length = 0;
00050     for (DomainParticipantFactoryImpl::DPMap::const_iterator mapIter = participants.begin();
00051          mapIter != participants.end();
00052          ++mapIter) {
00053       for (DomainParticipantFactoryImpl::DPSet::const_iterator iter = mapIter->second.begin();
00054            iter != mapIter->second.end();
00055            ++iter) {
00056         report.domain_participants.length(length+1);
00057         report.domain_participants[length] = iter->svt_->get_id();
00058         length++;
00059       }
00060     }
00061     length = 0;
00062     // TODO: Redo the transport-related monitor publishing here...
00063     //const TransportFactory::ImplMap& transports =
00064     //  TransportFactory::instance()->get_transport_impl_map();
00065     //report.transports.length(static_cast<CORBA::ULong>(transports.size()));
00066     //for (TransportFactory::ImplMap::const_iterator mapIter = transports.begin();
00067     //     mapIter != transports.end();
00068     //     ++mapIter) {
00069     //  report.transports[length++] = mapIter->first;
00070     //}
00071     this->sp_writer_->write(report, DDS::HANDLE_NIL);
00072   }
00073 }
00074 
00075 } // namespace DCPS
00076 } // namespace OpenDDS
00077 

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