OpenDDS  Snapshot(2023/04/07-19:43)
Public Member Functions | Private Attributes | List of all members
OpenDDS::DCPS::SPMonitorImpl Class Reference

#include <SPMonitorImpl.h>

Inheritance diagram for OpenDDS::DCPS::SPMonitorImpl:
Inheritance graph
[legend]
Collaboration diagram for OpenDDS::DCPS::SPMonitorImpl:
Collaboration graph
[legend]

Public Member Functions

 SPMonitorImpl (MonitorFactoryImpl *monitor_factory, Service_Participant *sp)
 
virtual ~SPMonitorImpl ()
 
virtual void report ()
 
- Public Member Functions inherited from OpenDDS::DCPS::Monitor
 Monitor ()
 
virtual ~Monitor ()
 

Private Attributes

MonitorFactoryImplmonitor_factory_
 
OpenDDS::DCPS::ServiceParticipantReportDataWriter_var sp_writer_
 
std::string hostname_
 
pid_t pid_
 

Detailed Description

Definition at line 26 of file SPMonitorImpl.h.

Constructor & Destructor Documentation

◆ SPMonitorImpl()

OpenDDS::DCPS::SPMonitorImpl::SPMonitorImpl ( MonitorFactoryImpl monitor_factory,
Service_Participant sp 
)

Definition at line 22 of file SPMonitorImpl.cpp.

References ACE_OS::getpid(), ACE_OS::hostname(), hostname_, and pid_.

24  : monitor_factory_(monitor_factory)
25 {
26  char host[256];
27  ACE_OS::hostname(host, 256);
28  hostname_ = host;
29  pid_ = ACE_OS::getpid();
30 }
int hostname(char name[], size_t maxnamelen)
MonitorFactoryImpl * monitor_factory_
Definition: SPMonitorImpl.h:34
pid_t getpid(void)

◆ ~SPMonitorImpl()

OpenDDS::DCPS::SPMonitorImpl::~SPMonitorImpl ( )
virtual

Definition at line 32 of file SPMonitorImpl.cpp.

33 {
34 }

Member Function Documentation

◆ report()

void OpenDDS::DCPS::SPMonitorImpl::report ( )
virtual

Implements OpenDDS::DCPS::Monitor.

Definition at line 37 of file SPMonitorImpl.cpp.

References ACE_ERROR, ACE_TEXT(), OpenDDS::DCPS::ServiceParticipantReport::domain_participants, OpenDDS::DCPS::MonitorFactoryImpl::get_sp_writer(), DDS::HANDLE_NIL, OpenDDS::DCPS::ServiceParticipantReport::host, hostname_, CORBA::is_nil(), LM_ERROR, monitor_factory_, OPENDDS_END_VERSIONED_NAMESPACE_DECL, OpenDDS::DCPS::DomainParticipantFactoryImpl::participants(), OpenDDS::DCPS::ServiceParticipantReport::pid, pid_, sp_writer_, and TheParticipantFactory.

38 {
39  if (CORBA::is_nil(this->sp_writer_.in())) {
40  this->sp_writer_ = this->monitor_factory_->get_sp_writer();
41  }
42 
43  // If the SP writer is not available, it is too soon to report
44  if (!CORBA::is_nil(this->sp_writer_.in())) {
45  ServiceParticipantReport report;
46  report.host = this->hostname_.c_str();
47  report.pid = this->pid_;
48  DDS::DomainParticipantFactory_var pf = TheParticipantFactory;
49 
50  OpenDDS::DCPS::DomainParticipantFactoryImpl* pi = dynamic_cast<DomainParticipantFactoryImpl*>(pf.in());
51  if (!pi) {
52  ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) SPMonitorImpl::report():")
53  ACE_TEXT(" failed to obtain DomainParticipantFactoryImpl.\n")));
54  return;
55  }
56 
57  const DomainParticipantFactoryImpl::DPMap& participants = pi->participants();
58  CORBA::ULong length = 0;
59  for (DomainParticipantFactoryImpl::DPMap::const_iterator mapIter = participants.begin();
60  mapIter != participants.end();
61  ++mapIter) {
62  for (DomainParticipantFactoryImpl::DPSet::const_iterator iter = mapIter->second.begin();
63  iter != mapIter->second.end();
64  ++iter) {
65  report.domain_participants.length(length+1);
66  report.domain_participants[length] = (*iter)->get_id();
67  length++;
68  }
69  }
70  length = 0;
71  // TODO: Redo the transport-related monitor publishing here...
72  //const TransportFactory::ImplMap& transports =
73  // TransportFactory::instance()->get_transport_impl_map();
74  //report.transports.length(static_cast<CORBA::ULong>(transports.size()));
75  //for (TransportFactory::ImplMap::const_iterator mapIter = transports.begin();
76  // mapIter != transports.end();
77  // ++mapIter) {
78  // report.transports[length++] = mapIter->first;
79  //}
80  this->sp_writer_->write(report, DDS::HANDLE_NIL);
81  }
82 }
#define ACE_ERROR(X)
DPMap participants() const
Make a copy of the participants map for reading.
const InstanceHandle_t HANDLE_NIL
Implements the OpenDDS::DCPS::DomainParticipantFactory interfaces.
ACE_CDR::ULong ULong
MonitorFactoryImpl * monitor_factory_
Definition: SPMonitorImpl.h:34
ACE_TEXT("TCP_Factory")
ServiceParticipantReportDataWriter_ptr get_sp_writer()
#define TheParticipantFactory
Boolean is_nil(T x)
OpenDDS::DCPS::ServiceParticipantReportDataWriter_var sp_writer_
Definition: SPMonitorImpl.h:35

Member Data Documentation

◆ hostname_

std::string OpenDDS::DCPS::SPMonitorImpl::hostname_
private

Definition at line 36 of file SPMonitorImpl.h.

Referenced by report(), and SPMonitorImpl().

◆ monitor_factory_

MonitorFactoryImpl* OpenDDS::DCPS::SPMonitorImpl::monitor_factory_
private

Definition at line 34 of file SPMonitorImpl.h.

Referenced by report().

◆ pid_

pid_t OpenDDS::DCPS::SPMonitorImpl::pid_
private

Definition at line 37 of file SPMonitorImpl.h.

Referenced by report(), and SPMonitorImpl().

◆ sp_writer_

OpenDDS::DCPS::ServiceParticipantReportDataWriter_var OpenDDS::DCPS::SPMonitorImpl::sp_writer_
private

Definition at line 35 of file SPMonitorImpl.h.

Referenced by report().


The documentation for this class was generated from the following files: