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