Skip to content

Commit

Permalink
Dynamic Subscription (BONUS: Allocators): rmw (#353)
Browse files Browse the repository at this point in the history
* Refactor serialization support to use allocators and refs

Signed-off-by: methylDragon <[email protected]>

* Use rmw_serialization_support_init

Signed-off-by: methylDragon <[email protected]>

---------

Signed-off-by: methylDragon <[email protected]>
  • Loading branch information
methylDragon authored Apr 11, 2023
1 parent 91b1dc7 commit 48df81b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
7 changes: 5 additions & 2 deletions rmw/include/rmw/dynamic_message_type_support.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ extern "C"
{
#endif

#include <rcutils/allocator.h>

#include <rosidl_dynamic_typesupport/api/serialization_support.h>
#include <rosidl_dynamic_typesupport/dynamic_message_type_support_struct.h>
#include <rosidl_dynamic_typesupport/identifier.h>
Expand Down Expand Up @@ -57,9 +59,10 @@ rmw_take_dynamic_message_with_info(
RMW_PUBLIC
RMW_WARN_UNUSED
rmw_ret_t
rmw_get_serialization_support(
rmw_serialization_support_init(
const char * serialization_lib_name,
rosidl_dynamic_typesupport_serialization_support_t ** serialization_support); // OUT
rcutils_allocator_t * allocator,
rosidl_dynamic_typesupport_serialization_support_t * serialization_support); // OUT

// TODO(methylDragon): Nice to have only
// RMW_PUBLIC
Expand Down
23 changes: 23 additions & 0 deletions rmw/include/rmw/error_handling.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,29 @@ typedef rcutils_error_state_t rmw_error_state_t;
/// Reset the error state by clearing any previously set error state.
#define rmw_reset_error rcutils_reset_error

/// Set the error message using RCUTILS_SET_ERROR_MSG and append the previous error.
/**
* If there is no previous error, has same behavior as RCUTILS_SET_ERROR_MSG.
* \param[in] msg The error message to be set.
*/
#define RMW_SET_ERROR_MSG_AND_APPEND_PREV_ERROR(msg) \
RCUTILS_SET_ERROR_MSG_AND_APPEND_PREV_ERROR(msg)

/// Set the error message with RCUTILS_SET_ERROR_MSG_WITH_FORMAT_STRING and append the previous
/// error.
/**
* This function sets the error message using the given format string, and appends and resets the
* latest error string.
* The resulting formatted string is silently truncated at RCUTILS_ERROR_MESSAGE_MAX_LENGTH.
*
* If there is no previous error, has same behavior as RCUTILS_SET_ERROR_MSG_WITH_FORMAT_STRING.
*
* \param[in] format_string The string to be used as the format of the error message.
* \param[in] ... Arguments for the format string.
*/
#define RMW_SET_ERROR_MSG_WITH_FORMAT_STRING_AND_APPEND_PREV_ERROR(format_string, ...) \
RCUTILS_SET_ERROR_MSG_WITH_FORMAT_STRING_AND_APPEND_PREV_ERROR(format_string, __VA_ARGS__)

#ifdef __cplusplus
}
#endif
Expand Down

0 comments on commit 48df81b

Please sign in to comment.