@@ -172,7 +172,95 @@ void Domain::registerPort(const Participant& part){
172
172
m_transport.createUdpConnection (getBuiltInUnicastPort (part.m_participantId ));
173
173
}
174
174
175
+ rtps::Reader* Domain::readerExists (Participant& part, const char * topicName, const char * typeName, bool reliable){
176
+ if (reliable){
177
+ for (unsigned int i = 0 ; i < m_numStatefulReaders; i++){
178
+ if (m_statefulReaders[i].isInitialized ()){
179
+ if (strncmp (m_statefulReaders[i].m_attributes .topicName , topicName, Config::MAX_TYPENAME_LENGTH) != 0 ){
180
+ continue ;
181
+ }
182
+
183
+ if (strncmp (m_statefulReaders[i].m_attributes .typeName , typeName, Config::MAX_TYPENAME_LENGTH) != 0 ){
184
+ continue ;
185
+ }
186
+
187
+ #if DOMAIN_VERBOSE
188
+ printf (" StatefulReader exists already [%s, %s]\n " , topicName, typeName);
189
+ #endif
190
+
191
+ return &m_statefulReaders[i];
192
+ }
193
+ }
194
+ }else {
195
+ for (unsigned int i = 0 ; i < m_numStatelessReaders; i++){
196
+ if (m_statelessReaders[i].isInitialized ()){
197
+ if (strncmp (m_statelessReaders[i].m_attributes .topicName , topicName, Config::MAX_TYPENAME_LENGTH) != 0 ){
198
+ continue ;
199
+ }
200
+
201
+ if (strncmp (m_statelessReaders[i].m_attributes .typeName , typeName, Config::MAX_TYPENAME_LENGTH) != 0 ){
202
+ continue ;
203
+ }
204
+
205
+ #if DOMAIN_VERBOSE
206
+ printf (" StatelessReader exists [%s, %s]\n " , topicName, typeName);
207
+ #endif
208
+ return &m_statelessReaders[i];
209
+ }
210
+ }
211
+ }
212
+
213
+ return nullptr ;
214
+ }
215
+
216
+
217
+ rtps::Writer* Domain::writerExists (Participant& part, const char * topicName, const char * typeName, bool reliable){
218
+ if (reliable){
219
+ for (unsigned int i = 0 ; i < m_numStatefulWriters; i++){
220
+ if (m_statefulWriters[i].isInitialized ()){
221
+ if (strncmp (m_statefulWriters[i].m_attributes .topicName , topicName, Config::MAX_TYPENAME_LENGTH) != 0 ){
222
+ continue ;
223
+ }
224
+
225
+ if (strncmp (m_statefulWriters[i].m_attributes .typeName , typeName, Config::MAX_TYPENAME_LENGTH) != 0 ){
226
+ continue ;
227
+ }
228
+
229
+ #if DOMAIN_VERBOSE
230
+ printf (" StatefulWriter exists [%s, %s]\n " , topicName, typeName);
231
+ #endif
232
+
233
+ return &m_statefulWriters[i];
234
+ }
235
+ }
236
+ }else {
237
+ for (unsigned int i = 0 ; i < m_numStatelessWriters; i++){
238
+ if (m_statelessWriters[i].isInitialized ()){
239
+ if (strncmp (m_statelessWriters[i].m_attributes .topicName , topicName, Config::MAX_TYPENAME_LENGTH) != 0 ){
240
+ continue ;
241
+ }
242
+
243
+ if (strncmp (m_statelessWriters[i].m_attributes .typeName , typeName, Config::MAX_TYPENAME_LENGTH) != 0 ){
244
+ continue ;
245
+ }
246
+
247
+ #if DOMAIN_VERBOSE
248
+ printf (" StatelessWriter exists [%s, %s]\n " , topicName, typeName);
249
+ #endif
250
+ return &m_statelessWriters[i];
251
+ }
252
+ }
253
+ }
254
+
255
+ return nullptr ;
256
+ }
257
+
175
258
rtps::Writer* Domain::createWriter (Participant& part, const char * topicName, const char * typeName, bool reliable){
259
+ #if DOMAIN_VERBOSE
260
+ printf (" Creating writer[%s, %s]\n " , topicName, typeName);
261
+ #endif
262
+
263
+ // Check if there is enough capacity for more writers
176
264
if ((reliable && m_statefulWriters.size () <= m_numStatefulWriters) ||
177
265
(!reliable && m_statelessWriters.size () <= m_numStatelessWriters) ||
178
266
part.isWritersFull ()){
@@ -215,10 +303,13 @@ rtps::Writer* Domain::createWriter(Participant& part, const char* topicName, con
215
303
216
304
217
305
rtps::Reader* Domain::createReader (Participant& part, const char * topicName, const char * typeName, bool reliable){
218
- if ((reliable && m_statefulReaders.size () <= m_numStatefulReaders) ||
219
- (!reliable && m_statelessReaders.size () <= m_numStatelessReaders) ||
220
- part.isReadersFull ()){
221
- return nullptr ;
306
+ #if DOMAIN_VERBOSE
307
+ printf (" Creating reader[%s, %s]\n " , topicName, typeName);
308
+ #endif
309
+ if ((reliable && m_statefulReaders.size () <= m_numStatefulReaders) ||
310
+ (!reliable && m_statelessReaders.size () <= m_numStatelessReaders) ||
311
+ part.isReadersFull ()){
312
+ return nullptr ;
222
313
}
223
314
224
315
// TODO Distinguish WithKey and NoKey (Also changes EntityKind)
0 commit comments