Skip to content

Commit b9d29b4

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

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
@@ -1256,6 +1256,14 @@ void dds_discovery_examples()
12561256
}
12571257
{
12581258
//CONF_SERVER_SERVER_GUIDPREFIX_OPTION_1
1259+
// Using the ``>>`` operator and the ``std::istringstream`` type.
1260+
DomainParticipantQos serverQos;
1261+
std::istringstream("44.53.00.5f.45.50.52.4f.53.49.4d.41") >> serverQos.wire_protocol().prefix;
1262+
//!--
1263+
}
1264+
{
1265+
//CONF_SERVER_SERVER_GUIDPREFIX_OPTION_2
1266+
// Manual setting of the ``unsigned char`` in ASCII format.
12591267
eprosima::fastrtps::rtps::GuidPrefix_t serverGuidPrefix;
12601268
serverGuidPrefix.value[0] = eprosima::fastrtps::rtps::octet(0x44);
12611269
serverGuidPrefix.value[1] = eprosima::fastrtps::rtps::octet(0x53);
@@ -1274,37 +1282,24 @@ void dds_discovery_examples()
12741282
serverQos.wire_protocol().prefix = serverGuidPrefix;
12751283
//!--
12761284
}
1277-
{
1278-
//CONF_SERVER_SERVER_GUIDPREFIX_OPTION_2
1279-
DomainParticipantQos serverQos;
1280-
std::istringstream("44.53.00.5f.45.50.52.4f.53.49.4d.41") >> serverQos.wire_protocol().prefix;
1281-
//!--
1282-
}
1283-
{
1284-
//CONF_SERVER_CLIENT_GUIDPREFIX
1285-
RemoteServerAttributes server;
1286-
server.ReadguidPrefix("44.53.00.5f.45.50.52.4f.53.49.4d.41");
1287-
1288-
DomainParticipantQos clientQos;
1289-
clientQos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(server);
1290-
//!--
1291-
}
12921285
{
12931286
//CONF_SERVER_CLIENT_LOCATORS
12941287
Locator_t locator;
1288+
// The default locator kind is UDPv4
1289+
locator.kind = LOCATOR_KIND_UDPv4;
12951290
IPLocator::setIPv4(locator, 192, 168, 1, 133);
12961291
locator.port = 64863;
1297-
RemoteServerAttributes server;
1298-
server.metatrafficUnicastLocatorList.push_back(locator);
12991292

13001293
DomainParticipantQos clientQos;
1301-
clientQos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(server);
1294+
clientQos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(locator);
13021295
//!--
13031296
}
13041297

13051298
{
13061299
//CONF_SERVER_SERVER_LOCATORS
13071300
Locator_t locator;
1301+
// The default locator kind is UDPv4
1302+
locator.kind = LOCATOR_KIND_UDPv4;
13081303
IPLocator::setIPv4(locator, 192, 168, 1, 133);
13091304
locator.port = 64863;
13101305

@@ -1331,17 +1326,13 @@ void dds_discovery_examples()
13311326
/* Create a new server entry to which the client or server should connect */
13321327
RemoteServerAttributes remote_server_att;
13331328

1334-
// Set server's GUID prefix
1335-
remote_server_att.ReadguidPrefix("44.53.00.5f.45.50.52.4f.53.49.4d.42");
1336-
13371329
// Set server's listening locator for PDP
13381330
Locator_t locator;
13391331
IPLocator::setIPv4(locator, 127, 0, 0, 1);
13401332
locator.port = 11812;
1341-
remote_server_att.metatrafficUnicastLocatorList.push_back(locator);
13421333

13431334
/* Update list of remote servers for this client or server */
1344-
client_or_server_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_att);
1335+
client_or_server_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(locator);
13451336
if (RETCODE_OK != client_or_server->set_qos(client_or_server_qos))
13461337
{
13471338
// Error
@@ -1373,28 +1364,20 @@ void dds_discovery_examples()
13731364
server_qos.wire_protocol().builtin.discovery_config.discoveryProtocol =
13741365
DiscoveryProtocol_t::SERVER;
13751366

1376-
// Set SERVER's GUID prefix
1377-
std::istringstream("44.53.00.5f.45.50.52.4f.53.49.4d.41") >> server_qos.wire_protocol().prefix;
1378-
13791367
// Set SERVER's listening locator for PDP
13801368
Locator_t locator;
13811369
IPLocator::setIPv4(locator, 127, 0, 0, 1);
13821370
locator.port = 11811;
13831371
server_qos.wire_protocol().builtin.metatrafficUnicastLocatorList.push_back(locator);
13841372

13851373
/* Add a remote serve to which this server will connect */
1386-
// Set remote SERVER's GUID prefix
1387-
RemoteServerAttributes remote_server_att;
1388-
remote_server_att.ReadguidPrefix("44.53.01.5f.45.50.52.4f.53.49.4d.41");
1389-
13901374
// Set remote SERVER's listening locator for PDP
13911375
Locator_t remote_locator;
13921376
IPLocator::setIPv4(remote_locator, 127, 0, 0, 1);
13931377
remote_locator.port = 11812;
1394-
remote_server_att.metatrafficUnicastLocatorList.push_back(remote_locator);
13951378

13961379
// Add remote SERVER to SERVER's list of SERVERs
1397-
server_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_att);
1380+
server_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_locator);
13981381

13991382
// Create SERVER
14001383
DomainParticipant* server =
@@ -1416,18 +1399,13 @@ void dds_discovery_examples()
14161399
client_qos.wire_protocol().builtin.discovery_config.discoveryProtocol =
14171400
DiscoveryProtocol_t::CLIENT;
14181401

1419-
// Set SERVER's GUID prefix
1420-
RemoteServerAttributes remote_server_att;
1421-
remote_server_att.ReadguidPrefix("44.53.00.5f.45.50.52.4f.53.49.4d.41");
1422-
14231402
// Set SERVER's listening locator for PDP
14241403
Locator_t locator;
14251404
IPLocator::setIPv4(locator, 127, 0, 0, 1);
14261405
locator.port = 11811;
1427-
remote_server_att.metatrafficUnicastLocatorList.push_back(locator);
14281406

14291407
// Add remote SERVER to CLIENT's list of SERVERs
1430-
client_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_att);
1408+
client_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(locator);
14311409

14321410
// Set ping period to 250 ms
14331411
client_qos.wire_protocol().builtin.discovery_config.discoveryServer_client_syncperiod =
@@ -6099,9 +6077,6 @@ void dds_usecase_examples()
60996077
IPLocator::setIPv4(server_locator, "192.168.10.57");
61006078
server_locator.port = 56542;
61016079
qos.wire_protocol().builtin.metatrafficUnicastLocatorList.push_back(server_locator);
6102-
6103-
// Set the GUID prefix to identify this server
6104-
std::istringstream("72.61.73.70.66.61.72.6d.74.65.73.74") >> qos.wire_protocol().prefix;
61056080
//!--
61066081
}
61076082

@@ -6117,14 +6092,8 @@ void dds_usecase_examples()
61176092
IPLocator::setIPv4(remote_server_locator, "192.168.10.57");
61186093
remote_server_locator.port = 56542;
61196094

6120-
RemoteServerAttributes remote_server_attr;
6121-
remote_server_attr.metatrafficUnicastLocatorList.push_back(remote_server_locator);
6122-
6123-
// Set the GUID prefix to identify the remote server
6124-
remote_server_attr.ReadguidPrefix("72.61.73.70.66.61.72.6d.74.65.73.74");
6125-
61266095
// Connect to the SERVER at the previous locator
6127-
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_attr);
6096+
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_locator);
61286097
//!--
61296098
}
61306099

@@ -6138,6 +6107,7 @@ void dds_usecase_examples()
61386107
// Configure participant_1 as SERVER listening on the previous locator
61396108
DomainParticipantQos server_1_qos;
61406109
server_1_qos.wire_protocol().builtin.discovery_config.discoveryProtocol = DiscoveryProtocol_t::SERVER;
6110+
// Optional GUID
61416111
std::istringstream("75.63.2D.73.76.72.63.6C.6E.74.2D.31") >> server_1_qos.wire_protocol().prefix;
61426112
server_1_qos.wire_protocol().builtin.metatrafficUnicastLocatorList.push_back(server_locator_1);
61436113

@@ -6149,6 +6119,7 @@ void dds_usecase_examples()
61496119
// Configure participant_2 as SERVER listening on the previous locator
61506120
DomainParticipantQos server_2_qos;
61516121
server_2_qos.wire_protocol().builtin.discovery_config.discoveryProtocol = DiscoveryProtocol_t::SERVER;
6122+
// Optional GUID
61526123
std::istringstream("75.63.2D.73.76.72.63.6C.6E.74.2D.32") >> server_2_qos.wire_protocol().prefix;
61536124
server_2_qos.wire_protocol().builtin.metatrafficUnicastLocatorList.push_back(server_locator_2);
61546125
//!--
@@ -6161,24 +6132,16 @@ void dds_usecase_examples()
61616132
IPLocator::setIPv4(remote_server_locator_1, "192.168.10.57");
61626133
remote_server_locator_1.port = 56542;
61636134

6164-
RemoteServerAttributes remote_server_attr_1;
6165-
remote_server_attr_1.ReadguidPrefix("75.63.2D.73.76.72.63.6C.6E.74.2D.31");
6166-
remote_server_attr_1.metatrafficUnicastLocatorList.push_back(remote_server_locator_1);
6167-
61686135
// Define a locator for the second SERVER Participant
61696136
Locator_t remote_server_locator_2;
61706137
IPLocator::setIPv4(remote_server_locator_2, "192.168.10.60");
61716138
remote_server_locator_2.port = 56543;
61726139

6173-
RemoteServerAttributes remote_server_attr_2;
6174-
remote_server_attr_2.ReadguidPrefix("75.63.2D.73.76.72.63.6C.6E.74.2D.32");
6175-
remote_server_attr_2.metatrafficUnicastLocatorList.push_back(remote_server_locator_2);
6176-
61776140
// Configure the current participant as CLIENT connecting to the SERVERS at the previous locators
61786141
DomainParticipantQos client_qos;
61796142
client_qos.wire_protocol().builtin.discovery_config.discoveryProtocol = DiscoveryProtocol_t::CLIENT;
6180-
client_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_attr_1);
6181-
client_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_attr_2);
6143+
client_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_locator_1);
6144+
client_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_locator_2);
61826145
//!--
61836146
}
61846147

@@ -6192,6 +6155,7 @@ void dds_usecase_examples()
61926155
server_locator.port = 56543;
61936156

61946157
qos.wire_protocol().builtin.discovery_config.discoveryProtocol = DiscoveryProtocol_t::SERVER;
6158+
// Optional GUID
61956159
std::istringstream("75.63.2D.73.76.72.63.6C.6E.74.2D.31") >> qos.wire_protocol().prefix;
61966160
qos.wire_protocol().builtin.metatrafficUnicastLocatorList.push_back(server_locator);
61976161

@@ -6200,11 +6164,7 @@ void dds_usecase_examples()
62006164
IPLocator::setIPv4(remote_server_locator, "192.168.10.57");
62016165
remote_server_locator.port = 56542;
62026166

6203-
RemoteServerAttributes remote_server_attr;
6204-
remote_server_attr.ReadguidPrefix("75.63.2D.73.76.72.63.6C.6E.74.2D.32");
6205-
remote_server_attr.metatrafficUnicastLocatorList.push_back(remote_server_locator);
6206-
6207-
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_attr);
6167+
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_locator);
62086168
//!--
62096169
}
62106170

@@ -6218,6 +6178,7 @@ void dds_usecase_examples()
62186178
server_locator.port = 56541;
62196179

62206180
qos.wire_protocol().builtin.discovery_config.discoveryProtocol = DiscoveryProtocol_t::SERVER;
6181+
// Optional GUID
62216182
std::istringstream("75.63.2D.73.76.72.63.6C.6E.74.2D.33") >> qos.wire_protocol().prefix;
62226183
qos.wire_protocol().builtin.metatrafficUnicastLocatorList.push_back(server_locator);
62236184

@@ -6226,22 +6187,14 @@ void dds_usecase_examples()
62266187
IPLocator::setIPv4(remote_server_locator_A, "192.168.10.60");
62276188
remote_server_locator_A.port = 56543;
62286189

6229-
RemoteServerAttributes remote_server_attr_A;
6230-
remote_server_attr_A.ReadguidPrefix("75.63.2D.73.76.72.63.6C.6E.74.2D.31");
6231-
remote_server_attr_A.metatrafficUnicastLocatorList.push_back(remote_server_locator_A);
6232-
6233-
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_attr_A);
6190+
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_locator_A);
62346191

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

6240-
RemoteServerAttributes remote_server_attr_B;
6241-
remote_server_attr_B.ReadguidPrefix("75.63.2D.73.76.72.63.6C.6E.74.2D.32");
6242-
remote_server_attr_B.metatrafficUnicastLocatorList.push_back(remote_server_locator_B);
6243-
6244-
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_attr_B);
6197+
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_locator_B);
62456198
//!--
62466199
}
62476200

@@ -7356,9 +7309,6 @@ void tcp_use_cases()
73567309
eprosima::fastrtps::rtps::IPLocator::setPhysicalPort(listening_locator, tcp_listening_port);
73577310
eprosima::fastrtps::rtps::IPLocator::setLogicalPort(listening_locator, tcp_listening_port);
73587311
qos.wire_protocol().builtin.metatrafficUnicastLocatorList.push_back(listening_locator);
7359-
7360-
// Set the GUID prefix to identify this server
7361-
std::istringstream("44.53.00.5f.45.50.52.4f.53.49.4d.41") >> qos.wire_protocol().prefix;
73627312
//!--
73637313
}
73647314

@@ -7382,15 +7332,8 @@ void tcp_use_cases()
73827332
eprosima::fastrtps::rtps::IPLocator::setPhysicalPort(server_locator, server_port);
73837333
eprosima::fastrtps::rtps::IPLocator::setLogicalPort(server_locator, server_port);
73847334

7385-
// Define the server attributes
7386-
eprosima::fastrtps::rtps::RemoteServerAttributes remote_server_att;
7387-
remote_server_att.metatrafficUnicastLocatorList.push_back(server_locator);
7388-
7389-
// Set the GUID prefix to identify this server
7390-
std::istringstream("44.53.00.5f.45.50.52.4f.53.49.4d.41") >> remote_server_att.guidPrefix;
7391-
73927335
// Add the server
7393-
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_att);
7336+
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(server_locator);
73947337
//!--
73957338
}
73967339
}

0 commit comments

Comments
 (0)