@@ -65,7 +65,7 @@ DynamicMessageTypeSupport::DynamicMessageTypeSupport(
65
65
}
66
66
if (ret != RCL_RET_OK) {
67
67
std::string error_msg =
68
- std::string (" error initializing rosidl message type support:\n " ) + rcl_get_error_string ().str ;
68
+ std::string (" error initializing rosidl message type support: " ) + rcl_get_error_string ().str ;
69
69
rcl_reset_error ();
70
70
throw std::runtime_error (error_msg);
71
71
}
@@ -75,16 +75,17 @@ DynamicMessageTypeSupport::DynamicMessageTypeSupport(
75
75
throw std::runtime_error (" rosidl message type support is of the wrong type" );
76
76
}
77
77
78
- auto ts_impl = static_cast <const rosidl_dynamic_message_type_support_impl_t *>(
79
- rosidl_message_type_support_.data );
78
+ auto ts_impl = static_cast <rosidl_dynamic_message_type_support_impl_t *>( const_cast < void *>(
79
+ rosidl_message_type_support_.data ) );
80
80
81
- serialization_support_ = DynamicSerializationSupport::make_shared (ts_impl->serialization_support );
81
+ serialization_support_ = DynamicSerializationSupport::make_shared (
82
+ std::move (ts_impl->serialization_support ));
82
83
83
84
dynamic_message_type_ = DynamicMessageType::make_shared (
84
- get_shared_dynamic_serialization_support (), ts_impl->dynamic_message_type );
85
+ get_shared_dynamic_serialization_support (), std::move ( ts_impl->dynamic_message_type ) );
85
86
86
87
dynamic_message_ = DynamicMessage::make_shared (
87
- get_shared_dynamic_serialization_support (), ts_impl->dynamic_message );
88
+ get_shared_dynamic_serialization_support (), std::move ( ts_impl->dynamic_message ) );
88
89
}
89
90
90
91
DynamicMessageTypeSupport::DynamicMessageTypeSupport (
@@ -111,7 +112,7 @@ DynamicMessageTypeSupport::DynamicMessageTypeSupport(
111
112
}
112
113
113
114
rcutils_ret_t ret = rosidl_dynamic_message_type_support_handle_init (
114
- serialization_support->get_rosidl_serialization_support (),
115
+ & serialization_support->get_rosidl_serialization_support (),
115
116
&type_hash, // type_hash
116
117
&description, // type_description
117
118
nullptr , // type_description_sources (not implemented for dynamic types)
@@ -174,40 +175,20 @@ DynamicMessageTypeSupport::DynamicMessageTypeSupport(
174
175
" dynamic message library identifier." );
175
176
}
176
177
177
- // Check pointers
178
- /* *INDENT-OFF* */
179
- if (serialization_support->get_rosidl_serialization_support () !=
180
- dynamic_message_type
181
- ->get_shared_dynamic_serialization_support ()
182
- ->get_rosidl_serialization_support ())
183
- {
184
- throw std::runtime_error (" serialization support pointer does not match dynamic message type's" );
185
- }
186
- if (dynamic_message_type
187
- ->get_shared_dynamic_serialization_support ()
188
- ->get_rosidl_serialization_support () !=
189
- dynamic_message_type
190
- ->get_shared_dynamic_serialization_support ()
191
- ->get_rosidl_serialization_support ())
192
- {
193
- throw std::runtime_error (" serialization support does not match pointer dynamic message type's" );
194
- }
195
- /* *INDENT-ON* */
196
-
197
178
rosidl_type_hash_t type_hash;
198
179
rcutils_ret_t hash_ret = rcl_calculate_type_hash (
199
180
// TODO(methylDragon): Swap this out with the conversion function when it is ready
200
181
// from https://github.com/ros2/rcl/pull/1052
201
182
reinterpret_cast <const type_description_interfaces__msg__TypeDescription *>(&description),
202
183
&type_hash);
203
184
if (hash_ret != RCL_RET_OK) {
204
- std::string error_msg = std::string (" failed to get type hash:\n " ) + rcl_get_error_string ().str ;
185
+ std::string error_msg = std::string (" failed to get type hash: " ) + rcl_get_error_string ().str ;
205
186
rcl_reset_error ();
206
187
throw std::runtime_error (error_msg);
207
188
}
208
189
209
190
auto ts_impl = static_cast <rosidl_dynamic_message_type_support_impl_t *>(
210
- allocator.zero_allocate (1 , sizeof (rosidl_dynamic_message_type_support_impl_t ), & allocator.state )
191
+ allocator.zero_allocate (1 , sizeof (rosidl_dynamic_message_type_support_impl_t ), allocator.state )
211
192
);
212
193
if (!ts_impl) {
213
194
throw std::runtime_error (" could not allocate rosidl_message_type_support_t" );
@@ -255,7 +236,7 @@ DynamicMessageTypeSupport::~DynamicMessageTypeSupport()
255
236
rosidl_runtime_c__type_description__TypeDescription__fini (&ts_impl->type_description );
256
237
rosidl_runtime_c__type_description__TypeSource__Sequence__fini (
257
238
&ts_impl->type_description_sources );
258
- allocator.deallocate (static_cast <void *>(ts_impl), & allocator.state ); // Always C allocated
239
+ allocator.deallocate (static_cast <void *>(ts_impl), allocator.state ); // Always C allocated
259
240
}
260
241
261
242
0 commit comments