Skip to content

Commit d6e0ff1

Browse files
committed
Refs #20629: Update DS XML examples
Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>
1 parent d59f297 commit d6e0ff1

5 files changed

Lines changed: 264 additions & 407 deletions

File tree

code/DDSCodeTester.cpp

Lines changed: 27 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,6 +1259,14 @@ void dds_discovery_examples()
12591259
}
12601260
{
12611261
//CONF_SERVER_SERVER_GUIDPREFIX_OPTION_1
1262+
// Using the ``>>`` operator and the ``std::istringstream`` type.
1263+
DomainParticipantQos serverQos;
1264+
std::istringstream("44.53.00.5f.45.50.52.4f.53.49.4d.41") >> serverQos.wire_protocol().prefix;
1265+
//!--
1266+
}
1267+
{
1268+
//CONF_SERVER_SERVER_GUIDPREFIX_OPTION_2
1269+
// Manual setting of the ``unsigned char`` in ASCII format.
12621270
eprosima::fastdds::rtps::GuidPrefix_t serverGuidPrefix;
12631271
serverGuidPrefix.value[0] = eprosima::fastdds::rtps::octet(0x44);
12641272
serverGuidPrefix.value[1] = eprosima::fastdds::rtps::octet(0x53);
@@ -1277,37 +1285,24 @@ void dds_discovery_examples()
12771285
serverQos.wire_protocol().prefix = serverGuidPrefix;
12781286
//!--
12791287
}
1280-
{
1281-
//CONF_SERVER_SERVER_GUIDPREFIX_OPTION_2
1282-
DomainParticipantQos serverQos;
1283-
std::istringstream("44.53.00.5f.45.50.52.4f.53.49.4d.41") >> serverQos.wire_protocol().prefix;
1284-
//!--
1285-
}
1286-
{
1287-
//CONF_SERVER_CLIENT_GUIDPREFIX
1288-
RemoteServerAttributes server;
1289-
server.ReadguidPrefix("44.53.00.5f.45.50.52.4f.53.49.4d.41");
1290-
1291-
DomainParticipantQos clientQos;
1292-
clientQos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(server);
1293-
//!--
1294-
}
12951288
{
12961289
//CONF_SERVER_CLIENT_LOCATORS
12971290
Locator_t locator;
1291+
// The default locator kind is UDPv4
1292+
locator.kind = LOCATOR_KIND_UDPv4;
12981293
IPLocator::setIPv4(locator, 192, 168, 1, 133);
12991294
locator.port = 64863;
1300-
RemoteServerAttributes server;
1301-
server.metatrafficUnicastLocatorList.push_back(locator);
13021295

13031296
DomainParticipantQos clientQos;
1304-
clientQos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(server);
1297+
clientQos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(locator);
13051298
//!--
13061299
}
13071300

13081301
{
13091302
//CONF_SERVER_SERVER_LOCATORS
13101303
Locator_t locator;
1304+
// The default locator kind is UDPv4
1305+
locator.kind = LOCATOR_KIND_UDPv4;
13111306
IPLocator::setIPv4(locator, 192, 168, 1, 133);
13121307
locator.port = 64863;
13131308

@@ -1334,17 +1329,13 @@ void dds_discovery_examples()
13341329
/* Create a new server entry to which the client or server should connect */
13351330
RemoteServerAttributes remote_server_att;
13361331

1337-
// Set server's GUID prefix
1338-
remote_server_att.ReadguidPrefix("44.53.00.5f.45.50.52.4f.53.49.4d.42");
1339-
13401332
// Set server's listening locator for PDP
13411333
Locator_t locator;
13421334
IPLocator::setIPv4(locator, 127, 0, 0, 1);
13431335
locator.port = 11812;
1344-
remote_server_att.metatrafficUnicastLocatorList.push_back(locator);
13451336

13461337
/* Update list of remote servers for this client or server */
1347-
client_or_server_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_att);
1338+
client_or_server_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(locator);
13481339
if (RETCODE_OK != client_or_server->set_qos(client_or_server_qos))
13491340
{
13501341
// Error
@@ -1376,28 +1367,20 @@ void dds_discovery_examples()
13761367
server_qos.wire_protocol().builtin.discovery_config.discoveryProtocol =
13771368
DiscoveryProtocol::SERVER;
13781369

1379-
// Set SERVER's GUID prefix
1380-
std::istringstream("44.53.00.5f.45.50.52.4f.53.49.4d.41") >> server_qos.wire_protocol().prefix;
1381-
13821370
// Set SERVER's listening locator for PDP
13831371
Locator_t locator;
13841372
IPLocator::setIPv4(locator, 127, 0, 0, 1);
13851373
locator.port = 11811;
13861374
server_qos.wire_protocol().builtin.metatrafficUnicastLocatorList.push_back(locator);
13871375

13881376
/* Add a remote serve to which this server will connect */
1389-
// Set remote SERVER's GUID prefix
1390-
RemoteServerAttributes remote_server_att;
1391-
remote_server_att.ReadguidPrefix("44.53.01.5f.45.50.52.4f.53.49.4d.41");
1392-
13931377
// Set remote SERVER's listening locator for PDP
13941378
Locator_t remote_locator;
13951379
IPLocator::setIPv4(remote_locator, 127, 0, 0, 1);
13961380
remote_locator.port = 11812;
1397-
remote_server_att.metatrafficUnicastLocatorList.push_back(remote_locator);
13981381

13991382
// Add remote SERVER to SERVER's list of SERVERs
1400-
server_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_att);
1383+
server_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_locator);
14011384

14021385
// Create SERVER
14031386
DomainParticipant* server =
@@ -1419,18 +1402,13 @@ void dds_discovery_examples()
14191402
client_qos.wire_protocol().builtin.discovery_config.discoveryProtocol =
14201403
DiscoveryProtocol::CLIENT;
14211404

1422-
// Set SERVER's GUID prefix
1423-
RemoteServerAttributes remote_server_att;
1424-
remote_server_att.ReadguidPrefix("44.53.00.5f.45.50.52.4f.53.49.4d.41");
1425-
14261405
// Set SERVER's listening locator for PDP
14271406
Locator_t locator;
14281407
IPLocator::setIPv4(locator, 127, 0, 0, 1);
14291408
locator.port = 11811;
1430-
remote_server_att.metatrafficUnicastLocatorList.push_back(locator);
14311409

14321410
// Add remote SERVER to CLIENT's list of SERVERs
1433-
client_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_att);
1411+
client_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(locator);
14341412

14351413
// Set ping period to 250 ms
14361414
client_qos.wire_protocol().builtin.discovery_config.discoveryServer_client_syncperiod =
@@ -6261,9 +6239,6 @@ void dds_usecase_examples()
62616239
IPLocator::setIPv4(server_locator, "192.168.10.57");
62626240
server_locator.port = 56542;
62636241
qos.wire_protocol().builtin.metatrafficUnicastLocatorList.push_back(server_locator);
6264-
6265-
// Set the GUID prefix to identify this server
6266-
std::istringstream("72.61.73.70.66.61.72.6d.74.65.73.74") >> qos.wire_protocol().prefix;
62676242
//!--
62686243
}
62696244

@@ -6279,14 +6254,8 @@ void dds_usecase_examples()
62796254
IPLocator::setIPv4(remote_server_locator, "192.168.10.57");
62806255
remote_server_locator.port = 56542;
62816256

6282-
RemoteServerAttributes remote_server_attr;
6283-
remote_server_attr.metatrafficUnicastLocatorList.push_back(remote_server_locator);
6284-
6285-
// Set the GUID prefix to identify the remote server
6286-
remote_server_attr.ReadguidPrefix("72.61.73.70.66.61.72.6d.74.65.73.74");
6287-
62886257
// Connect to the SERVER at the previous locator
6289-
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_attr);
6258+
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_locator);
62906259
//!--
62916260
}
62926261

@@ -6300,6 +6269,7 @@ void dds_usecase_examples()
63006269
// Configure participant_1 as SERVER listening on the previous locator
63016270
DomainParticipantQos server_1_qos;
63026271
server_1_qos.wire_protocol().builtin.discovery_config.discoveryProtocol = DiscoveryProtocol::SERVER;
6272+
// Optional GUID
63036273
std::istringstream("75.63.2D.73.76.72.63.6C.6E.74.2D.31") >> server_1_qos.wire_protocol().prefix;
63046274
server_1_qos.wire_protocol().builtin.metatrafficUnicastLocatorList.push_back(server_locator_1);
63056275

@@ -6311,6 +6281,7 @@ void dds_usecase_examples()
63116281
// Configure participant_2 as SERVER listening on the previous locator
63126282
DomainParticipantQos server_2_qos;
63136283
server_2_qos.wire_protocol().builtin.discovery_config.discoveryProtocol = DiscoveryProtocol::SERVER;
6284+
// Optional GUID
63146285
std::istringstream("75.63.2D.73.76.72.63.6C.6E.74.2D.32") >> server_2_qos.wire_protocol().prefix;
63156286
server_2_qos.wire_protocol().builtin.metatrafficUnicastLocatorList.push_back(server_locator_2);
63166287
//!--
@@ -6323,24 +6294,16 @@ void dds_usecase_examples()
63236294
IPLocator::setIPv4(remote_server_locator_1, "192.168.10.57");
63246295
remote_server_locator_1.port = 56542;
63256296

6326-
RemoteServerAttributes remote_server_attr_1;
6327-
remote_server_attr_1.ReadguidPrefix("75.63.2D.73.76.72.63.6C.6E.74.2D.31");
6328-
remote_server_attr_1.metatrafficUnicastLocatorList.push_back(remote_server_locator_1);
6329-
63306297
// Define a locator for the second SERVER Participant
63316298
Locator_t remote_server_locator_2;
63326299
IPLocator::setIPv4(remote_server_locator_2, "192.168.10.60");
63336300
remote_server_locator_2.port = 56543;
63346301

6335-
RemoteServerAttributes remote_server_attr_2;
6336-
remote_server_attr_2.ReadguidPrefix("75.63.2D.73.76.72.63.6C.6E.74.2D.32");
6337-
remote_server_attr_2.metatrafficUnicastLocatorList.push_back(remote_server_locator_2);
6338-
63396302
// Configure the current participant as CLIENT connecting to the SERVERS at the previous locators
63406303
DomainParticipantQos client_qos;
63416304
client_qos.wire_protocol().builtin.discovery_config.discoveryProtocol = DiscoveryProtocol::CLIENT;
6342-
client_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_attr_1);
6343-
client_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_attr_2);
6305+
client_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_locator_1);
6306+
client_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_locator_2);
63446307
//!--
63456308
}
63466309

@@ -6354,6 +6317,7 @@ void dds_usecase_examples()
63546317
server_locator.port = 56543;
63556318

63566319
qos.wire_protocol().builtin.discovery_config.discoveryProtocol = DiscoveryProtocol::SERVER;
6320+
// Optional GUID
63576321
std::istringstream("75.63.2D.73.76.72.63.6C.6E.74.2D.31") >> qos.wire_protocol().prefix;
63586322
qos.wire_protocol().builtin.metatrafficUnicastLocatorList.push_back(server_locator);
63596323

@@ -6362,11 +6326,7 @@ void dds_usecase_examples()
63626326
IPLocator::setIPv4(remote_server_locator, "192.168.10.57");
63636327
remote_server_locator.port = 56542;
63646328

6365-
RemoteServerAttributes remote_server_attr;
6366-
remote_server_attr.ReadguidPrefix("75.63.2D.73.76.72.63.6C.6E.74.2D.32");
6367-
remote_server_attr.metatrafficUnicastLocatorList.push_back(remote_server_locator);
6368-
6369-
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_attr);
6329+
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_locator);
63706330
//!--
63716331
}
63726332

@@ -6380,6 +6340,7 @@ void dds_usecase_examples()
63806340
server_locator.port = 56541;
63816341

63826342
qos.wire_protocol().builtin.discovery_config.discoveryProtocol = DiscoveryProtocol::SERVER;
6343+
// Optional GUID
63836344
std::istringstream("75.63.2D.73.76.72.63.6C.6E.74.2D.33") >> qos.wire_protocol().prefix;
63846345
qos.wire_protocol().builtin.metatrafficUnicastLocatorList.push_back(server_locator);
63856346

@@ -6388,22 +6349,14 @@ void dds_usecase_examples()
63886349
IPLocator::setIPv4(remote_server_locator_A, "192.168.10.60");
63896350
remote_server_locator_A.port = 56543;
63906351

6391-
RemoteServerAttributes remote_server_attr_A;
6392-
remote_server_attr_A.ReadguidPrefix("75.63.2D.73.76.72.63.6C.6E.74.2D.31");
6393-
remote_server_attr_A.metatrafficUnicastLocatorList.push_back(remote_server_locator_A);
6394-
6395-
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_attr_A);
6352+
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_locator_A);
63966353

63976354
// Add the connection attributes to the remote server B.
63986355
Locator_t remote_server_locator_B;
63996356
IPLocator::setIPv4(remote_server_locator_B, "192.168.10.57");
64006357
remote_server_locator_B.port = 56542;
64016358

6402-
RemoteServerAttributes remote_server_attr_B;
6403-
remote_server_attr_B.ReadguidPrefix("75.63.2D.73.76.72.63.6C.6E.74.2D.32");
6404-
remote_server_attr_B.metatrafficUnicastLocatorList.push_back(remote_server_locator_B);
6405-
6406-
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_attr_B);
6359+
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_locator_B);
64076360
//!--
64086361
}
64096362

@@ -7518,9 +7471,6 @@ void tcp_use_cases()
75187471
eprosima::fastdds::rtps::IPLocator::setPhysicalPort(listening_locator, tcp_listening_port);
75197472
eprosima::fastdds::rtps::IPLocator::setLogicalPort(listening_locator, tcp_listening_port);
75207473
qos.wire_protocol().builtin.metatrafficUnicastLocatorList.push_back(listening_locator);
7521-
7522-
// Set the GUID prefix to identify this server
7523-
std::istringstream("44.53.00.5f.45.50.52.4f.53.49.4d.41") >> qos.wire_protocol().prefix;
75247474
//!--
75257475
}
75267476

@@ -7544,15 +7494,8 @@ void tcp_use_cases()
75447494
eprosima::fastdds::rtps::IPLocator::setPhysicalPort(server_locator, server_port);
75457495
eprosima::fastdds::rtps::IPLocator::setLogicalPort(server_locator, server_port);
75467496

7547-
// Define the server attributes
7548-
eprosima::fastdds::rtps::RemoteServerAttributes remote_server_att;
7549-
remote_server_att.metatrafficUnicastLocatorList.push_back(server_locator);
7550-
7551-
// Set the GUID prefix to identify this server
7552-
std::istringstream("44.53.00.5f.45.50.52.4f.53.49.4d.41") >> remote_server_att.guidPrefix;
7553-
75547497
// Add the server
7555-
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_att);
7498+
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(server_locator);
75567499
//!--
75577500
}
75587501
}

0 commit comments

Comments
 (0)