Skip to content

Commit 7884b5f

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

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 =
@@ -6102,9 +6080,6 @@ void dds_usecase_examples()
61026080
IPLocator::setIPv4(server_locator, "192.168.10.57");
61036081
server_locator.port = 56542;
61046082
qos.wire_protocol().builtin.metatrafficUnicastLocatorList.push_back(server_locator);
6105-
6106-
// Set the GUID prefix to identify this server
6107-
std::istringstream("72.61.73.70.66.61.72.6d.74.65.73.74") >> qos.wire_protocol().prefix;
61086083
//!--
61096084
}
61106085

@@ -6120,14 +6095,8 @@ void dds_usecase_examples()
61206095
IPLocator::setIPv4(remote_server_locator, "192.168.10.57");
61216096
remote_server_locator.port = 56542;
61226097

6123-
RemoteServerAttributes remote_server_attr;
6124-
remote_server_attr.metatrafficUnicastLocatorList.push_back(remote_server_locator);
6125-
6126-
// Set the GUID prefix to identify the remote server
6127-
remote_server_attr.ReadguidPrefix("72.61.73.70.66.61.72.6d.74.65.73.74");
6128-
61296098
// Connect to the SERVER at the previous locator
6130-
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_attr);
6099+
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_locator);
61316100
//!--
61326101
}
61336102

@@ -6141,6 +6110,7 @@ void dds_usecase_examples()
61416110
// Configure participant_1 as SERVER listening on the previous locator
61426111
DomainParticipantQos server_1_qos;
61436112
server_1_qos.wire_protocol().builtin.discovery_config.discoveryProtocol = DiscoveryProtocol::SERVER;
6113+
// Optional GUID
61446114
std::istringstream("75.63.2D.73.76.72.63.6C.6E.74.2D.31") >> server_1_qos.wire_protocol().prefix;
61456115
server_1_qos.wire_protocol().builtin.metatrafficUnicastLocatorList.push_back(server_locator_1);
61466116

@@ -6152,6 +6122,7 @@ void dds_usecase_examples()
61526122
// Configure participant_2 as SERVER listening on the previous locator
61536123
DomainParticipantQos server_2_qos;
61546124
server_2_qos.wire_protocol().builtin.discovery_config.discoveryProtocol = DiscoveryProtocol::SERVER;
6125+
// Optional GUID
61556126
std::istringstream("75.63.2D.73.76.72.63.6C.6E.74.2D.32") >> server_2_qos.wire_protocol().prefix;
61566127
server_2_qos.wire_protocol().builtin.metatrafficUnicastLocatorList.push_back(server_locator_2);
61576128
//!--
@@ -6164,24 +6135,16 @@ void dds_usecase_examples()
61646135
IPLocator::setIPv4(remote_server_locator_1, "192.168.10.57");
61656136
remote_server_locator_1.port = 56542;
61666137

6167-
RemoteServerAttributes remote_server_attr_1;
6168-
remote_server_attr_1.ReadguidPrefix("75.63.2D.73.76.72.63.6C.6E.74.2D.31");
6169-
remote_server_attr_1.metatrafficUnicastLocatorList.push_back(remote_server_locator_1);
6170-
61716138
// Define a locator for the second SERVER Participant
61726139
Locator_t remote_server_locator_2;
61736140
IPLocator::setIPv4(remote_server_locator_2, "192.168.10.60");
61746141
remote_server_locator_2.port = 56543;
61756142

6176-
RemoteServerAttributes remote_server_attr_2;
6177-
remote_server_attr_2.ReadguidPrefix("75.63.2D.73.76.72.63.6C.6E.74.2D.32");
6178-
remote_server_attr_2.metatrafficUnicastLocatorList.push_back(remote_server_locator_2);
6179-
61806143
// Configure the current participant as CLIENT connecting to the SERVERS at the previous locators
61816144
DomainParticipantQos client_qos;
61826145
client_qos.wire_protocol().builtin.discovery_config.discoveryProtocol = DiscoveryProtocol::CLIENT;
6183-
client_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_attr_1);
6184-
client_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_attr_2);
6146+
client_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_locator_1);
6147+
client_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_locator_2);
61856148
//!--
61866149
}
61876150

@@ -6195,6 +6158,7 @@ void dds_usecase_examples()
61956158
server_locator.port = 56543;
61966159

61976160
qos.wire_protocol().builtin.discovery_config.discoveryProtocol = DiscoveryProtocol::SERVER;
6161+
// Optional GUID
61986162
std::istringstream("75.63.2D.73.76.72.63.6C.6E.74.2D.31") >> qos.wire_protocol().prefix;
61996163
qos.wire_protocol().builtin.metatrafficUnicastLocatorList.push_back(server_locator);
62006164

@@ -6203,11 +6167,7 @@ void dds_usecase_examples()
62036167
IPLocator::setIPv4(remote_server_locator, "192.168.10.57");
62046168
remote_server_locator.port = 56542;
62056169

6206-
RemoteServerAttributes remote_server_attr;
6207-
remote_server_attr.ReadguidPrefix("75.63.2D.73.76.72.63.6C.6E.74.2D.32");
6208-
remote_server_attr.metatrafficUnicastLocatorList.push_back(remote_server_locator);
6209-
6210-
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_attr);
6170+
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_locator);
62116171
//!--
62126172
}
62136173

@@ -6221,6 +6181,7 @@ void dds_usecase_examples()
62216181
server_locator.port = 56541;
62226182

62236183
qos.wire_protocol().builtin.discovery_config.discoveryProtocol = DiscoveryProtocol::SERVER;
6184+
// Optional GUID
62246185
std::istringstream("75.63.2D.73.76.72.63.6C.6E.74.2D.33") >> qos.wire_protocol().prefix;
62256186
qos.wire_protocol().builtin.metatrafficUnicastLocatorList.push_back(server_locator);
62266187

@@ -6229,22 +6190,14 @@ void dds_usecase_examples()
62296190
IPLocator::setIPv4(remote_server_locator_A, "192.168.10.60");
62306191
remote_server_locator_A.port = 56543;
62316192

6232-
RemoteServerAttributes remote_server_attr_A;
6233-
remote_server_attr_A.ReadguidPrefix("75.63.2D.73.76.72.63.6C.6E.74.2D.31");
6234-
remote_server_attr_A.metatrafficUnicastLocatorList.push_back(remote_server_locator_A);
6235-
6236-
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_attr_A);
6193+
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_locator_A);
62376194

62386195
// Add the connection attributes to the remote server B.
62396196
Locator_t remote_server_locator_B;
62406197
IPLocator::setIPv4(remote_server_locator_B, "192.168.10.57");
62416198
remote_server_locator_B.port = 56542;
62426199

6243-
RemoteServerAttributes remote_server_attr_B;
6244-
remote_server_attr_B.ReadguidPrefix("75.63.2D.73.76.72.63.6C.6E.74.2D.32");
6245-
remote_server_attr_B.metatrafficUnicastLocatorList.push_back(remote_server_locator_B);
6246-
6247-
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_attr_B);
6200+
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_locator_B);
62486201
//!--
62496202
}
62506203

@@ -7359,9 +7312,6 @@ void tcp_use_cases()
73597312
eprosima::fastdds::rtps::IPLocator::setPhysicalPort(listening_locator, tcp_listening_port);
73607313
eprosima::fastdds::rtps::IPLocator::setLogicalPort(listening_locator, tcp_listening_port);
73617314
qos.wire_protocol().builtin.metatrafficUnicastLocatorList.push_back(listening_locator);
7362-
7363-
// Set the GUID prefix to identify this server
7364-
std::istringstream("44.53.00.5f.45.50.52.4f.53.49.4d.41") >> qos.wire_protocol().prefix;
73657315
//!--
73667316
}
73677317

@@ -7385,15 +7335,8 @@ void tcp_use_cases()
73857335
eprosima::fastdds::rtps::IPLocator::setPhysicalPort(server_locator, server_port);
73867336
eprosima::fastdds::rtps::IPLocator::setLogicalPort(server_locator, server_port);
73877337

7388-
// Define the server attributes
7389-
eprosima::fastdds::rtps::RemoteServerAttributes remote_server_att;
7390-
remote_server_att.metatrafficUnicastLocatorList.push_back(server_locator);
7391-
7392-
// Set the GUID prefix to identify this server
7393-
std::istringstream("44.53.00.5f.45.50.52.4f.53.49.4d.41") >> remote_server_att.guidPrefix;
7394-
73957338
// Add the server
7396-
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_att);
7339+
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(server_locator);
73977340
//!--
73987341
}
73997342
}

0 commit comments

Comments
 (0)