Line data Source code
1 : /*
2 : * Distributed under the OpenDDS License.
3 : * See: http://www.opendds.org/license.html
4 : */
5 :
6 : #include <DCPS/DdsDcps_pch.h> // Only the _pch include should start with DCPS/
7 :
8 : #include "Discovery.h"
9 :
10 : #include "Service_Participant.h"
11 : #include "BuiltInTopicUtils.h"
12 : #include "Registered_Data_Types.h"
13 : #include "Marked_Default_Qos.h"
14 : #include "SafetyProfileStreams.h"
15 : #include "DCPS_Utils.h"
16 :
17 : #include <dds/DdsDcpsCoreC.h>
18 : #include <dds/OpenddsDcpsExtC.h>
19 : #ifndef DDS_HAS_MINIMUM_BIT
20 : # include <dds/DdsDcpsCoreTypeSupportImpl.h>
21 : # include <dds/OpenddsDcpsExtTypeSupportImpl.h>
22 : #endif
23 :
24 : OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
25 :
26 : namespace OpenDDS {
27 : namespace DCPS {
28 :
29 0 : DDS::ReturnCode_t TypeObjReqCond::wait()
30 : {
31 0 : ThreadStatusManager& thread_status_manager = TheServiceParticipant->get_thread_status_manager();
32 0 : while (waiting) {
33 0 : cond.wait(thread_status_manager);
34 : }
35 0 : return rc;
36 : }
37 :
38 0 : void TypeObjReqCond::done(DDS::ReturnCode_t retcode)
39 : {
40 0 : ACE_GUARD(LockType, g, lock);
41 0 : waiting = false;
42 0 : rc = retcode;
43 0 : cond.notify_all();
44 0 : }
45 :
46 : const char* Discovery::DEFAULT_REPO = "DEFAULT_REPO";
47 : const char* Discovery::DEFAULT_RTPS = "DEFAULT_RTPS";
48 : const char* Discovery::DEFAULT_STATIC = "DEFAULT_STATIC";
49 :
50 : DDS::ReturnCode_t
51 0 : Discovery::create_bit_topics(DomainParticipantImpl* participant)
52 : {
53 : #ifndef DDS_HAS_MINIMUM_BIT
54 :
55 : TypeSupport_var type_support =
56 0 : Registered_Data_Types->lookup(participant, BUILT_IN_PARTICIPANT_TOPIC_TYPE);
57 :
58 0 : if (CORBA::is_nil(type_support)) {
59 : // Participant topic
60 : DDS::ParticipantBuiltinTopicDataTypeSupport_var ts =
61 0 : new DDS::ParticipantBuiltinTopicDataTypeSupportImpl;
62 :
63 0 : const DDS::ReturnCode_t ret = ts->register_type(participant,
64 : BUILT_IN_PARTICIPANT_TOPIC_TYPE);
65 :
66 0 : if (ret != DDS::RETCODE_OK) {
67 0 : ACE_ERROR_RETURN((LM_ERROR,
68 : ACE_TEXT("(%P|%t) ")
69 : ACE_TEXT("Discovery::create_bit_topics, ")
70 : ACE_TEXT("register BUILT_IN_PARTICIPANT_TOPIC_TYPE returned %d.\n"),
71 : ret),
72 : ret);
73 : }
74 0 : }
75 :
76 : DDS::Topic_var bit_part_topic =
77 0 : participant->create_topic(BUILT_IN_PARTICIPANT_TOPIC,
78 : BUILT_IN_PARTICIPANT_TOPIC_TYPE,
79 0 : TOPIC_QOS_DEFAULT,
80 : DDS::TopicListener::_nil(),
81 0 : DEFAULT_STATUS_MASK);
82 :
83 0 : if (CORBA::is_nil(bit_part_topic)) {
84 0 : ACE_ERROR_RETURN((LM_ERROR,
85 : ACE_TEXT("(%P|%t) ")
86 : ACE_TEXT("Discovery::create_bit_topics, ")
87 : ACE_TEXT("Nil %C Topic\n"),
88 : BUILT_IN_PARTICIPANT_TOPIC),
89 : DDS::RETCODE_ERROR);
90 : }
91 :
92 : // Participant location topic
93 : type_support =
94 0 : Registered_Data_Types->lookup(participant, BUILT_IN_PARTICIPANT_LOCATION_TOPIC_TYPE);
95 :
96 0 : if (CORBA::is_nil(type_support)) {
97 : OpenDDS::DCPS::ParticipantLocationBuiltinTopicDataTypeSupport_var ts =
98 0 : new OpenDDS::DCPS::ParticipantLocationBuiltinTopicDataTypeSupportImpl;
99 :
100 0 : const DDS::ReturnCode_t ret = ts->register_type(participant,
101 : BUILT_IN_PARTICIPANT_LOCATION_TOPIC_TYPE);
102 :
103 0 : if (ret != DDS::RETCODE_OK) {
104 0 : ACE_ERROR_RETURN((LM_ERROR,
105 : ACE_TEXT("(%P|%t) ")
106 : ACE_TEXT("Discovery::create_bit_topics, ")
107 : ACE_TEXT("register BUILT_IN_PARTICIPANT_LOCATION_TOPIC_TYPE returned %C.\n"),
108 : retcode_to_string(ret)),
109 : ret);
110 : }
111 0 : }
112 :
113 : DDS::Topic_var bit_part_loc_topic =
114 0 : participant->create_topic(BUILT_IN_PARTICIPANT_LOCATION_TOPIC,
115 : BUILT_IN_PARTICIPANT_LOCATION_TOPIC_TYPE,
116 0 : TOPIC_QOS_DEFAULT,
117 : DDS::TopicListener::_nil(),
118 0 : DEFAULT_STATUS_MASK);
119 :
120 0 : if (CORBA::is_nil(bit_part_loc_topic)) {
121 0 : ACE_ERROR_RETURN((LM_ERROR,
122 : ACE_TEXT("(%P|%t) ")
123 : ACE_TEXT("Discovery::create_bit_topics, ")
124 : ACE_TEXT("Nil %C Topic\n"),
125 : BUILT_IN_PARTICIPANT_LOCATION_TOPIC),
126 : DDS::RETCODE_ERROR);
127 : }
128 :
129 : // Internal thread status topic
130 : type_support =
131 0 : Registered_Data_Types->lookup(participant, BUILT_IN_INTERNAL_THREAD_TOPIC_TYPE);
132 :
133 0 : if (CORBA::is_nil(type_support)) {
134 : OpenDDS::DCPS::InternalThreadBuiltinTopicDataTypeSupport_var ts =
135 0 : new OpenDDS::DCPS::InternalThreadBuiltinTopicDataTypeSupportImpl;
136 :
137 0 : const DDS::ReturnCode_t ret = ts->register_type(participant,
138 : BUILT_IN_INTERNAL_THREAD_TOPIC_TYPE);
139 :
140 0 : if (ret != DDS::RETCODE_OK) {
141 0 : ACE_ERROR_RETURN((LM_ERROR,
142 : ACE_TEXT("(%P|%t) ")
143 : ACE_TEXT("Discovery::create_bit_topics, ")
144 : ACE_TEXT("register BUILT_IN_INTERNAL_THREAD_TOPIC_TYPE returned %C.\n"),
145 : retcode_to_string(ret)),
146 : ret);
147 : }
148 0 : }
149 :
150 : DDS::Topic_var bit_internal_thread_topic =
151 0 : participant->create_topic(BUILT_IN_INTERNAL_THREAD_TOPIC,
152 : BUILT_IN_INTERNAL_THREAD_TOPIC_TYPE,
153 0 : TOPIC_QOS_DEFAULT,
154 : DDS::TopicListener::_nil(),
155 0 : DEFAULT_STATUS_MASK);
156 :
157 0 : if (CORBA::is_nil(bit_internal_thread_topic)) {
158 0 : ACE_ERROR_RETURN((LM_ERROR,
159 : ACE_TEXT("(%P|%t) ")
160 : ACE_TEXT("Discovery::create_bit_topics, ")
161 : ACE_TEXT("Nil %C Topic\n"),
162 : BUILT_IN_INTERNAL_THREAD_TOPIC),
163 : DDS::RETCODE_ERROR);
164 : }
165 :
166 : // Connection Record Topic
167 : type_support =
168 0 : Registered_Data_Types->lookup(participant, BUILT_IN_CONNECTION_RECORD_TOPIC_TYPE);
169 :
170 0 : if (CORBA::is_nil(type_support)) {
171 : OpenDDS::DCPS::ConnectionRecordTypeSupport_var ts =
172 0 : new OpenDDS::DCPS::ConnectionRecordTypeSupportImpl;
173 :
174 0 : const DDS::ReturnCode_t ret = ts->register_type(participant,
175 : BUILT_IN_CONNECTION_RECORD_TOPIC_TYPE);
176 :
177 0 : if (ret != DDS::RETCODE_OK) {
178 0 : ACE_ERROR_RETURN((LM_ERROR,
179 : ACE_TEXT("(%P|%t) ")
180 : ACE_TEXT("Discovery::create_bit_topics, ")
181 : ACE_TEXT("register BUILT_IN_CONNECTION_RECORD_TOPIC_TYPE returned %C.\n"),
182 : retcode_to_string(ret)),
183 : ret);
184 : }
185 0 : }
186 :
187 : DDS::Topic_var bit_connection_record_topic =
188 0 : participant->create_topic(BUILT_IN_CONNECTION_RECORD_TOPIC,
189 : BUILT_IN_CONNECTION_RECORD_TOPIC_TYPE,
190 0 : TOPIC_QOS_DEFAULT,
191 : DDS::TopicListener::_nil(),
192 0 : DEFAULT_STATUS_MASK);
193 :
194 0 : if (CORBA::is_nil(bit_connection_record_topic)) {
195 0 : ACE_ERROR_RETURN((LM_ERROR,
196 : ACE_TEXT("(%P|%t) ")
197 : ACE_TEXT("Discovery::create_bit_topics, ")
198 : ACE_TEXT("Nil %C Topic\n"),
199 : BUILT_IN_CONNECTION_RECORD_TOPIC),
200 : DDS::RETCODE_ERROR);
201 : }
202 :
203 : // Topic topic
204 : type_support =
205 0 : Registered_Data_Types->lookup(participant, BUILT_IN_TOPIC_TOPIC_TYPE);
206 :
207 0 : if (CORBA::is_nil(type_support)) {
208 : DDS::TopicBuiltinTopicDataTypeSupport_var ts =
209 0 : new DDS::TopicBuiltinTopicDataTypeSupportImpl;
210 :
211 0 : const DDS::ReturnCode_t ret = ts->register_type(participant,
212 : BUILT_IN_TOPIC_TOPIC_TYPE);
213 :
214 0 : if (ret != DDS::RETCODE_OK) {
215 0 : ACE_ERROR_RETURN((LM_ERROR,
216 : ACE_TEXT("(%P|%t) ")
217 : ACE_TEXT("Discovery::create_bit_topics, ")
218 : ACE_TEXT("register BUILT_IN_TOPIC_TOPIC_TYPE returned %d.\n"),
219 : ret),
220 : ret);
221 : }
222 0 : }
223 :
224 : DDS::Topic_var bit_topic_topic =
225 0 : participant->create_topic(BUILT_IN_TOPIC_TOPIC,
226 : BUILT_IN_TOPIC_TOPIC_TYPE,
227 0 : TOPIC_QOS_DEFAULT,
228 : DDS::TopicListener::_nil(),
229 0 : DEFAULT_STATUS_MASK);
230 :
231 0 : if (CORBA::is_nil(bit_topic_topic)) {
232 0 : ACE_ERROR_RETURN((LM_ERROR,
233 : ACE_TEXT("(%P|%t) ")
234 : ACE_TEXT("Discovery::create_bit_topics, ")
235 : ACE_TEXT("Nil %C Topic\n"),
236 : BUILT_IN_TOPIC_TOPIC),
237 : DDS::RETCODE_ERROR);
238 : }
239 :
240 : // Subscription topic
241 : type_support =
242 0 : Registered_Data_Types->lookup(participant, BUILT_IN_SUBSCRIPTION_TOPIC_TYPE);
243 :
244 0 : if (CORBA::is_nil(type_support)) {
245 : DDS::SubscriptionBuiltinTopicDataTypeSupport_var ts =
246 0 : new DDS::SubscriptionBuiltinTopicDataTypeSupportImpl;
247 :
248 0 : const DDS::ReturnCode_t ret = ts->register_type(participant,
249 : BUILT_IN_SUBSCRIPTION_TOPIC_TYPE);
250 :
251 0 : if (ret != DDS::RETCODE_OK) {
252 0 : ACE_ERROR_RETURN((LM_ERROR,
253 : ACE_TEXT("(%P|%t) ")
254 : ACE_TEXT("Discovery::create_bit_topics, ")
255 : ACE_TEXT("register BUILT_IN_SUBSCRIPTION_TOPIC_TYPE returned %d.\n"),
256 : ret),
257 : ret);
258 : }
259 0 : }
260 :
261 : DDS::Topic_var bit_sub_topic =
262 0 : participant->create_topic(BUILT_IN_SUBSCRIPTION_TOPIC,
263 : BUILT_IN_SUBSCRIPTION_TOPIC_TYPE,
264 0 : TOPIC_QOS_DEFAULT,
265 : DDS::TopicListener::_nil(),
266 0 : DEFAULT_STATUS_MASK);
267 :
268 0 : if (CORBA::is_nil(bit_sub_topic)) {
269 0 : ACE_ERROR_RETURN((LM_ERROR,
270 : ACE_TEXT("(%P|%t) ")
271 : ACE_TEXT("Discovery::create_bit_topics, ")
272 : ACE_TEXT("Nil %C Topic\n"),
273 : BUILT_IN_SUBSCRIPTION_TOPIC),
274 : DDS::RETCODE_ERROR);
275 : }
276 :
277 : // Publication topic
278 : type_support =
279 0 : Registered_Data_Types->lookup(participant, BUILT_IN_PUBLICATION_TOPIC_TYPE);
280 :
281 0 : if (CORBA::is_nil(type_support)) {
282 : DDS::PublicationBuiltinTopicDataTypeSupport_var ts =
283 0 : new DDS::PublicationBuiltinTopicDataTypeSupportImpl;
284 :
285 0 : const DDS::ReturnCode_t ret = ts->register_type(participant,
286 : BUILT_IN_PUBLICATION_TOPIC_TYPE);
287 :
288 0 : if (ret != DDS::RETCODE_OK) {
289 0 : ACE_ERROR_RETURN((LM_ERROR,
290 : ACE_TEXT("(%P|%t) ")
291 : ACE_TEXT("Discovery::create_bit_topics, ")
292 : ACE_TEXT("register BUILT_IN_PUBLICATION_TOPIC_TYPE returned %d.\n"),
293 : ret),
294 : ret);
295 : }
296 0 : }
297 :
298 : DDS::Topic_var bit_pub_topic =
299 0 : participant->create_topic(BUILT_IN_PUBLICATION_TOPIC,
300 : BUILT_IN_PUBLICATION_TOPIC_TYPE,
301 0 : TOPIC_QOS_DEFAULT,
302 : DDS::TopicListener::_nil(),
303 0 : DEFAULT_STATUS_MASK);
304 :
305 0 : if (CORBA::is_nil(bit_pub_topic)) {
306 0 : ACE_ERROR_RETURN((LM_ERROR,
307 : ACE_TEXT("(%P|%t) ERROR: Discovery::create_bit_topics, ")
308 : ACE_TEXT("Nil %C Topic\n"),
309 : BUILT_IN_PUBLICATION_TOPIC),
310 : DDS::RETCODE_ERROR);
311 : }
312 :
313 :
314 0 : bit_part_topic->enable();
315 0 : bit_topic_topic->enable();
316 0 : bit_sub_topic->enable();
317 0 : bit_pub_topic->enable();
318 :
319 0 : bit_part_loc_topic->enable();
320 0 : bit_connection_record_topic->enable();
321 0 : bit_internal_thread_topic->enable();
322 :
323 : #else
324 : ACE_UNUSED_ARG(participant);
325 : #endif /* DDS_HAS_MINIMUM_BIT */
326 :
327 0 : return DDS::RETCODE_OK;
328 0 : }
329 :
330 0 : Discovery::Config::~Config()
331 : {
332 0 : }
333 :
334 0 : void Discovery::update_publication_locators(DDS::DomainId_t,
335 : const GUID_t&,
336 : const GUID_t&,
337 : const TransportLocatorSeq&)
338 0 : {}
339 :
340 0 : void Discovery::update_subscription_locators(DDS::DomainId_t,
341 : const GUID_t&,
342 : const GUID_t&,
343 : const TransportLocatorSeq&)
344 0 : {}
345 :
346 : } // namespace DCPS
347 : } // namespace OpenDDS
348 :
349 : OPENDDS_END_VERSIONED_NAMESPACE_DECL
|