Skip to content

Commit 0fae698

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

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
@@ -1260,6 +1260,14 @@ void dds_discovery_examples()
12601260
}
12611261
{
12621262
//CONF_SERVER_SERVER_GUIDPREFIX_OPTION_1
1263+
// Using the ``>>`` operator and the ``std::istringstream`` type.
1264+
DomainParticipantQos serverQos;
1265+
std::istringstream("44.53.00.5f.45.50.52.4f.53.49.4d.41") >> serverQos.wire_protocol().prefix;
1266+
//!--
1267+
}
1268+
{
1269+
//CONF_SERVER_SERVER_GUIDPREFIX_OPTION_2
1270+
// Manual setting of the ``unsigned char`` in ASCII format.
12631271
eprosima::fastdds::rtps::GuidPrefix_t serverGuidPrefix;
12641272
serverGuidPrefix.value[0] = eprosima::fastdds::rtps::octet(0x44);
12651273
serverGuidPrefix.value[1] = eprosima::fastdds::rtps::octet(0x53);
@@ -1278,37 +1286,24 @@ void dds_discovery_examples()
12781286
serverQos.wire_protocol().prefix = serverGuidPrefix;
12791287
//!--
12801288
}
1281-
{
1282-
//CONF_SERVER_SERVER_GUIDPREFIX_OPTION_2
1283-
DomainParticipantQos serverQos;
1284-
std::istringstream("44.53.00.5f.45.50.52.4f.53.49.4d.41") >> serverQos.wire_protocol().prefix;
1285-
//!--
1286-
}
1287-
{
1288-
//CONF_SERVER_CLIENT_GUIDPREFIX
1289-
RemoteServerAttributes server;
1290-
server.ReadguidPrefix("44.53.00.5f.45.50.52.4f.53.49.4d.41");
1291-
1292-
DomainParticipantQos clientQos;
1293-
clientQos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(server);
1294-
//!--
1295-
}
12961289
{
12971290
//CONF_SERVER_CLIENT_LOCATORS
12981291
Locator_t locator;
1292+
// The default locator kind is UDPv4
1293+
locator.kind = LOCATOR_KIND_UDPv4;
12991294
IPLocator::setIPv4(locator, 192, 168, 1, 133);
13001295
locator.port = 64863;
1301-
RemoteServerAttributes server;
1302-
server.metatrafficUnicastLocatorList.push_back(locator);
13031296

13041297
DomainParticipantQos clientQos;
1305-
clientQos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(server);
1298+
clientQos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(locator);
13061299
//!--
13071300
}
13081301

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

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

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

13471338
/* Update list of remote servers for this client or server */
1348-
client_or_server_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_att);
1339+
client_or_server_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(locator);
13491340
if (RETCODE_OK != client_or_server->set_qos(client_or_server_qos))
13501341
{
13511342
// Error
@@ -1377,28 +1368,20 @@ void dds_discovery_examples()
13771368
server_qos.wire_protocol().builtin.discovery_config.discoveryProtocol =
13781369
DiscoveryProtocol::SERVER;
13791370

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

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

14001383
// Add remote SERVER to SERVER's list of SERVERs
1401-
server_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_att);
1384+
server_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_locator);
14021385

14031386
// Create SERVER
14041387
DomainParticipant* server =
@@ -1420,18 +1403,13 @@ void dds_discovery_examples()
14201403
client_qos.wire_protocol().builtin.discovery_config.discoveryProtocol =
14211404
DiscoveryProtocol::CLIENT;
14221405

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

14331411
// Add remote SERVER to CLIENT's list of SERVERs
1434-
client_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_att);
1412+
client_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(locator);
14351413

14361414
// Set ping period to 250 ms
14371415
client_qos.wire_protocol().builtin.discovery_config.discoveryServer_client_syncperiod =
@@ -6268,9 +6246,6 @@ void dds_usecase_examples()
62686246
IPLocator::setIPv4(server_locator, "192.168.10.57");
62696247
server_locator.port = 56542;
62706248
qos.wire_protocol().builtin.metatrafficUnicastLocatorList.push_back(server_locator);
6271-
6272-
// Set the GUID prefix to identify this server
6273-
std::istringstream("72.61.73.70.66.61.72.6d.74.65.73.74") >> qos.wire_protocol().prefix;
62746249
//!--
62756250
}
62766251

@@ -6286,14 +6261,8 @@ void dds_usecase_examples()
62866261
IPLocator::setIPv4(remote_server_locator, "192.168.10.57");
62876262
remote_server_locator.port = 56542;
62886263

6289-
RemoteServerAttributes remote_server_attr;
6290-
remote_server_attr.metatrafficUnicastLocatorList.push_back(remote_server_locator);
6291-
6292-
// Set the GUID prefix to identify the remote server
6293-
remote_server_attr.ReadguidPrefix("72.61.73.70.66.61.72.6d.74.65.73.74");
6294-
62956264
// Connect to the SERVER at the previous locator
6296-
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_attr);
6265+
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_locator);
62976266
//!--
62986267
}
62996268

@@ -6307,6 +6276,7 @@ void dds_usecase_examples()
63076276
// Configure participant_1 as SERVER listening on the previous locator
63086277
DomainParticipantQos server_1_qos;
63096278
server_1_qos.wire_protocol().builtin.discovery_config.discoveryProtocol = DiscoveryProtocol::SERVER;
6279+
// Optional GUID
63106280
std::istringstream("75.63.2D.73.76.72.63.6C.6E.74.2D.31") >> server_1_qos.wire_protocol().prefix;
63116281
server_1_qos.wire_protocol().builtin.metatrafficUnicastLocatorList.push_back(server_locator_1);
63126282

@@ -6318,6 +6288,7 @@ void dds_usecase_examples()
63186288
// Configure participant_2 as SERVER listening on the previous locator
63196289
DomainParticipantQos server_2_qos;
63206290
server_2_qos.wire_protocol().builtin.discovery_config.discoveryProtocol = DiscoveryProtocol::SERVER;
6291+
// Optional GUID
63216292
std::istringstream("75.63.2D.73.76.72.63.6C.6E.74.2D.32") >> server_2_qos.wire_protocol().prefix;
63226293
server_2_qos.wire_protocol().builtin.metatrafficUnicastLocatorList.push_back(server_locator_2);
63236294
//!--
@@ -6330,24 +6301,16 @@ void dds_usecase_examples()
63306301
IPLocator::setIPv4(remote_server_locator_1, "192.168.10.57");
63316302
remote_server_locator_1.port = 56542;
63326303

6333-
RemoteServerAttributes remote_server_attr_1;
6334-
remote_server_attr_1.ReadguidPrefix("75.63.2D.73.76.72.63.6C.6E.74.2D.31");
6335-
remote_server_attr_1.metatrafficUnicastLocatorList.push_back(remote_server_locator_1);
6336-
63376304
// Define a locator for the second SERVER Participant
63386305
Locator_t remote_server_locator_2;
63396306
IPLocator::setIPv4(remote_server_locator_2, "192.168.10.60");
63406307
remote_server_locator_2.port = 56543;
63416308

6342-
RemoteServerAttributes remote_server_attr_2;
6343-
remote_server_attr_2.ReadguidPrefix("75.63.2D.73.76.72.63.6C.6E.74.2D.32");
6344-
remote_server_attr_2.metatrafficUnicastLocatorList.push_back(remote_server_locator_2);
6345-
63466309
// Configure the current participant as CLIENT connecting to the SERVERS at the previous locators
63476310
DomainParticipantQos client_qos;
63486311
client_qos.wire_protocol().builtin.discovery_config.discoveryProtocol = DiscoveryProtocol::CLIENT;
6349-
client_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_attr_1);
6350-
client_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_attr_2);
6312+
client_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_locator_1);
6313+
client_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_locator_2);
63516314
//!--
63526315
}
63536316

@@ -6361,6 +6324,7 @@ void dds_usecase_examples()
63616324
server_locator.port = 56543;
63626325

63636326
qos.wire_protocol().builtin.discovery_config.discoveryProtocol = DiscoveryProtocol::SERVER;
6327+
// Optional GUID
63646328
std::istringstream("75.63.2D.73.76.72.63.6C.6E.74.2D.31") >> qos.wire_protocol().prefix;
63656329
qos.wire_protocol().builtin.metatrafficUnicastLocatorList.push_back(server_locator);
63666330

@@ -6369,11 +6333,7 @@ void dds_usecase_examples()
63696333
IPLocator::setIPv4(remote_server_locator, "192.168.10.57");
63706334
remote_server_locator.port = 56542;
63716335

6372-
RemoteServerAttributes remote_server_attr;
6373-
remote_server_attr.ReadguidPrefix("75.63.2D.73.76.72.63.6C.6E.74.2D.32");
6374-
remote_server_attr.metatrafficUnicastLocatorList.push_back(remote_server_locator);
6375-
6376-
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_attr);
6336+
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_locator);
63776337
//!--
63786338
}
63796339

@@ -6387,6 +6347,7 @@ void dds_usecase_examples()
63876347
server_locator.port = 56541;
63886348

63896349
qos.wire_protocol().builtin.discovery_config.discoveryProtocol = DiscoveryProtocol::SERVER;
6350+
// Optional GUID
63906351
std::istringstream("75.63.2D.73.76.72.63.6C.6E.74.2D.33") >> qos.wire_protocol().prefix;
63916352
qos.wire_protocol().builtin.metatrafficUnicastLocatorList.push_back(server_locator);
63926353

@@ -6395,22 +6356,14 @@ void dds_usecase_examples()
63956356
IPLocator::setIPv4(remote_server_locator_A, "192.168.10.60");
63966357
remote_server_locator_A.port = 56543;
63976358

6398-
RemoteServerAttributes remote_server_attr_A;
6399-
remote_server_attr_A.ReadguidPrefix("75.63.2D.73.76.72.63.6C.6E.74.2D.31");
6400-
remote_server_attr_A.metatrafficUnicastLocatorList.push_back(remote_server_locator_A);
6401-
6402-
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_attr_A);
6359+
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_locator_A);
64036360

64046361
// Add the connection attributes to the remote server B.
64056362
Locator_t remote_server_locator_B;
64066363
IPLocator::setIPv4(remote_server_locator_B, "192.168.10.57");
64076364
remote_server_locator_B.port = 56542;
64086365

6409-
RemoteServerAttributes remote_server_attr_B;
6410-
remote_server_attr_B.ReadguidPrefix("75.63.2D.73.76.72.63.6C.6E.74.2D.32");
6411-
remote_server_attr_B.metatrafficUnicastLocatorList.push_back(remote_server_locator_B);
6412-
6413-
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_attr_B);
6366+
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_locator_B);
64146367
//!--
64156368
}
64166369

@@ -7525,9 +7478,6 @@ void tcp_use_cases()
75257478
eprosima::fastdds::rtps::IPLocator::setPhysicalPort(listening_locator, tcp_listening_port);
75267479
eprosima::fastdds::rtps::IPLocator::setLogicalPort(listening_locator, tcp_listening_port);
75277480
qos.wire_protocol().builtin.metatrafficUnicastLocatorList.push_back(listening_locator);
7528-
7529-
// Set the GUID prefix to identify this server
7530-
std::istringstream("44.53.00.5f.45.50.52.4f.53.49.4d.41") >> qos.wire_protocol().prefix;
75317481
//!--
75327482
}
75337483

@@ -7551,15 +7501,8 @@ void tcp_use_cases()
75517501
eprosima::fastdds::rtps::IPLocator::setPhysicalPort(server_locator, server_port);
75527502
eprosima::fastdds::rtps::IPLocator::setLogicalPort(server_locator, server_port);
75537503

7554-
// Define the server attributes
7555-
eprosima::fastdds::rtps::RemoteServerAttributes remote_server_att;
7556-
remote_server_att.metatrafficUnicastLocatorList.push_back(server_locator);
7557-
7558-
// Set the GUID prefix to identify this server
7559-
std::istringstream("44.53.00.5f.45.50.52.4f.53.49.4d.41") >> remote_server_att.guidPrefix;
7560-
75617504
// Add the server
7562-
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_att);
7505+
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(server_locator);
75637506
//!--
75647507
}
75657508
}

0 commit comments

Comments
 (0)