forked from OpenDDS/OpenDDS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTopicMonitorImpl.cpp
56 lines (46 loc) · 1.4 KB
/
TopicMonitorImpl.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
*
*
* Distributed under the OpenDDS License.
* See: http://www.opendds.org/license.html
*/
#include "TopicMonitorImpl.h"
#include "monitorC.h"
#include "monitorTypeSupportImpl.h"
#include "dds/DCPS/TopicImpl.h"
#include "dds/DCPS/DomainParticipantImpl.h"
#include <dds/DdsDcpsInfrastructureC.h>
OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
namespace OpenDDS {
namespace DCPS {
TopicMonitorImpl::TopicMonitorImpl(TopicImpl* topic,
OpenDDS::DCPS::TopicReportDataWriter_ptr topic_writer)
: topic_(topic),
topic_writer_(TopicReportDataWriter::_duplicate(topic_writer))
{
}
TopicMonitorImpl::~TopicMonitorImpl()
{
}
void
TopicMonitorImpl::report() {
if (!CORBA::is_nil(this->topic_writer_.in())) {
TopicReport report;
DDS::DomainParticipant_var dp = this->topic_->get_participant();
DomainParticipantImpl* dp_impl =
dynamic_cast<DomainParticipantImpl*>(dp.in());
if (dp_impl) {
report.dp_id = dp_impl->get_id();
report.topic_id = this->topic_->get_id();
report.topic_name = this->topic_->get_name();
report.type_name = this->topic_->get_type_name();
this->topic_writer_->write(report, DDS::HANDLE_NIL);
} else {
ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) TopicMonitorImpl::report(): ")
ACE_TEXT("failed to obtain DomainParticipantImpl.\n")));
}
}
}
} // namespace DCPS
} // namespace OpenDDS
OPENDDS_END_VERSIONED_NAMESPACE_DECL