Skip to content

Commit efd2fdd

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

5 files changed

Lines changed: 270 additions & 413 deletions

File tree

code/DDSCodeTester.cpp

Lines changed: 32 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,6 +1235,14 @@ void dds_discovery_examples()
12351235
}
12361236
{
12371237
//CONF_SERVER_SERVER_GUIDPREFIX_OPTION_1
1238+
// Using the ``>>`` operator and the ``std::istringstream`` type.
1239+
DomainParticipantQos serverQos;
1240+
std::istringstream("44.53.00.5f.45.50.52.4f.53.49.4d.41") >> serverQos.wire_protocol().prefix;
1241+
//!--
1242+
}
1243+
{
1244+
//CONF_SERVER_SERVER_GUIDPREFIX_OPTION_2
1245+
// Manual setting of the ``unsigned char`` in ASCII format.
12381246
eprosima::fastrtps::rtps::GuidPrefix_t serverGuidPrefix;
12391247
serverGuidPrefix.value[0] = eprosima::fastrtps::rtps::octet(0x44);
12401248
serverGuidPrefix.value[1] = eprosima::fastrtps::rtps::octet(0x53);
@@ -1253,37 +1261,24 @@ void dds_discovery_examples()
12531261
serverQos.wire_protocol().prefix = serverGuidPrefix;
12541262
//!--
12551263
}
1256-
{
1257-
//CONF_SERVER_SERVER_GUIDPREFIX_OPTION_2
1258-
DomainParticipantQos serverQos;
1259-
std::istringstream("44.53.00.5f.45.50.52.4f.53.49.4d.41") >> serverQos.wire_protocol().prefix;
1260-
//!--
1261-
}
1262-
{
1263-
//CONF_SERVER_CLIENT_GUIDPREFIX
1264-
RemoteServerAttributes server;
1265-
server.ReadguidPrefix("44.53.00.5f.45.50.52.4f.53.49.4d.41");
1266-
1267-
DomainParticipantQos clientQos;
1268-
clientQos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(server);
1269-
//!--
1270-
}
12711264
{
12721265
//CONF_SERVER_CLIENT_LOCATORS
12731266
Locator_t locator;
1267+
// The default locator kind is UDPv4
1268+
locator.kind = LOCATOR_KIND_UDPv4;
12741269
IPLocator::setIPv4(locator, 192, 168, 1, 133);
12751270
locator.port = 64863;
1276-
RemoteServerAttributes server;
1277-
server.metatrafficUnicastLocatorList.push_back(locator);
12781271

12791272
DomainParticipantQos clientQos;
1280-
clientQos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(server);
1273+
clientQos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(locator);
12811274
//!--
12821275
}
12831276

12841277
{
12851278
//CONF_SERVER_SERVER_LOCATORS
12861279
Locator_t locator;
1280+
// The default locator kind is UDPv4
1281+
locator.kind = LOCATOR_KIND_UDPv4;
12871282
IPLocator::setIPv4(locator, 192, 168, 1, 133);
12881283
locator.port = 64863;
12891284

@@ -1310,17 +1305,13 @@ void dds_discovery_examples()
13101305
/* Create a new server entry to which the client or server should connect */
13111306
RemoteServerAttributes remote_server_att;
13121307

1313-
// Set server's GUID prefix
1314-
remote_server_att.ReadguidPrefix("44.53.00.5f.45.50.52.4f.53.49.4d.42");
1315-
13161308
// Set server's listening locator for PDP
13171309
Locator_t locator;
13181310
IPLocator::setIPv4(locator, 127, 0, 0, 1);
13191311
locator.port = 11812;
1320-
remote_server_att.metatrafficUnicastLocatorList.push_back(locator);
13211312

13221313
/* Update list of remote servers for this client or server */
1323-
client_or_server_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_att);
1314+
client_or_server_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(locator);
13241315
if (RETCODE_OK != client_or_server->set_qos(client_or_server_qos))
13251316
{
13261317
// Error
@@ -1352,28 +1343,20 @@ void dds_discovery_examples()
13521343
server_qos.wire_protocol().builtin.discovery_config.discoveryProtocol =
13531344
DiscoveryProtocol_t::SERVER;
13541345

1355-
// Set SERVER's GUID prefix
1356-
std::istringstream("44.53.00.5f.45.50.52.4f.53.49.4d.41") >> server_qos.wire_protocol().prefix;
1357-
13581346
// Set SERVER's listening locator for PDP
13591347
Locator_t locator;
13601348
IPLocator::setIPv4(locator, 127, 0, 0, 1);
13611349
locator.port = 11811;
13621350
server_qos.wire_protocol().builtin.metatrafficUnicastLocatorList.push_back(locator);
13631351

13641352
/* Add a remote serve to which this server will connect */
1365-
// Set remote SERVER's GUID prefix
1366-
RemoteServerAttributes remote_server_att;
1367-
remote_server_att.ReadguidPrefix("44.53.01.5f.45.50.52.4f.53.49.4d.41");
1368-
13691353
// Set remote SERVER's listening locator for PDP
13701354
Locator_t remote_locator;
13711355
IPLocator::setIPv4(remote_locator, 127, 0, 0, 1);
13721356
remote_locator.port = 11812;
1373-
remote_server_att.metatrafficUnicastLocatorList.push_back(remote_locator);
13741357

13751358
// Add remote SERVER to SERVER's list of SERVERs
1376-
server_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_att);
1359+
server_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_locator);
13771360

13781361
// Create SERVER
13791362
DomainParticipant* server =
@@ -1395,18 +1378,13 @@ void dds_discovery_examples()
13951378
client_qos.wire_protocol().builtin.discovery_config.discoveryProtocol =
13961379
DiscoveryProtocol_t::CLIENT;
13971380

1398-
// Set SERVER's GUID prefix
1399-
RemoteServerAttributes remote_server_att;
1400-
remote_server_att.ReadguidPrefix("44.53.00.5f.45.50.52.4f.53.49.4d.41");
1401-
14021381
// Set SERVER's listening locator for PDP
14031382
Locator_t locator;
14041383
IPLocator::setIPv4(locator, 127, 0, 0, 1);
14051384
locator.port = 11811;
1406-
remote_server_att.metatrafficUnicastLocatorList.push_back(locator);
14071385

14081386
// Add remote SERVER to CLIENT's list of SERVERs
1409-
client_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_att);
1387+
client_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(locator);
14101388

14111389
// Set ping period to 250 ms
14121390
client_qos.wire_protocol().builtin.discovery_config.discoveryServer_client_syncperiod =
@@ -4948,10 +4926,10 @@ void dynamictypes_examples()
49484926
sequence_member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->create_type(
49494927
type_descriptor)->build());
49504928
*/
4951-
4929+
49524930
// Add the sequence member to the struct
49534931
struct_builder->add_member(sequence_member_descriptor);
4954-
4932+
49554933
sequence_member_descriptor = traits<MemberDescriptor>::make_shared();
49564934
sequence_member_descriptor->name("short_sequence");
49574935
sequence_member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->create_sequence_type(
@@ -4989,7 +4967,7 @@ void dynamictypes_examples()
49894967
int16_t out_simple_value;
49904968
sequence_data->set_int16_value(2, in_simple_value);
49914969
sequence_data->get_int16_value(out_simple_value, 2);
4992-
4970+
49934971
data->return_loaned_value(sequence_data);
49944972
//!--
49954973
}
@@ -5042,7 +5020,7 @@ void dynamictypes_examples()
50425020
int32_t out_simple_value;
50435021
array_data->set_int32_value(2, in_simple_value);
50445022
array_data->get_int32_value(out_simple_value, 2);
5045-
5023+
50465024
data->return_loaned_value(array_data);
50475025
//!--
50485026
}
@@ -5313,7 +5291,7 @@ void dynamictypes_examples()
53135291
// Get the loan for the bitset member
53145292
DynamicData::_ref_type bitset_data = data->loan_value(data->get_member_id_by_name("my_bitset"));
53155293

5316-
// Set and retrieve bitfield values
5294+
// Set and retrieve bitfield values
53175295
int16_t in_value {2};
53185296
int16_t out_value;
53195297
bitset_data->set_int16_value(bitset_data->get_member_id_by_name("d"), in_value);
@@ -6044,9 +6022,6 @@ void dds_usecase_examples()
60446022
IPLocator::setIPv4(server_locator, "192.168.10.57");
60456023
server_locator.port = 56542;
60466024
qos.wire_protocol().builtin.metatrafficUnicastLocatorList.push_back(server_locator);
6047-
6048-
// Set the GUID prefix to identify this server
6049-
std::istringstream("72.61.73.70.66.61.72.6d.74.65.73.74") >> qos.wire_protocol().prefix;
60506025
//!--
60516026
}
60526027

@@ -6062,14 +6037,8 @@ void dds_usecase_examples()
60626037
IPLocator::setIPv4(remote_server_locator, "192.168.10.57");
60636038
remote_server_locator.port = 56542;
60646039

6065-
RemoteServerAttributes remote_server_attr;
6066-
remote_server_attr.metatrafficUnicastLocatorList.push_back(remote_server_locator);
6067-
6068-
// Set the GUID prefix to identify the remote server
6069-
remote_server_attr.ReadguidPrefix("72.61.73.70.66.61.72.6d.74.65.73.74");
6070-
60716040
// Connect to the SERVER at the previous locator
6072-
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_attr);
6041+
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_locator);
60736042
//!--
60746043
}
60756044

@@ -6083,6 +6052,7 @@ void dds_usecase_examples()
60836052
// Configure participant_1 as SERVER listening on the previous locator
60846053
DomainParticipantQos server_1_qos;
60856054
server_1_qos.wire_protocol().builtin.discovery_config.discoveryProtocol = DiscoveryProtocol_t::SERVER;
6055+
// Optional GUID
60866056
std::istringstream("75.63.2D.73.76.72.63.6C.6E.74.2D.31") >> server_1_qos.wire_protocol().prefix;
60876057
server_1_qos.wire_protocol().builtin.metatrafficUnicastLocatorList.push_back(server_locator_1);
60886058

@@ -6094,6 +6064,7 @@ void dds_usecase_examples()
60946064
// Configure participant_2 as SERVER listening on the previous locator
60956065
DomainParticipantQos server_2_qos;
60966066
server_2_qos.wire_protocol().builtin.discovery_config.discoveryProtocol = DiscoveryProtocol_t::SERVER;
6067+
// Optional GUID
60976068
std::istringstream("75.63.2D.73.76.72.63.6C.6E.74.2D.32") >> server_2_qos.wire_protocol().prefix;
60986069
server_2_qos.wire_protocol().builtin.metatrafficUnicastLocatorList.push_back(server_locator_2);
60996070
//!--
@@ -6106,24 +6077,16 @@ void dds_usecase_examples()
61066077
IPLocator::setIPv4(remote_server_locator_1, "192.168.10.57");
61076078
remote_server_locator_1.port = 56542;
61086079

6109-
RemoteServerAttributes remote_server_attr_1;
6110-
remote_server_attr_1.ReadguidPrefix("75.63.2D.73.76.72.63.6C.6E.74.2D.31");
6111-
remote_server_attr_1.metatrafficUnicastLocatorList.push_back(remote_server_locator_1);
6112-
61136080
// Define a locator for the second SERVER Participant
61146081
Locator_t remote_server_locator_2;
61156082
IPLocator::setIPv4(remote_server_locator_2, "192.168.10.60");
61166083
remote_server_locator_2.port = 56543;
61176084

6118-
RemoteServerAttributes remote_server_attr_2;
6119-
remote_server_attr_2.ReadguidPrefix("75.63.2D.73.76.72.63.6C.6E.74.2D.32");
6120-
remote_server_attr_2.metatrafficUnicastLocatorList.push_back(remote_server_locator_2);
6121-
61226085
// Configure the current participant as CLIENT connecting to the SERVERS at the previous locators
61236086
DomainParticipantQos client_qos;
61246087
client_qos.wire_protocol().builtin.discovery_config.discoveryProtocol = DiscoveryProtocol_t::CLIENT;
6125-
client_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_attr_1);
6126-
client_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_attr_2);
6088+
client_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_locator_1);
6089+
client_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_locator_2);
61276090
//!--
61286091
}
61296092

@@ -6137,6 +6100,7 @@ void dds_usecase_examples()
61376100
server_locator.port = 56543;
61386101

61396102
qos.wire_protocol().builtin.discovery_config.discoveryProtocol = DiscoveryProtocol_t::SERVER;
6103+
// Optional GUID
61406104
std::istringstream("75.63.2D.73.76.72.63.6C.6E.74.2D.31") >> qos.wire_protocol().prefix;
61416105
qos.wire_protocol().builtin.metatrafficUnicastLocatorList.push_back(server_locator);
61426106

@@ -6145,11 +6109,7 @@ void dds_usecase_examples()
61456109
IPLocator::setIPv4(remote_server_locator, "192.168.10.57");
61466110
remote_server_locator.port = 56542;
61476111

6148-
RemoteServerAttributes remote_server_attr;
6149-
remote_server_attr.ReadguidPrefix("75.63.2D.73.76.72.63.6C.6E.74.2D.32");
6150-
remote_server_attr.metatrafficUnicastLocatorList.push_back(remote_server_locator);
6151-
6152-
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_attr);
6112+
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_locator);
61536113
//!--
61546114
}
61556115

@@ -6163,6 +6123,7 @@ void dds_usecase_examples()
61636123
server_locator.port = 56541;
61646124

61656125
qos.wire_protocol().builtin.discovery_config.discoveryProtocol = DiscoveryProtocol_t::SERVER;
6126+
// Optional GUID
61666127
std::istringstream("75.63.2D.73.76.72.63.6C.6E.74.2D.33") >> qos.wire_protocol().prefix;
61676128
qos.wire_protocol().builtin.metatrafficUnicastLocatorList.push_back(server_locator);
61686129

@@ -6171,22 +6132,14 @@ void dds_usecase_examples()
61716132
IPLocator::setIPv4(remote_server_locator_A, "192.168.10.60");
61726133
remote_server_locator_A.port = 56543;
61736134

6174-
RemoteServerAttributes remote_server_attr_A;
6175-
remote_server_attr_A.ReadguidPrefix("75.63.2D.73.76.72.63.6C.6E.74.2D.31");
6176-
remote_server_attr_A.metatrafficUnicastLocatorList.push_back(remote_server_locator_A);
6177-
6178-
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_attr_A);
6135+
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_locator_A);
61796136

61806137
// Add the connection attributes to the remote server B.
61816138
Locator_t remote_server_locator_B;
61826139
IPLocator::setIPv4(remote_server_locator_B, "192.168.10.57");
61836140
remote_server_locator_B.port = 56542;
61846141

6185-
RemoteServerAttributes remote_server_attr_B;
6186-
remote_server_attr_B.ReadguidPrefix("75.63.2D.73.76.72.63.6C.6E.74.2D.32");
6187-
remote_server_attr_B.metatrafficUnicastLocatorList.push_back(remote_server_locator_B);
6188-
6189-
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_attr_B);
6142+
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_locator_B);
61906143
//!--
61916144
}
61926145

@@ -7301,9 +7254,6 @@ void tcp_use_cases()
73017254
eprosima::fastrtps::rtps::IPLocator::setPhysicalPort(listening_locator, tcp_listening_port);
73027255
eprosima::fastrtps::rtps::IPLocator::setLogicalPort(listening_locator, tcp_listening_port);
73037256
qos.wire_protocol().builtin.metatrafficUnicastLocatorList.push_back(listening_locator);
7304-
7305-
// Set the GUID prefix to identify this server
7306-
std::istringstream("44.53.00.5f.45.50.52.4f.53.49.4d.41") >> qos.wire_protocol().prefix;
73077257
//!--
73087258
}
73097259

@@ -7327,15 +7277,8 @@ void tcp_use_cases()
73277277
eprosima::fastrtps::rtps::IPLocator::setPhysicalPort(server_locator, server_port);
73287278
eprosima::fastrtps::rtps::IPLocator::setLogicalPort(server_locator, server_port);
73297279

7330-
// Define the server attributes
7331-
eprosima::fastrtps::rtps::RemoteServerAttributes remote_server_att;
7332-
remote_server_att.metatrafficUnicastLocatorList.push_back(server_locator);
7333-
7334-
// Set the GUID prefix to identify this server
7335-
std::istringstream("44.53.00.5f.45.50.52.4f.53.49.4d.41") >> remote_server_att.guidPrefix;
7336-
73377280
// Add the server
7338-
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_att);
7281+
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(server_locator);
73397282
//!--
73407283
}
73417284
}

0 commit comments

Comments
 (0)