Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions rclc/include/rclc/executor.h
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,47 @@ rclc_executor_trigger_one(
unsigned int size,
void * obj);

/**
* Allocates an rclc_executor_t object and sets its values to zero. Can be
* used as an alternative to rclc_executor_get_zero_initialized_executor() if
* no stack allocation can or should be used.
*
* * <hr>
* Attribute | Adherence
* ------------------ | -------------
* Allocates Memory | Yes
* Thread-Safe | No
* Uses Atomics | No
* Lock-Free | No
*
* \param[in] allocator the rcl_allocator_t to be used
* \return pointer to the executor (rclc_executor_t)
* \return NULL, if no memory could be allocated.
*/
RCLC_PUBLIC
rclc_executor_t *
rclc_alloc_zero_initialized_executor(const rcl_allocator_t * const allocator);

/**
* De-allocates an rclc_executor_t object.
*
* * <hr>
* Attribute | Adherence
* ------------------ | -------------
* Allocates Memory | Yes
* Thread-Safe | No
* Uses Atomics | No
* Lock-Free | No
*
* \param[inout] executor a heap-allocated rclc_executor_t
* \return `RCL_RET_OK` if operation was successful
* \return `RCL_RET_INVALID_ARGUMENT` if any null pointer as argument
*/
RCLC_PUBLIC
rcl_ret_t
rclc_executor_free(
rclc_executor_t * executor);

#if __cplusplus
}
#endif
Expand Down
3 changes: 3 additions & 0 deletions rclc/include/rclc/executor_handle.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ typedef enum
ON_NEW_DATA,
ALWAYS
} rclc_executor_handle_invocation_t;
/** Can be used if the node cannot access defines.*/
RCLC_PUBLIC extern const int32_t rclc_on_new_data;
RCLC_PUBLIC extern const int32_t rclc_always;

/// Type definition for subscription callback function
/// - incoming message
Expand Down
146 changes: 146 additions & 0 deletions rclc/include/rclc/init.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,152 @@ rcl_ret_t
rclc_support_fini(
rclc_support_t * support);

/**
* Allocates memory for an rclc_support_t object.
* Can be used if no stack allocation can or should be used.
*
* * <hr>
* Attribute | Adherence
* ------------------ | -------------
* Allocates Memory | Yes
* Thread-Safe | No
* Uses Atomics | No
* Lock-Free | No
*
* \param[in] allocator the rcl_allocator_t to be used
* \return pointer to the support (rclc_support_t)
* \return NULL, if no memory could be allocated.
*/
RCLC_PUBLIC
rclc_support_t *
rclc_support_alloc(const rcl_allocator_t * const allocator);

/**
* Return the pointer to the context member of struct support.
*
* * <hr>
* Attribute | Adherence
* ------------------ | -------------
* Allocates Memory | No
* Thread-Safe | No
* Uses Atomics | No
* Lock-Free | Yes
*
* \param[inout] support an instance of type rclc_support_t
* \return `RCL_RET_OK` if operation was successful
* \return `RCL_RET_INVALID_ARGUMENT` if any null pointer as argument
*/
rcl_context_t *
rclc_get_context(
rclc_support_t * support);

/**
* Return the pointer to the allocator member of struct support.
*
* * <hr>
* Attribute | Adherence
* ------------------ | -------------
* Allocates Memory | No
* Thread-Safe | No
* Uses Atomics | No
* Lock-Free | Yes
*
* \param[inout] support an instance of type rclc_support_t
* \return `RCL_RET_OK` if operation was successful
* \return `RCL_RET_INVALID_ARGUMENT` if any null pointer as argument
*/
rcl_allocator_t *
rclc_get_allocator(
rclc_support_t * support);

/**
* Return the pointer to the clock member of struct support.
*
* * <hr>
* Attribute | Adherence
* ------------------ | -------------
* Allocates Memory | No
* Thread-Safe | No
* Uses Atomics | No
* Lock-Free | Yes
*
* \param[inout] support an instance of type rclc_support_t
* \return `RCL_RET_OK` if operation was successful
* \return `RCL_RET_INVALID_ARGUMENT` if any null pointer as argument
*/
rcl_clock_t *
rclc_get_clock(
rclc_support_t * support);

/**
* De-allocates an rclc_support_t object.
*
* * <hr>
* Attribute | Adherence
* ------------------ | -------------
* Allocates Memory | Yes
* Thread-Safe | No
* Uses Atomics | No
* Lock-Free | No
*
* \param[inout] support a heap-allocated rclc_support_t
* \param[in] allocator the rcl_allocator_t to be used
* \return `RCL_RET_OK` if operation was successful
* \return `RCL_RET_INVALID_ARGUMENT` if any null pointer as argument
*/
rcl_ret_t
rclc_support_free(
rclc_support_t * support,
const rcl_allocator_t * const allocator);


/**
* Allocates the rcl_allocator_t object and sets it to default values.
* Can be used as an alternative to rcl_get_default_allocator() if no
* stack allocation can or should be used.
*
* * <hr>
* Attribute | Adherence
* ------------------ | -------------
* Allocates Memory | Yes
* Thread-Safe | No
* Uses Atomics | No
* Lock-Free | No
*
* \return pointer to the allocator (rcl_allocator_t)
* \return NULL, if no memory could be allocated.
*/
RCLC_PUBLIC
rcl_allocator_t *
rclc_allocator_alloc_default();

/**
* De-allocates an rcl_allocator_t object.
*
* * <hr>
* Attribute | Adherence
* ------------------ | -------------
* Allocates Memory | Yes
* Thread-Safe | No
* Uses Atomics | No
* Lock-Free | No
*
* \param[inout] allocator a heap-allocated rcl_allocator_t
* \return `RCL_RET_OK` if operation was successful
* \return `RCL_RET_INVALID_ARGUMENT` if any null pointer as argument
*/
RCLC_PUBLIC
rcl_ret_t
rclc_allocator_free(
rcl_allocator_t * allocator);


/** Can be used if the node cannot access defines.*/
RCLC_PUBLIC extern const int32_t rcl_ret_ok;
RCLC_PUBLIC extern const int32_t rcl_ret_error;
RCLC_PUBLIC extern const int32_t rcl_ret_timeout;
RCLC_PUBLIC extern const int32_t rcl_ret_unsupported;

#if __cplusplus
}
#endif
Expand Down
42 changes: 42 additions & 0 deletions rclc/include/rclc/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,48 @@ rclc_node_init_with_options(
rclc_support_t * support,
rcl_node_options_t * node_ops);

/**
* Allocates an rcl_node_t object and sets its values to zero.
* Can be used as an alternative to rcl_get_zero_initialized_node() if no
* stack allocation can or should be used.
*
* * <hr>
* Attribute | Adherence
* ------------------ | -------------
* Allocates Memory | Yes
* Thread-Safe | No
* Uses Atomics | No
* Lock-Free | No
*
* \param[in] allocator the rcl_allocator_t to be used
* \return pointer to the node (rcl_node_t)
* \return NULL, if no memory could be allocated.
*/
RCLC_PUBLIC
rcl_node_t *
rclc_alloc_zero_initialized_node(const rcl_allocator_t * const allocator);

/**
* De-allocates an rcl_node_t object.
*
* * <hr>
* Attribute | Adherence
* ------------------ | -------------
* Allocates Memory | Yes
* Thread-Safe | No
* Uses Atomics | No
* Lock-Free | No
*
* \param[inout] node a heap-allocated rcl_node_t
* \param[in] allocator the rcl_allocator_t to be used
* \return `RCL_RET_OK` if operation was successful
* \return `RCL_RET_INVALID_ARGUMENT` if any null pointer as argument
*/
RCLC_PUBLIC
rcl_ret_t
rclc_node_free(
rcl_node_t * node,
const rcl_allocator_t * const allocator);

#if __cplusplus
}
Expand Down
42 changes: 42 additions & 0 deletions rclc/include/rclc/publisher.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,48 @@ rclc_publisher_init(
const char * topic_name,
const rmw_qos_profile_t * qos_profile);

/**
* Allocates memory for an rcl_publisher_t object.
* Can be used as if no stack allocation can or should be used.
*
* * <hr>
* Attribute | Adherence
* ------------------ | -------------
* Allocates Memory | Yes
* Thread-Safe | No
* Uses Atomics | No
* Lock-Free | No
*
* \param[in] allocator the rcl_allocator_t to be used
* \return pointer to a publisher (rcl_publisher_t)
* \return NULL, if no memory could be allocated.
*/
RCLC_PUBLIC
rcl_publisher_t *
rclc_publisher_alloc(
const rcl_allocator_t * const allocator);

/**
* De-allocates an rcl_publisher_t object.
*
* * <hr>
* Attribute | Adherence
* ------------------ | -------------
* Allocates Memory | Yes
* Thread-Safe | No
* Uses Atomics | No
* Lock-Free | No
*
* \param[inout] publisher a heap-allocated rcl_publisher_t
* \param[in] allocator the rcl_allocator_t to be used
* \return `RCL_RET_OK` if operation was successful
* \return `RCL_RET_INVALID_ARGUMENT` if any null pointer as argument
*/
rcl_ret_t
rclc_publisher_free(
rcl_publisher_t * publisher,
const rcl_allocator_t * const allocator);

#if __cplusplus
}
#endif
Expand Down
45 changes: 45 additions & 0 deletions rclc/include/rclc/subscription.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,51 @@ rclc_subscription_init(
const char * topic_name,
const rmw_qos_profile_t * qos_profile);

/**
* Allocates an rcl_subscription_t object and sets its values to zero.
* Can be used as an alternative to rcl_get_zero_initialized_subscription() if no
* stack allocation can or should be used.
*
* * <hr>
* Attribute | Adherence
* ------------------ | -------------
* Allocates Memory | Yes
* Thread-Safe | No
* Uses Atomics | No
* Lock-Free | No
*
* \param[in] allocator the rcl_allocator_t to be used
* \return pointer to the subscription (rcl_subscription_t)
* \return NULL, if no memory could be allocated.
*/
RCLC_PUBLIC
rcl_subscription_t *
rclc_alloc_zero_initialized_subscription(
const rcl_allocator_t * const allocator
);

/**
* De-allocates an rcl_subscription_t object.
*
* * <hr>
* Attribute | Adherence
* ------------------ | -------------
* Allocates Memory | Yes
* Thread-Safe | No
* Uses Atomics | No
* Lock-Free | No
*
* \param[inout] subscription a heap-allocated rcl_subscription_t
* \param[in] allocator the rcl_allocator_t to be used
* \return `RCL_RET_OK` if operation was successful
* \return `RCL_RET_INVALID_ARGUMENT` if any null pointer as argument
*/
RCLC_PUBLIC
rcl_ret_t
rclc_subscription_free(
rcl_subscription_t * subscription,
const rcl_allocator_t * const allocator);

#if __cplusplus
}
#endif
Expand Down
Loading