-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDataReader_Aux2Strings.cpp
73 lines (57 loc) · 1.75 KB
/
DataReader_Aux2Strings.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
69
70
71
72
73
#include "DataReader_Aux2Strings.h"
#include "DataReaderListenerImpl_Aux2Strings.h"
#include <dds/DCPS/Marked_Default_Qos.h>
DataReader_Aux2Strings::DataReader_Aux2Strings(DDS::DomainParticipant_var m_participant, DDS::Subscriber_var subscriber, const char * topic_name)
{
this->participant = m_participant;
this->subscriber = subscriber;
this->topic = createTopic(topic_name);
// Create Listener
DataReaderListenerImpl_Aux2Strings* listener_impl = new DataReaderListenerImpl_Aux2Strings;
DDS::DataReaderListener_var m_listener(listener_impl);
this->reader = createDataReader(subscriber, topic, m_listener);
}
DataReader_Aux2Strings::~DataReader_Aux2Strings()
{
}
DDS::Topic_var
DataReader_Aux2Strings::createTopic(const char * topic_name)
{
// Register TypeSupport
Mri::Aux2StringsTypeSupport_var ts =
new Mri::Aux2StringsTypeSupportImpl;
if (ts->register_type(participant, "") != DDS::RETCODE_OK) {
throw std::string("failed to register type support");
}
// Create Topic (Mri_Control)
CORBA::String_var type_name = ts->get_type_name();
DDS::Topic_var topic =
participant->create_topic(topic_name,
type_name,
TOPIC_QOS_DEFAULT,
DDS::TopicListener::_nil(),
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
// Check for failure
if (!topic) {
throw std::string("failed to create topic");
}
return topic;
}
DDS::DataReader_var
DataReader_Aux2Strings::createDataReader(
DDS::Subscriber_var subscriber,
DDS::Topic_var topic,
DDS::DataReaderListener_var listener)
{
// Create DataReader
DDS::DataReader_var reader =
subscriber->create_datareader(topic,
DATAREADER_QOS_DEFAULT,
listener,
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
// Check for failure
if (!reader) {
throw std::string("failed to create data reader");
}
return reader;
}