Skip to content

Commit e2d8bca

Browse files
leeminju531fujitatomoya
authored andcommitted
Add rmw_get_service_endpoint_info and update graph cache entity to support service type hash
Signed-off-by: Minju, Lee <[email protected]>
1 parent 1c5e273 commit e2d8bca

File tree

14 files changed

+413
-17
lines changed

14 files changed

+413
-17
lines changed

rmw_fastrtps_cpp/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ add_library(rmw_fastrtps_cpp
6868
src/rmw_get_gid_for_publisher.cpp
6969
src/rmw_get_implementation_identifier.cpp
7070
src/rmw_get_serialization_format.cpp
71+
src/rmw_get_service_endpoint_info.cpp
7172
src/rmw_get_topic_endpoint_info.cpp
7273
src/rmw_guard_condition.cpp
7374
src/rmw_init.cpp

rmw_fastrtps_cpp/src/rmw_client.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,10 +319,11 @@ rmw_create_client(
319319
reader_qos.data_sharing().off();
320320
}
321321

322+
const rosidl_type_hash_t * ser_type_hash = type_supports->get_type_hash_func(type_supports);
322323
if (!get_datareader_qos(
323324
adapted_qos_policies,
324325
*type_supports->response_typesupport->get_type_hash_func(type_supports->response_typesupport),
325-
reader_qos))
326+
reader_qos, ser_type_hash))
326327
{
327328
RMW_SET_ERROR_MSG("create_client() failed setting response DataReader QoS");
328329
return nullptr;
@@ -389,7 +390,7 @@ rmw_create_client(
389390
if (!get_datawriter_qos(
390391
adapted_qos_policies,
391392
*type_supports->request_typesupport->get_type_hash_func(type_supports->request_typesupport),
392-
writer_qos))
393+
writer_qos, ser_type_hash))
393394
{
394395
RMW_SET_ERROR_MSG("create_client() failed setting request DataWriter QoS");
395396
return nullptr;
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Copyright 2025 Minju Lee (이민주). All rights reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#include "rmw/get_service_endpoint_info.h"
16+
#include "rmw/service_endpoint_info_array.h"
17+
#include "rmw/types.h"
18+
#include "rmw_fastrtps_cpp/identifier.hpp"
19+
#include "rmw_fastrtps_shared_cpp/rmw_common.hpp"
20+
21+
extern "C"
22+
{
23+
rmw_ret_t
24+
rmw_get_clients_info_by_service(
25+
const rmw_node_t * node,
26+
rcutils_allocator_t * allocator,
27+
const char * service_name,
28+
bool no_mangle,
29+
rmw_service_endpoint_info_array_t * clients_info)
30+
{
31+
return rmw_fastrtps_shared_cpp::__rmw_get_clients_info_by_service(
32+
eprosima_fastrtps_identifier, node, allocator, service_name, no_mangle, clients_info);
33+
}
34+
35+
rmw_ret_t
36+
rmw_get_servers_info_by_service(
37+
const rmw_node_t * node,
38+
rcutils_allocator_t * allocator,
39+
const char * service_name,
40+
bool no_mangle,
41+
rmw_service_endpoint_info_array_t * servers_info)
42+
{
43+
return rmw_fastrtps_shared_cpp::__rmw_get_servers_info_by_service(
44+
eprosima_fastrtps_identifier, node, allocator, service_name, no_mangle, servers_info);
45+
}
46+
} // extern "C"

rmw_fastrtps_cpp/src/rmw_service.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,10 +315,11 @@ rmw_create_service(
315315
reader_qos.data_sharing().off();
316316
}
317317

318+
const rosidl_type_hash_t * ser_type_hash = type_supports->get_type_hash_func(type_supports);
318319
if (!get_datareader_qos(
319320
adapted_qos_policies,
320321
*type_supports->request_typesupport->get_type_hash_func(type_supports->request_typesupport),
321-
reader_qos))
322+
reader_qos, ser_type_hash))
322323
{
323324
RMW_SET_ERROR_MSG("create_service() failed setting request DataReader QoS");
324325
return nullptr;
@@ -389,7 +390,7 @@ rmw_create_service(
389390
if (!get_datawriter_qos(
390391
adapted_qos_policies,
391392
*type_supports->response_typesupport->get_type_hash_func(type_supports->response_typesupport),
392-
writer_qos))
393+
writer_qos, ser_type_hash))
393394
{
394395
RMW_SET_ERROR_MSG("create_service() failed setting response DataWriter QoS");
395396
return nullptr;

rmw_fastrtps_dynamic_cpp/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ add_library(rmw_fastrtps_dynamic_cpp
6666
src/rmw_get_gid_for_publisher.cpp
6767
src/rmw_get_implementation_identifier.cpp
6868
src/rmw_get_serialization_format.cpp
69+
src/rmw_get_service_endpoint_info.cpp
6970
src/rmw_get_topic_endpoint_info.cpp
7071
src/rmw_guard_condition.cpp
7172
src/rmw_init.cpp

rmw_fastrtps_dynamic_cpp/src/rmw_client.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,10 +348,11 @@ rmw_create_client(
348348
reader_qos.data_sharing().off();
349349
}
350350

351+
const rosidl_type_hash_t * ser_type_hash = type_supports->get_type_hash_func(type_supports);
351352
if (!get_datareader_qos(
352353
adapted_qos_policies,
353354
*type_supports->response_typesupport->get_type_hash_func(type_supports->response_typesupport),
354-
reader_qos))
355+
reader_qos, ser_type_hash))
355356
{
356357
RMW_SET_ERROR_MSG("create_client() failed setting response DataReader QoS");
357358
return nullptr;
@@ -418,7 +419,7 @@ rmw_create_client(
418419
if (!get_datawriter_qos(
419420
adapted_qos_policies,
420421
*type_supports->request_typesupport->get_type_hash_func(type_supports->request_typesupport),
421-
writer_qos))
422+
writer_qos, ser_type_hash))
422423
{
423424
RMW_SET_ERROR_MSG("create_client() failed setting request DataWriter QoS");
424425
return nullptr;
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Copyright 2025 Minju Lee (이민주). All rights reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#include "rmw/get_service_endpoint_info.h"
16+
#include "rmw/service_endpoint_info_array.h"
17+
#include "rmw/types.h"
18+
#include "rmw_fastrtps_dynamic_cpp/identifier.hpp"
19+
#include "rmw_fastrtps_shared_cpp/rmw_common.hpp"
20+
21+
extern "C"
22+
{
23+
rmw_ret_t
24+
rmw_get_clients_info_by_service(
25+
const rmw_node_t * node,
26+
rcutils_allocator_t * allocator,
27+
const char * service_name,
28+
bool no_mangle,
29+
rmw_service_endpoint_info_array_t * clients_info)
30+
{
31+
return rmw_fastrtps_shared_cpp::__rmw_get_clients_info_by_service(
32+
eprosima_fastrtps_identifier, node, allocator, service_name, no_mangle, clients_info);
33+
}
34+
35+
rmw_ret_t
36+
rmw_get_servers_info_by_service(
37+
const rmw_node_t * node,
38+
rcutils_allocator_t * allocator,
39+
const char * service_name,
40+
bool no_mangle,
41+
rmw_service_endpoint_info_array_t * servers_info)
42+
{
43+
return rmw_fastrtps_shared_cpp::__rmw_get_servers_info_by_service(
44+
eprosima_fastrtps_identifier, node, allocator, service_name, no_mangle, servers_info);
45+
}
46+
} // extern "C"

rmw_fastrtps_dynamic_cpp/src/rmw_service.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,10 +344,11 @@ rmw_create_service(
344344
reader_qos.data_sharing().off();
345345
}
346346

347+
const rosidl_type_hash_t * ser_type_hash = type_supports->get_type_hash_func(type_supports);
347348
if (!get_datareader_qos(
348349
adapted_qos_policies,
349350
*type_supports->request_typesupport->get_type_hash_func(type_supports->request_typesupport),
350-
reader_qos))
351+
reader_qos, ser_type_hash))
351352
{
352353
RMW_SET_ERROR_MSG("create_service() failed setting request DataReader QoS");
353354
return nullptr;
@@ -418,7 +419,7 @@ rmw_create_service(
418419
if (!get_datawriter_qos(
419420
adapted_qos_policies,
420421
*type_supports->response_typesupport->get_type_hash_func(type_supports->response_typesupport),
421-
writer_qos))
422+
writer_qos, ser_type_hash))
422423
{
423424
RMW_SET_ERROR_MSG("create_service() failed setting response DataWriter QoS");
424425
return nullptr;

rmw_fastrtps_shared_cpp/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ add_library(rmw_fastrtps_shared_cpp
7171
src/rmw_get_endpoint_network_flow.cpp
7272
src/rmw_get_gid_for_client.cpp
7373
src/rmw_get_gid_for_publisher.cpp
74+
src/rmw_get_service_endpoint_info.cpp
7475
src/rmw_get_topic_endpoint_info.cpp
7576
src/rmw_guard_condition.cpp
7677
src/rmw_init.cpp

rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/custom_participant_info.hpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,13 @@ class ParticipantListener : public eprosima::fastdds::dds::DomainParticipantList
243243
// We've handled the error, so clear it out.
244244
rmw_reset_error();
245245
}
246-
246+
rosidl_type_hash_t ser_type_hash;
247+
rosidl_type_hash_t * ser_type_hash_ptr = nullptr;
248+
if (RMW_RET_OK == rmw_dds_common::parse_sertype_hash_from_user_data(
249+
userDataValue.data(), userDataValue.size(), ser_type_hash))
250+
{
251+
ser_type_hash_ptr = &ser_type_hash;
252+
}
247253
context->graph_cache.add_entity(
248254
rmw_fastrtps_shared_cpp::create_rmw_gid(
249255
identifier_,
@@ -255,7 +261,8 @@ class ParticipantListener : public eprosima::fastdds::dds::DomainParticipantList
255261
identifier_,
256262
proxyData.participant_guid),
257263
qos_profile,
258-
is_reader);
264+
is_reader,
265+
ser_type_hash_ptr);
259266
} else {
260267
context->graph_cache.remove_entity(
261268
rmw_fastrtps_shared_cpp::create_rmw_gid(

0 commit comments

Comments
 (0)