Skip to content

Commit d871af0

Browse files
committed
Use create instead of init
Signed-off-by: methylDragon <[email protected]>
1 parent 29577da commit d871af0

8 files changed

+55
-53
lines changed

rclcpp/include/rclcpp/dynamic_typesupport/dynamic_message_type.hpp

+19-18
Original file line numberDiff line numberDiff line change
@@ -34,43 +34,44 @@ namespace dynamic_typesupport
3434
class DynamicMessage;
3535
class DynamicMessageTypeBuilder;
3636

37-
/// Utility wrapper class for rosidl_dynamic_typesupport_dynamic_type_t *
37+
/// Utility wrapper class for `rosidl_dynamic_typesupport_dynamic_type_t *`
3838
/**
3939
* This class:
4040
* - Manages the lifetime of the raw pointer.
4141
* - Exposes getter methods to get the raw pointer and shared pointers
4242
* - Exposes the underlying serialization support API
4343
*
4444
* Ownership:
45-
* - This class borrows the rosidl_dynamic_typesupport_serialization_support_t stored in the passed
46-
* DynamicSerializationSupport. So it cannot outlive the DynamicSerializationSupport.
47-
* - The DynamicSerializationSupport's rosidl_dynamic_typesupport_serialization_support_t pointer
48-
* must point to the same location in memory as the stored raw pointer!
45+
* - This class borrows the `rosidl_dynamic_typesupport_serialization_support_t` stored in the
46+
* passed `DynamicSerializationSupport`.
47+
* So it cannot outlive the `DynamicSerializationSupport`.
48+
* - The `DynamicSerializationSupport`'s `rosidl_dynamic_typesupport_serialization_support_t`
49+
* pointer must point to the same location in memory as the stored raw pointer!
4950
*
50-
* Note: This class is meant to map to the lower level rosidl_dynamic_typesupport_dynamic_type_t,
51-
* which can be constructed via DynamicMessageTypeBuilder, which maps to
52-
* rosidl_dynamic_typesupport_dynamic_type_builder_t.
51+
* This class is meant to map to the lower level `rosidl_dynamic_typesupport_dynamic_type_t`,
52+
* which can be constructed via `DynamicMessageTypeBuilder`, which maps to
53+
* `rosidl_dynamic_typesupport_dynamic_type_builder_t`.
5354
*
54-
* The usual method of obtaining a DynamicMessageType is through construction of
55-
* rosidl_message_type_support_t via rcl_dynamic_message_type_support_handle_init(), then
56-
* taking ownership of its contents. But DynamicMessageTypeBuilder can also be used to obtain
57-
* DynamicMessageType by constructing it bottom-up instead, since it exposes the lower_level
58-
* rosidl methods.
55+
* The usual method of obtaining a `DynamicMessageType` is through construction of
56+
* `rosidl_message_type_support_t` via `rcl_dynamic_message_type_support_handle_create()`, then
57+
* taking ownership of its contents. But `DynamicMessageTypeBuilder` can also be used to obtain
58+
* `DynamicMessageType` by constructing it bottom-up instead, since it exposes the lower_level
59+
* rosidl methods.
5960
*/
6061
class DynamicMessageType : public std::enable_shared_from_this<DynamicMessageType>
6162
{
6263
public:
6364
RCLCPP_SMART_PTR_ALIASES_ONLY(DynamicMessageType)
6465

6566
// CONSTRUCTION ==================================================================================
66-
// Most constructors require a passed in DynamicSerializationSupport::SharedPtr, to extend the
67+
// Most constructors require a passed in `DynamicSerializationSupport::SharedPtr`, to extend the
6768
// lifetime of the serialization support (if the constructor cannot otherwise get it from args).
6869
//
6970
// In cases where a dynamic type pointer is passed, the serialization support composed by
70-
// the type should be the exact same object managed by the DynamicSerializationSupport,
71+
// the type should be the exact same object managed by the `DynamicSerializationSupport`,
7172
// otherwise the lifetime management will not work properly.
7273

73-
/// Construct a new DynamicMessageType with the provided dynamic type builder
74+
/// Construct a new `DynamicMessageType` with the provided dynamic type builder
7475
RCLCPP_PUBLIC
7576
explicit DynamicMessageType(std::shared_ptr<DynamicMessageTypeBuilder> dynamic_type_builder);
7677

@@ -111,7 +112,7 @@ class DynamicMessageType : public std::enable_shared_from_this<DynamicMessageTyp
111112
RCLCPP_PUBLIC
112113
virtual ~DynamicMessageType();
113114

114-
/// Swaps the serialization support if serialization_support is populated
115+
/// Swaps the serialization support if `serialization_support` is populated
115116
RCLCPP_PUBLIC
116117
void
117118
init_from_description(
@@ -183,7 +184,7 @@ class DynamicMessageType : public std::enable_shared_from_this<DynamicMessageTyp
183184
// It isn't actually used by the builder since the builder should compose its own support
184185
//
185186
// ... Though ideally it should be the exact same support as the one stored in the
186-
// DynamicSerializationSupport
187+
// `DynamicSerializationSupport`
187188
DynamicSerializationSupport::SharedPtr serialization_support_;
188189

189190
std::shared_ptr<rosidl_dynamic_typesupport_dynamic_type_t> rosidl_dynamic_type_;

rclcpp/include/rclcpp/dynamic_typesupport/dynamic_message_type_builder.hpp

+16-15
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ namespace dynamic_typesupport
3333
class DynamicMessage;
3434
class DynamicMessageType;
3535

36-
/// Utility wrapper class for rosidl_dynamic_typesupport_dynamic_type_builder_t *
36+
/// Utility wrapper class for `rosidl_dynamic_typesupport_dynamic_type_builder_t *`
3737
/**
3838
* This class:
3939
* - Manages the lifetime of the raw pointer.
@@ -42,33 +42,34 @@ class DynamicMessageType;
4242
*
4343
* Ownership:
4444
* - This class borrows the rosidl_dynamic_typesupport_serialization_support_t stored in the passed
45-
* DynamicSerializationSupport. So it cannot outlive the DynamicSerializationSupport.
46-
* - The DynamicSerializationSupport's rosidl_dynamic_typesupport_serialization_support_t pointer
47-
* must point to the same location in memory as the stored raw pointer!
45+
* `DynamicSerializationSupport`.
46+
* So it cannot outlive the `DynamicSerializationSupport`.
47+
* - The `DynamicSerializationSupport`'s `rosidl_dynamic_typesupport_serialization_support_t`
48+
* pointer must point to the same location in memory as the stored raw pointer!
4849
*
49-
* Note: This class is meant to map to rosidl_dynamic_typesupport_dynamic_type_builder_t,
50-
* facilitating the construction of dynamic types bottom-up in the C++ layer.
50+
* This class is meant to map to rosidl_dynamic_typesupport_dynamic_type_builder_t, facilitating the
51+
* construction of dynamic types bottom-up in the C++ layer.
5152
*
52-
* The usual method of obtaining a DynamicMessageType is through construction of
53-
* rosidl_message_type_support_t via rcl_dynamic_message_type_support_handle_init(), then taking
54-
* ownership of its contents. But DynamicMessageTypeBuilder can also be used to obtain
55-
* DynamicMessageType by constructing it bottom-up instead, since it exposes the lower_level
56-
* rosidl methods.
53+
* The usual method of obtaining a `DynamicMessageType` is through construction of
54+
* `rosidl_message_type_support_t` via `rcl_dynamic_message_type_support_handle_create()`, then
55+
* taking ownership of its contents.
56+
* But `DynamicMessageTypeBuilder` can also be used to obtain `DynamicMessageType` by constructing
57+
* it bottom-up instead, since it exposes the lower_level rosidl methods.
5758
*/
5859
class DynamicMessageTypeBuilder : public std::enable_shared_from_this<DynamicMessageTypeBuilder>
5960
{
6061
public:
6162
RCLCPP_SMART_PTR_ALIASES_ONLY(DynamicMessageTypeBuilder)
6263

6364
// CONSTRUCTION ==================================================================================
64-
// All constructors require a passed in DynamicSerializationSupport::SharedPtr, to extend the
65+
// All constructors require a passed in `DynamicSerializationSupport::SharedPtr`, to extend the
6566
// lifetime of the serialization support.
6667
//
6768
// In cases where a dynamic type builder pointer is passed, the serialization support composed by
68-
// the builder should be the exact same object managed by the DynamicSerializationSupport,
69+
// the builder should be the exact same object managed by the `DynamicSerializationSupport`,
6970
// otherwise the lifetime management will not work properly.
7071

71-
/// Construct a new DynamicMessageTypeBuilder with the provided serialization support
72+
/// Construct a new `DynamicMessageTypeBuilder` with the provided serialization support
7273
RCLCPP_PUBLIC
7374
DynamicMessageTypeBuilder(
7475
DynamicSerializationSupport::SharedPtr serialization_support,
@@ -383,7 +384,7 @@ class DynamicMessageTypeBuilder : public std::enable_shared_from_this<DynamicMes
383384
// It isn't actually used by the builder since the builder should compose its own support
384385
//
385386
// ... Though ideally it should be the exact same support as the one stored in the
386-
// DynamicSerializationSupport
387+
// `DynamicSerializationSupport`
387388
DynamicSerializationSupport::SharedPtr serialization_support_;
388389

389390
std::shared_ptr<rosidl_dynamic_typesupport_dynamic_type_builder_t> rosidl_dynamic_type_builder_;

rclcpp/include/rclcpp/dynamic_typesupport/dynamic_message_type_support.hpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ namespace rclcpp
3535
namespace dynamic_typesupport
3636
{
3737

38-
/// Utility wrapper class for rosidl_message_type_support_t * containing managed
38+
/// Utility wrapper class for `rosidl_message_type_support_t *` containing managed
3939
/// instances of the typesupport handle impl.
4040
/**
4141
*
4242
* NOTE: This class is the recommended way to obtain the dynamic message type
43-
* support struct, instead of rcl_dynamic_message_type_support_handle_init,
43+
* support struct, instead of `rcl_dynamic_message_type_support_handle_create()`,
4444
* because this class will manage the lifetimes for you.
4545
*
4646
* Do NOT call rcl_dynamic_message_type_support_handle_destroy!!
@@ -52,7 +52,7 @@ namespace dynamic_typesupport
5252
* serialization support API
5353
*
5454
* Ownership:
55-
* - This class, similarly to the rosidl_dynamic_typesupport_serialization_support_t, must outlive
55+
* - This class, similarly to the `rosidl_dynamic_typesupport_serialization_support_t`, must outlive
5656
* all downstream usages of the serialization support.
5757
*/
5858
class DynamicMessageTypeSupport : public std::enable_shared_from_this<DynamicMessageTypeSupport>
@@ -63,15 +63,15 @@ class DynamicMessageTypeSupport : public std::enable_shared_from_this<DynamicMes
6363
// CONSTRUCTION ==================================================================================
6464
/// From description
6565
/// Does NOT take ownership of the description (copies instead.)
66-
/// Constructs type support top-down (calling rcl_dynamic_message_type_support_handle_init)
66+
/// Constructs type support top-down (calling `rcl_dynamic_message_type_support_handle_create()`)
6767
RCLCPP_PUBLIC
6868
DynamicMessageTypeSupport(
6969
const rosidl_runtime_c__type_description__TypeDescription & description,
7070
const std::string & serialization_library_name = "");
7171

7272
/// From description, for provided serialization support
7373
/// Does NOT take ownership of the description (copies instead.)
74-
/// Constructs type support top-down (calling rmw_dynamic_message_type_support_handle_init)
74+
/// Constructs type support top-down (calling `rmw_dynamic_message_type_support_handle_create()`)
7575
RCLCPP_PUBLIC
7676
DynamicMessageTypeSupport(
7777
DynamicSerializationSupport::SharedPtr serialization_support,

rclcpp/src/rclcpp/dynamic_typesupport/dynamic_message.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ DynamicMessage::DynamicMessage(const DynamicMessageTypeBuilder::SharedPtr dynami
5858
}
5959

6060
rosidl_dynamic_typesupport_dynamic_data_t * rosidl_dynamic_data = nullptr;
61-
rcutils_ret_t ret = rosidl_dynamic_typesupport_dynamic_data_init_from_dynamic_type_builder(
61+
rcutils_ret_t ret = rosidl_dynamic_typesupport_dynamic_data_create_from_dynamic_type_builder(
6262
rosidl_dynamic_type_builder, &rosidl_dynamic_data);
6363
if (ret != RCUTILS_RET_OK || !rosidl_dynamic_data) {
6464
throw std::runtime_error("could not create new dynamic data object from dynamic type builder");
@@ -90,7 +90,7 @@ DynamicMessage::DynamicMessage(const DynamicMessageType::SharedPtr dynamic_type)
9090
}
9191

9292
rosidl_dynamic_typesupport_dynamic_data_t * rosidl_dynamic_data = nullptr;
93-
rcutils_ret_t ret = rosidl_dynamic_typesupport_dynamic_data_init_from_dynamic_type(
93+
rcutils_ret_t ret = rosidl_dynamic_typesupport_dynamic_data_create_from_dynamic_type(
9494
rosidl_dynamic_type, &rosidl_dynamic_data);
9595
if (ret != RCUTILS_RET_OK || !rosidl_dynamic_data) {
9696
throw std::runtime_error(
@@ -428,7 +428,7 @@ DynamicMessage
428428
DynamicMessage::init_from_type(DynamicMessageType & type) const
429429
{
430430
rosidl_dynamic_typesupport_dynamic_data_t * rosidl_dynamic_data = nullptr;
431-
rcutils_ret_t ret = rosidl_dynamic_typesupport_dynamic_data_init_from_dynamic_type(
431+
rcutils_ret_t ret = rosidl_dynamic_typesupport_dynamic_data_create_from_dynamic_type(
432432
type.get_rosidl_dynamic_type(), &rosidl_dynamic_data);
433433
if (ret != RCUTILS_RET_OK || !rosidl_dynamic_data) {
434434
throw std::runtime_error("could not create new dynamic data object from dynamic type");
@@ -441,7 +441,7 @@ DynamicMessage::SharedPtr
441441
DynamicMessage::init_from_type_shared(DynamicMessageType & type) const
442442
{
443443
rosidl_dynamic_typesupport_dynamic_data_t * rosidl_dynamic_data = nullptr;
444-
rcutils_ret_t ret = rosidl_dynamic_typesupport_dynamic_data_init_from_dynamic_type(
444+
rcutils_ret_t ret = rosidl_dynamic_typesupport_dynamic_data_create_from_dynamic_type(
445445
type.get_rosidl_dynamic_type(), &rosidl_dynamic_data);
446446
if (ret != RCUTILS_RET_OK || !rosidl_dynamic_data) {
447447
throw std::runtime_error("could not create new dynamic data object from dynamic type");

rclcpp/src/rclcpp/dynamic_typesupport/dynamic_message_type.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ DynamicMessageType::DynamicMessageType(DynamicMessageTypeBuilder::SharedPtr dyna
5050
}
5151

5252
rosidl_dynamic_typesupport_dynamic_type_t * rosidl_dynamic_type = nullptr;
53-
rcutils_ret_t ret = rosidl_dynamic_typesupport_dynamic_type_init_from_dynamic_type_builder(
53+
rcutils_ret_t ret = rosidl_dynamic_typesupport_dynamic_type_create_from_dynamic_type_builder(
5454
rosidl_dynamic_type_builder, &rosidl_dynamic_type);
5555
if (ret != RCUTILS_RET_OK || !rosidl_dynamic_type) {
5656
throw std::runtime_error("could not create new dynamic type object");
@@ -159,7 +159,7 @@ DynamicMessageType::init_from_description(
159159
}
160160

161161
rosidl_dynamic_typesupport_dynamic_type_t * rosidl_dynamic_type = nullptr;
162-
rcutils_ret_t ret = rosidl_dynamic_typesupport_dynamic_type_init_from_description(
162+
rcutils_ret_t ret = rosidl_dynamic_typesupport_dynamic_type_create_from_description(
163163
serialization_support_->get_rosidl_serialization_support(), &description, &rosidl_dynamic_type);
164164
if (ret != RCUTILS_RET_OK || !rosidl_dynamic_type) {
165165
throw std::runtime_error("could not create new dynamic type object");

rclcpp/src/rclcpp/dynamic_typesupport/dynamic_message_type_builder.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ using rclcpp::dynamic_typesupport::DynamicSerializationSupport;
4040
#endif
4141

4242

43-
// CONSTRUCTION ==================================================================================
43+
// CONSTRUCTION ====================================================================================
4444
DynamicMessageTypeBuilder::DynamicMessageTypeBuilder(
4545
DynamicSerializationSupport::SharedPtr serialization_support, const std::string & name)
4646
: serialization_support_(serialization_support), rosidl_dynamic_type_builder_(nullptr)
@@ -153,7 +153,7 @@ DynamicMessageTypeBuilder::init_from_description(
153153
}
154154

155155
rosidl_dynamic_typesupport_dynamic_type_builder_t * rosidl_dynamic_type_builder = nullptr;
156-
rcutils_ret_t ret = rosidl_dynamic_typesupport_dynamic_type_builder_init_from_description(
156+
rcutils_ret_t ret = rosidl_dynamic_typesupport_dynamic_type_builder_create_from_description(
157157
serialization_support_->get_rosidl_serialization_support(), &description,
158158
&rosidl_dynamic_type_builder);
159159
if (ret != RCUTILS_RET_OK || !rosidl_dynamic_type_builder) {
@@ -183,7 +183,7 @@ DynamicMessageTypeBuilder::init_from_serialization_support_(
183183

184184

185185
rosidl_dynamic_typesupport_dynamic_type_builder_t * rosidl_dynamic_type_builder = nullptr;
186-
rcutils_ret_t ret = rosidl_dynamic_typesupport_dynamic_type_builder_init(
186+
rcutils_ret_t ret = rosidl_dynamic_typesupport_dynamic_type_builder_create(
187187
serialization_support->get_rosidl_serialization_support(),
188188
name.c_str(), name.size(),
189189
&rosidl_dynamic_type_builder);

rclcpp/src/rclcpp/dynamic_typesupport/dynamic_message_type_support.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ DynamicMessageTypeSupport::DynamicMessageTypeSupport(
5757
rcl_ret_t ret;
5858

5959
if (serialization_library_name.empty()) {
60-
ret = rcl_dynamic_message_type_support_handle_init(nullptr, &description, &ts);
60+
ret = rcl_dynamic_message_type_support_handle_create(nullptr, &description, &ts);
6161
} else {
62-
ret = rcl_dynamic_message_type_support_handle_init(
62+
ret = rcl_dynamic_message_type_support_handle_create(
6363
serialization_library_name.c_str(), &description, &ts);
6464
}
6565
if (ret != RCL_RET_OK) {
@@ -135,7 +135,7 @@ DynamicMessageTypeSupport::DynamicMessageTypeSupport(
135135
throw std::runtime_error("failed to get type hash");
136136
}
137137

138-
rmw_ret_t ret = rmw_dynamic_message_type_support_handle_init(
138+
rmw_ret_t ret = rmw_dynamic_message_type_support_handle_create(
139139
serialization_support->get_rosidl_serialization_support(),
140140
rmw_feature_supported(RMW_MIDDLEWARE_SUPPORTS_TYPE_DISCOVERY),
141141
type_hash.get(), // type_hash
@@ -280,8 +280,8 @@ DynamicMessageTypeSupport::manage_description_(
280280
}
281281

282282

283-
// NOTE(methylDragon): This looks like rmw_dynamic_message_type_support_handle_init, but instead
284-
// just aggregates already initialized objects
283+
// This looks like rmw_`dynamic_message_type_support_handle_create()`, but instead just aggregates
284+
// already initialized objects
285285
void
286286
DynamicMessageTypeSupport::init_rosidl_message_type_support_(
287287
DynamicSerializationSupport::SharedPtr serialization_support,

rclcpp/src/rclcpp/dynamic_typesupport/dynamic_serialization_support.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ using rclcpp::dynamic_typesupport::DynamicSerializationSupport;
2929

3030
// CONSTRUCTION ====================================================================================
3131
DynamicSerializationSupport::DynamicSerializationSupport()
32-
: DynamicSerializationSupport::DynamicSerializationSupport("") {};
32+
: DynamicSerializationSupport::DynamicSerializationSupport("") {}
3333

3434
DynamicSerializationSupport::DynamicSerializationSupport(
3535
const std::string & serialization_library_name)

0 commit comments

Comments
 (0)