forked from OpenDDS/OpenDDS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDRMonitorImpl.cpp
68 lines (58 loc) · 1.89 KB
/
DRMonitorImpl.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
57
58
59
60
61
62
63
64
65
66
67
68
/*
*
*
* Distributed under the OpenDDS License.
* See: http://www.opendds.org/license.html
*/
#include "DRMonitorImpl.h"
#include "monitorC.h"
#include "monitorTypeSupportImpl.h"
#include "dds/DCPS/DataReaderImpl.h"
#include <dds/DdsDcpsInfrastructureC.h>
OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
namespace OpenDDS {
namespace DCPS {
DRMonitorImpl::DRMonitorImpl(DataReaderImpl* dr,
OpenDDS::DCPS::DataReaderReportDataWriter_ptr dr_writer)
: dr_(dr),
dr_writer_(DataReaderReportDataWriter::_duplicate(dr_writer))
{
}
DRMonitorImpl::~DRMonitorImpl()
{
}
void
DRMonitorImpl::report() {
if (!CORBA::is_nil(this->dr_writer_.in())) {
DataReaderReport report;
report.dp_id = this->dr_->get_dp_id();
DDS::Subscriber_var sub = this->dr_->get_subscriber();
report.sub_handle = sub->get_instance_handle();
report.dr_id = this->dr_->get_repo_id();
report.topic_id = this->dr_->get_topic_id();
DataReaderImpl::InstanceHandleVec instances;
this->dr_->get_instance_handles(instances);
CORBA::ULong length = 0;
report.instances.length(static_cast<CORBA::ULong>(instances.size()));
for (DataReaderImpl::InstanceHandleVec::iterator iter = instances.begin();
iter != instances.end();
++iter) {
report.instances[length++] = *iter;
}
DataReaderImpl::WriterStatePairVec writer_states;
this->dr_->get_writer_states(writer_states);
length = 0;
report.associations.length(static_cast<CORBA::ULong>(writer_states.size()));
for (DataReaderImpl::WriterStatePairVec::iterator iter = writer_states.begin();
iter != writer_states.end();
++iter) {
report.associations[length].dw_id = iter->first;
report.associations[length].state = iter->second;
length++;
}
this->dr_writer_->write(report, DDS::HANDLE_NIL);
}
}
} // namespace DCPS
} // namespace OpenDDS
OPENDDS_END_VERSIONED_NAMESPACE_DECL