Skip to content

Commit 2bb8431

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

5 files changed

Lines changed: 269 additions & 412 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 =
@@ -4986,10 +4964,10 @@ void dynamictypes_examples()
49864964
sequence_member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->create_type(
49874965
type_descriptor)->build());
49884966
*/
4989-
4967+
49904968
// Add the sequence member to the struct
49914969
struct_builder->add_member(sequence_member_descriptor);
4992-
4970+
49934971
sequence_member_descriptor = traits<MemberDescriptor>::make_shared();
49944972
sequence_member_descriptor->name("short_sequence");
49954973
sequence_member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->create_sequence_type(
@@ -5027,7 +5005,7 @@ void dynamictypes_examples()
50275005
int16_t out_simple_value;
50285006
sequence_data->set_int16_value(2, in_simple_value);
50295007
sequence_data->get_int16_value(out_simple_value, 2);
5030-
5008+
50315009
data->return_loaned_value(sequence_data);
50325010
//!--
50335011
}
@@ -5080,7 +5058,7 @@ void dynamictypes_examples()
50805058
int32_t out_simple_value;
50815059
array_data->set_int32_value(2, in_simple_value);
50825060
array_data->get_int32_value(out_simple_value, 2);
5083-
5061+
50845062
data->return_loaned_value(array_data);
50855063
//!--
50865064
}
@@ -5351,7 +5329,7 @@ void dynamictypes_examples()
53515329
// Get the loan for the bitset member
53525330
DynamicData::_ref_type bitset_data = data->loan_value(data->get_member_id_by_name("my_bitset"));
53535331

5354-
// Set and retrieve bitfield values
5332+
// Set and retrieve bitfield values
53555333
int16_t in_value {2};
53565334
int16_t out_value;
53575335
bitset_data->set_int16_value(bitset_data->get_member_id_by_name("d"), in_value);
@@ -6082,9 +6060,6 @@ void dds_usecase_examples()
60826060
IPLocator::setIPv4(server_locator, "192.168.10.57");
60836061
server_locator.port = 56542;
60846062
qos.wire_protocol().builtin.metatrafficUnicastLocatorList.push_back(server_locator);
6085-
6086-
// Set the GUID prefix to identify this server
6087-
std::istringstream("72.61.73.70.66.61.72.6d.74.65.73.74") >> qos.wire_protocol().prefix;
60886063
//!--
60896064
}
60906065

@@ -6100,14 +6075,8 @@ void dds_usecase_examples()
61006075
IPLocator::setIPv4(remote_server_locator, "192.168.10.57");
61016076
remote_server_locator.port = 56542;
61026077

6103-
RemoteServerAttributes remote_server_attr;
6104-
remote_server_attr.metatrafficUnicastLocatorList.push_back(remote_server_locator);
6105-
6106-
// Set the GUID prefix to identify the remote server
6107-
remote_server_attr.ReadguidPrefix("72.61.73.70.66.61.72.6d.74.65.73.74");
6108-
61096078
// Connect to the SERVER at the previous locator
6110-
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_attr);
6079+
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_locator);
61116080
//!--
61126081
}
61136082

@@ -6121,6 +6090,7 @@ void dds_usecase_examples()
61216090
// Configure participant_1 as SERVER listening on the previous locator
61226091
DomainParticipantQos server_1_qos;
61236092
server_1_qos.wire_protocol().builtin.discovery_config.discoveryProtocol = DiscoveryProtocol_t::SERVER;
6093+
// Optional GUID
61246094
std::istringstream("75.63.2D.73.76.72.63.6C.6E.74.2D.31") >> server_1_qos.wire_protocol().prefix;
61256095
server_1_qos.wire_protocol().builtin.metatrafficUnicastLocatorList.push_back(server_locator_1);
61266096

@@ -6132,6 +6102,7 @@ void dds_usecase_examples()
61326102
// Configure participant_2 as SERVER listening on the previous locator
61336103
DomainParticipantQos server_2_qos;
61346104
server_2_qos.wire_protocol().builtin.discovery_config.discoveryProtocol = DiscoveryProtocol_t::SERVER;
6105+
// Optional GUID
61356106
std::istringstream("75.63.2D.73.76.72.63.6C.6E.74.2D.32") >> server_2_qos.wire_protocol().prefix;
61366107
server_2_qos.wire_protocol().builtin.metatrafficUnicastLocatorList.push_back(server_locator_2);
61376108
//!--
@@ -6144,24 +6115,16 @@ void dds_usecase_examples()
61446115
IPLocator::setIPv4(remote_server_locator_1, "192.168.10.57");
61456116
remote_server_locator_1.port = 56542;
61466117

6147-
RemoteServerAttributes remote_server_attr_1;
6148-
remote_server_attr_1.ReadguidPrefix("75.63.2D.73.76.72.63.6C.6E.74.2D.31");
6149-
remote_server_attr_1.metatrafficUnicastLocatorList.push_back(remote_server_locator_1);
6150-
61516118
// Define a locator for the second SERVER Participant
61526119
Locator_t remote_server_locator_2;
61536120
IPLocator::setIPv4(remote_server_locator_2, "192.168.10.60");
61546121
remote_server_locator_2.port = 56543;
61556122

6156-
RemoteServerAttributes remote_server_attr_2;
6157-
remote_server_attr_2.ReadguidPrefix("75.63.2D.73.76.72.63.6C.6E.74.2D.32");
6158-
remote_server_attr_2.metatrafficUnicastLocatorList.push_back(remote_server_locator_2);
6159-
61606123
// Configure the current participant as CLIENT connecting to the SERVERS at the previous locators
61616124
DomainParticipantQos client_qos;
61626125
client_qos.wire_protocol().builtin.discovery_config.discoveryProtocol = DiscoveryProtocol_t::CLIENT;
6163-
client_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_attr_1);
6164-
client_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_attr_2);
6126+
client_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_locator_1);
6127+
client_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_locator_2);
61656128
//!--
61666129
}
61676130

@@ -6175,6 +6138,7 @@ void dds_usecase_examples()
61756138
server_locator.port = 56543;
61766139

61776140
qos.wire_protocol().builtin.discovery_config.discoveryProtocol = DiscoveryProtocol_t::SERVER;
6141+
// Optional GUID
61786142
std::istringstream("75.63.2D.73.76.72.63.6C.6E.74.2D.31") >> qos.wire_protocol().prefix;
61796143
qos.wire_protocol().builtin.metatrafficUnicastLocatorList.push_back(server_locator);
61806144

@@ -6183,11 +6147,7 @@ void dds_usecase_examples()
61836147
IPLocator::setIPv4(remote_server_locator, "192.168.10.57");
61846148
remote_server_locator.port = 56542;
61856149

6186-
RemoteServerAttributes remote_server_attr;
6187-
remote_server_attr.ReadguidPrefix("75.63.2D.73.76.72.63.6C.6E.74.2D.32");
6188-
remote_server_attr.metatrafficUnicastLocatorList.push_back(remote_server_locator);
6189-
6190-
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_attr);
6150+
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_locator);
61916151
//!--
61926152
}
61936153

@@ -6201,6 +6161,7 @@ void dds_usecase_examples()
62016161
server_locator.port = 56541;
62026162

62036163
qos.wire_protocol().builtin.discovery_config.discoveryProtocol = DiscoveryProtocol_t::SERVER;
6164+
// Optional GUID
62046165
std::istringstream("75.63.2D.73.76.72.63.6C.6E.74.2D.33") >> qos.wire_protocol().prefix;
62056166
qos.wire_protocol().builtin.metatrafficUnicastLocatorList.push_back(server_locator);
62066167

@@ -6209,22 +6170,14 @@ void dds_usecase_examples()
62096170
IPLocator::setIPv4(remote_server_locator_A, "192.168.10.60");
62106171
remote_server_locator_A.port = 56543;
62116172

6212-
RemoteServerAttributes remote_server_attr_A;
6213-
remote_server_attr_A.ReadguidPrefix("75.63.2D.73.76.72.63.6C.6E.74.2D.31");
6214-
remote_server_attr_A.metatrafficUnicastLocatorList.push_back(remote_server_locator_A);
6215-
6216-
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_attr_A);
6173+
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_locator_A);
62176174

62186175
// Add the connection attributes to the remote server B.
62196176
Locator_t remote_server_locator_B;
62206177
IPLocator::setIPv4(remote_server_locator_B, "192.168.10.57");
62216178
remote_server_locator_B.port = 56542;
62226179

6223-
RemoteServerAttributes remote_server_attr_B;
6224-
remote_server_attr_B.ReadguidPrefix("75.63.2D.73.76.72.63.6C.6E.74.2D.32");
6225-
remote_server_attr_B.metatrafficUnicastLocatorList.push_back(remote_server_locator_B);
6226-
6227-
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_attr_B);
6180+
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_locator_B);
62286181
//!--
62296182
}
62306183

@@ -7339,9 +7292,6 @@ void tcp_use_cases()
73397292
eprosima::fastrtps::rtps::IPLocator::setPhysicalPort(listening_locator, tcp_listening_port);
73407293
eprosima::fastrtps::rtps::IPLocator::setLogicalPort(listening_locator, tcp_listening_port);
73417294
qos.wire_protocol().builtin.metatrafficUnicastLocatorList.push_back(listening_locator);
7342-
7343-
// Set the GUID prefix to identify this server
7344-
std::istringstream("44.53.00.5f.45.50.52.4f.53.49.4d.41") >> qos.wire_protocol().prefix;
73457295
//!--
73467296
}
73477297

@@ -7365,15 +7315,8 @@ void tcp_use_cases()
73657315
eprosima::fastrtps::rtps::IPLocator::setPhysicalPort(server_locator, server_port);
73667316
eprosima::fastrtps::rtps::IPLocator::setLogicalPort(server_locator, server_port);
73677317

7368-
// Define the server attributes
7369-
eprosima::fastrtps::rtps::RemoteServerAttributes remote_server_att;
7370-
remote_server_att.metatrafficUnicastLocatorList.push_back(server_locator);
7371-
7372-
// Set the GUID prefix to identify this server
7373-
std::istringstream("44.53.00.5f.45.50.52.4f.53.49.4d.41") >> remote_server_att.guidPrefix;
7374-
73757318
// Add the server
7376-
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_att);
7319+
qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(server_locator);
73777320
//!--
73787321
}
73797322
}

0 commit comments

Comments
 (0)