Signed-off-by: Tomoya.Fujita <Tomoya.Fujita@sony.com> (cherry picked from commit 45f133152e59c800e85b1dc97bf14e3b74aecd00) Co-authored-by: tomoya <Tomoya.Fujita@sony.com>
This commit is contained in:
parent
f91a556bcb
commit
e88a953ec9
3 changed files with 90 additions and 1 deletions
|
@ -127,6 +127,50 @@ RCL_WARN_UNUSED
|
||||||
rcl_ret_t
|
rcl_ret_t
|
||||||
rcl_init_options_fini(rcl_init_options_t * init_options);
|
rcl_init_options_fini(rcl_init_options_t * init_options);
|
||||||
|
|
||||||
|
/// Return the domain_id stored in the init options.
|
||||||
|
/**
|
||||||
|
* Get the domain id from the specified rcl_init_options_t object.
|
||||||
|
*
|
||||||
|
* <hr>
|
||||||
|
* Attribute | Adherence
|
||||||
|
* ------------------ | -------------
|
||||||
|
* Allocates Memory | No
|
||||||
|
* Thread-Safe | Yes
|
||||||
|
* Uses Atomics | No
|
||||||
|
* Lock-Free | Yes
|
||||||
|
*
|
||||||
|
* \param[in] init_options object from which the domain id should be retrieved.
|
||||||
|
* \param[out] domain_id domain id to be set in init_options object.
|
||||||
|
* \return `RCL_RET_OK` if successful, or
|
||||||
|
* \return `RCL_RET_INVALID_ARGUMENT` if any arguments are invalid.
|
||||||
|
*/
|
||||||
|
RCL_PUBLIC
|
||||||
|
RCL_WARN_UNUSED
|
||||||
|
rcl_ret_t
|
||||||
|
rcl_init_options_get_domain_id(rcl_init_options_t * init_options, size_t * domain_id);
|
||||||
|
|
||||||
|
/// Set a domain id in the init options provided.
|
||||||
|
/**
|
||||||
|
* Store the domain id in the specified init_options object.
|
||||||
|
*
|
||||||
|
* <hr>
|
||||||
|
* Attribute | Adherence
|
||||||
|
* ------------------ | -------------
|
||||||
|
* Allocates Memory | No
|
||||||
|
* Thread-Safe | Yes
|
||||||
|
* Uses Atomics | No
|
||||||
|
* Lock-Free | Yes
|
||||||
|
*
|
||||||
|
* \param[in] init_options objects in which to set the specified domain id.
|
||||||
|
* \param[in] domain_id domain id to be set in init_options object.
|
||||||
|
* \return `RCL_RET_OK` if successful, or
|
||||||
|
* \return `RCL_RET_INVALID_ARGUMENT` if any arguments are invalid.
|
||||||
|
*/
|
||||||
|
RCL_PUBLIC
|
||||||
|
RCL_WARN_UNUSED
|
||||||
|
rcl_ret_t
|
||||||
|
rcl_init_options_set_domain_id(rcl_init_options_t * init_options, size_t domain_id);
|
||||||
|
|
||||||
/// Return the rmw init options which are stored internally.
|
/// Return the rmw init options which are stored internally.
|
||||||
/**
|
/**
|
||||||
* This function can fail and return `NULL` if:
|
* This function can fail and return `NULL` if:
|
||||||
|
|
|
@ -142,6 +142,25 @@ rcl_init_options_fini(rcl_init_options_t * init_options)
|
||||||
return RCL_RET_OK;
|
return RCL_RET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rcl_ret_t
|
||||||
|
rcl_init_options_get_domain_id(rcl_init_options_t * init_options, size_t * domain_id)
|
||||||
|
{
|
||||||
|
RCL_CHECK_ARGUMENT_FOR_NULL(init_options, RCL_RET_INVALID_ARGUMENT);
|
||||||
|
RCL_CHECK_ARGUMENT_FOR_NULL(init_options->impl, RCL_RET_INVALID_ARGUMENT);
|
||||||
|
RCL_CHECK_ARGUMENT_FOR_NULL(domain_id, RCL_RET_INVALID_ARGUMENT);
|
||||||
|
*domain_id = init_options->impl->rmw_init_options.domain_id;
|
||||||
|
return RCL_RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
rcl_ret_t
|
||||||
|
rcl_init_options_set_domain_id(rcl_init_options_t * init_options, size_t domain_id)
|
||||||
|
{
|
||||||
|
RCL_CHECK_ARGUMENT_FOR_NULL(init_options, RCL_RET_INVALID_ARGUMENT);
|
||||||
|
RCL_CHECK_ARGUMENT_FOR_NULL(init_options->impl, RCL_RET_INVALID_ARGUMENT);
|
||||||
|
init_options->impl->rmw_init_options.domain_id = domain_id;
|
||||||
|
return RCL_RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
rmw_init_options_t *
|
rmw_init_options_t *
|
||||||
rcl_init_options_get_rmw_init_options(rcl_init_options_t * init_options)
|
rcl_init_options_get_rmw_init_options(rcl_init_options_t * init_options)
|
||||||
{
|
{
|
||||||
|
|
|
@ -453,8 +453,34 @@ TEST_F(CLASSNAME(TestRCLFixture, RMW_IMPLEMENTATION), test_rcl_init_options_acce
|
||||||
const rcl_allocator_t * options_allocator = rcl_init_options_get_allocator(&init_options);
|
const rcl_allocator_t * options_allocator = rcl_init_options_get_allocator(&init_options);
|
||||||
EXPECT_TRUE(rcutils_allocator_is_valid(options_allocator));
|
EXPECT_TRUE(rcutils_allocator_is_valid(options_allocator));
|
||||||
|
|
||||||
|
size_t domain_id;
|
||||||
|
ret = rcl_init_options_get_domain_id(NULL, &domain_id);
|
||||||
|
ASSERT_EQ(RCL_RET_INVALID_ARGUMENT, ret) << rcl_get_error_string().str;
|
||||||
|
rcl_reset_error();
|
||||||
|
ret = rcl_init_options_get_domain_id(&init_options, NULL);
|
||||||
|
ASSERT_EQ(RCL_RET_INVALID_ARGUMENT, ret) << rcl_get_error_string().str;
|
||||||
|
rcl_reset_error();
|
||||||
|
ret = rcl_init_options_get_domain_id(NULL, NULL);
|
||||||
|
ASSERT_EQ(RCL_RET_INVALID_ARGUMENT, ret) << rcl_get_error_string().str;
|
||||||
|
rcl_reset_error();
|
||||||
|
ret = rcl_init_options_set_domain_id(NULL, domain_id);
|
||||||
|
ASSERT_EQ(RCL_RET_INVALID_ARGUMENT, ret) << rcl_get_error_string().str;
|
||||||
|
rcl_reset_error();
|
||||||
|
|
||||||
|
ret = rcl_init_options_get_domain_id(&init_options, &domain_id);
|
||||||
|
ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
|
||||||
|
EXPECT_EQ(RCL_DEFAULT_DOMAIN_ID, domain_id);
|
||||||
|
ret = rcl_init_options_set_domain_id(&init_options, static_cast<size_t>(0u));
|
||||||
|
ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
|
||||||
|
ret = rcl_init_options_get_domain_id(&init_options, &domain_id);
|
||||||
|
ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
|
||||||
|
EXPECT_EQ(0U, domain_id);
|
||||||
|
|
||||||
rcl_init_options_t init_options_dst = rcl_get_zero_initialized_init_options();
|
rcl_init_options_t init_options_dst = rcl_get_zero_initialized_init_options();
|
||||||
EXPECT_EQ(RCL_RET_OK, rcl_init_options_copy(&init_options, &init_options_dst));
|
ASSERT_EQ(RCL_RET_OK, rcl_init_options_copy(&init_options, &init_options_dst));
|
||||||
|
ret = rcl_init_options_get_domain_id(&init_options_dst, &domain_id);
|
||||||
|
ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
|
||||||
|
EXPECT_EQ(0U, domain_id);
|
||||||
EXPECT_EQ(RCL_RET_ALREADY_INIT, rcl_init_options_copy(&init_options, &init_options_dst));
|
EXPECT_EQ(RCL_RET_ALREADY_INIT, rcl_init_options_copy(&init_options, &init_options_dst));
|
||||||
EXPECT_EQ(RCL_RET_OK, rcl_init_options_fini(&init_options_dst));
|
EXPECT_EQ(RCL_RET_OK, rcl_init_options_fini(&init_options_dst));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue