Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add content-filtered-topic interfaces #894

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
2016557
to support a feature of content filtered topic
Dec 2, 2020
593a4bf
Update function description
Dec 3, 2020
fc651ec
Nit.
Feb 2, 2021
1af2e83
Update based on review
Feb 22, 2021
953ad14
Not to reset error if subscrption is invalid.
Feb 23, 2021
9626a6c
remove copy function for subscription_options
Feb 23, 2021
da7be13
update comments to make linelength <= 100
Feb 25, 2021
14ff61e
Update comments
Mar 11, 2021
0aaf6e1
add test for filter data by all cft interfaces with rcl_take
Mar 12, 2021
190948c
update interface
Oct 11, 2021
6381b08
update test
Oct 13, 2021
154ed6f
add lost test file
Oct 25, 2021
680d0c2
update test case
Oct 25, 2021
069b196
nit
Oct 25, 2021
328e8ff
fix for unsupported cft and unscrutify
Oct 25, 2021
65f53dd
fix unscrutify
Oct 25, 2021
f3364d9
rename
Oct 26, 2021
5550615
refactor test
Jan 13, 2022
bdc50e6
fix for uncrustify and typo
Jan 13, 2022
1667f3a
relate to `rcutils_string_array_t expression_parameters` changed in rmw
Mar 17, 2022
e03e121
add necessary structure for fallback interfaces
Mar 24, 2022
100d4a0
remove the implementation temporary, add them with fallback in the fe…
Mar 24, 2022
b33d745
address comments
Mar 25, 2022
0ca5105
update comments
Mar 25, 2022
3f6421f
add DDS content filter implementation without fallback
Mar 25, 2022
eaa8727
waiting to allow for filter propagation
Mar 25, 2022
cd8e859
use = instead of match symbol as it is not standard
Mar 25, 2022
0fcdc5b
remove unnecessary code and update error message
Mar 29, 2022
206facd
update test case name and use BasicTypes
Mar 30, 2022
05811f0
use the rcl_subscription_option_t allocator instead
Mar 31, 2022
d421cf2
set the option data directly
Mar 31, 2022
6301133
explicitly check the cft supported by rmw_connextdds and rmw_fastrtps…
Mar 31, 2022
4934583
increase the maximun time for events and content filter propagation
Apr 1, 2022
954982e
set test timeout to 120
Apr 1, 2022
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
224 changes: 224 additions & 0 deletions rcl/include/rcl/subscription.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ typedef struct rcl_subscription_options_s
rmw_subscription_options_t rmw_subscription_options;
} rcl_subscription_options_t;

typedef struct rcl_subscription_content_filter_options_s
{
rmw_subscription_content_filter_options_t rmw_subscription_content_filter_options;
} rcl_subscription_content_filter_options_t;

/// Return a rcl_subscription_t struct with members set to `NULL`.
/**
* Should be called to get a null rcl_subscription_t before passing to
Expand Down Expand Up @@ -209,6 +214,225 @@ RCL_WARN_UNUSED
rcl_subscription_options_t
rcl_subscription_get_default_options(void);

/// Reclaim resources held inside rcl_subscription_options_t structure.
/**
* <hr>
* Attribute | Adherence
* ------------------ | -------------
* Allocates Memory | Yes
* Thread-Safe | No
* Uses Atomics | No
* Lock-Free | No
*
* \param[in] option The structure which its resources have to be deallocated.
* \return `RCL_RET_OK` if the memory was successfully freed, or
* \return `RCL_RET_INVALID_ARGUMENT` if option is NULL, or
* \return `RCL_RET_BAD_ALLOC` if deallocating memory fails.
*/
RCL_PUBLIC
RCL_WARN_UNUSED
rcl_ret_t
rcl_subscription_options_fini(rcl_subscription_options_t * option);
ivanpauno marked this conversation as resolved.
Show resolved Hide resolved

/// Set the content filter options for the given subscription options.
fujitatomoya marked this conversation as resolved.
Show resolved Hide resolved
/**
* <hr>
* Attribute | Adherence
* ------------------ | -------------
* Allocates Memory | Yes
* Thread-Safe | No
* Uses Atomics | No
* Lock-Free | No
*
* \param[in] filter_expression The filter expression is similar to the WHERE part of an SQL clause.
* \param[in] expression_parameters_argc The maximum of expression parameters argc is 100.
* \param[in] expression_parameter_argv The expression parameters argv are the tokens placeholder
* ‘parameters’ (i.e., "%n" tokens begin from 0) in the filter_expression.
*
* It can be NULL if there is no "%n" tokens placeholder in filter_expression.
* \param[out] options The subscription options to be set.
* \return `RCL_RET_OK` if set options successfully, or
* \return `RCL_RET_INVALID_ARGUMENT` if arguments invalid, or
* \return `RCL_RET_BAD_ALLOC` if allocating memory fails.
*/
RCL_PUBLIC
RCL_WARN_UNUSED
rcl_ret_t
rcl_subscription_options_set_content_filter_options(
const char * filter_expression,
size_t expression_parameters_argc,
const char * expression_parameter_argv[],
rcl_subscription_options_t * options);

/// Return the zero initialized subscription content filter options.
RCL_PUBLIC
RCL_WARN_UNUSED
rcl_subscription_content_filter_options_t
rcl_get_zero_initialized_subscription_content_filter_options(void);

/// Initialize the content filter options for the given subscription options.
/**
* <hr>
* Attribute | Adherence
* ------------------ | -------------
* Allocates Memory | Yes
* Thread-Safe | No
* Uses Atomics | No
* Lock-Free | No
*
* \param[in] subscription the handle to the subscription.
* \param[in] filter_expression The filter expression is similar to the WHERE part of an SQL clause,
* use empty ("") can reset (or clear) the content filter setting of a subscription.
* \param[in] expression_parameters_argc The maximum of expression parameters argc is 100.
* \param[in] expression_parameter_argv The expression parameters argv are the tokens placeholder
* ‘parameters’ (i.e., "%n" tokens begin from 0) in the filter_expression.
*
* It can be NULL if there is no "%n" tokens placeholder in filter_expression.
* \param[out] options The subscription options to be set.
* \return `RCL_RET_OK` if set options successfully, or
* \return `RCL_RET_SUBSCRIPTION_INVALID` if subscription is invalid, or
* \return `RCL_RET_INVALID_ARGUMENT` if arguments invalid, or
* \return `RCL_RET_BAD_ALLOC` if allocating memory fails.
*/
RCL_PUBLIC
RCL_WARN_UNUSED
rcl_ret_t
rcl_subscription_content_filter_options_init(
const rcl_subscription_t * subscription,
const char * filter_expression,
size_t expression_parameters_argc,
const char * expression_parameter_argv[],
rcl_subscription_content_filter_options_t * options);

/// Set the content filter options for the given subscription options.
/**
* <hr>
* Attribute | Adherence
* ------------------ | -------------
* Allocates Memory | Yes
* Thread-Safe | No
* Uses Atomics | No
* Lock-Free | No
*
* \param[in] subscription the handle to the subscription.
* \param[in] filter_expression The filter expression is similar to the WHERE part of an SQL clause,
* use empty ("") can reset (or clear) the content filter setting of a subscription.
* \param[in] expression_parameters_argc The maximum of expression parameters argc is 100.
* \param[in] expression_parameter_argv The expression parameters argv are the tokens placeholder
* ‘parameters’ (i.e., "%n" tokens begin from 0) in the filter_expression.
*
* It can be NULL if there is no "%n" tokens placeholder in filter_expression.
* \param[out] options The subscription options to be set.
* \return `RCL_RET_OK` if set options successfully, or
* \return `RCL_RET_SUBSCRIPTION_INVALID` if subscription is invalid, or
* \return `RCL_RET_INVALID_ARGUMENT` if arguments invalid, or
* \return `RCL_RET_BAD_ALLOC` if allocating memory fails.
*/
RCL_PUBLIC
RCL_WARN_UNUSED
rcl_ret_t
rcl_subscription_content_filter_options_set(
const rcl_subscription_t * subscription,
ivanpauno marked this conversation as resolved.
Show resolved Hide resolved
const char * filter_expression,
size_t expression_parameters_argc,
const char * expression_parameter_argv[],
rcl_subscription_content_filter_options_t * options);

/// Reclaim rcl_subscription_content_filter_options_t structure.
/**
* <hr>
* Attribute | Adherence
* ------------------ | -------------
* Allocates Memory | Yes
* Thread-Safe | No
* Uses Atomics | No
* Lock-Free | No
*
* \param[in] subscription the handle to the subscription.
* \param[in] options The structure which its resources have to be deallocated.
* \return `RCL_RET_OK` if the memory was successfully freed, or
* \return `RCL_RET_SUBSCRIPTION_INVALID` if subscription is invalid, or
* \return `RCL_RET_INVALID_ARGUMENT` if option is NULL, or
* if its allocator is invalid and the structure contains initialized memory.
*/
RCL_PUBLIC
RCL_WARN_UNUSED
rcl_ret_t
rcl_subscription_content_filter_options_fini(
const rcl_subscription_t * subscription,
ivanpauno marked this conversation as resolved.
Show resolved Hide resolved
rcl_subscription_content_filter_options_t * options);

/// Check if the content filtered topic feature is enabled in the subscription.
/**
* Depending on the middleware and whether cft is enabled in the subscription.
*
* \return `true` if the content filtered topic of `subscription` is enabled, otherwise `false`
*/
RCL_PUBLIC
RCL_WARN_UNUSED
bool
rcl_subscription_is_cft_enabled(const rcl_subscription_t * subscription);

/// Set the filter expression and expression parameters for the subscription.
/**
* This function will set a filter expression and an array of expression parameters
* for the given subscription.
*
fujitatomoya marked this conversation as resolved.
Show resolved Hide resolved
* <hr>
* Attribute | Adherence
* ------------------ | -------------
* Allocates Memory | No
* Thread-Safe | No
* Uses Atomics | Maybe [1]
* Lock-Free | Maybe [1]
*
* \param[in] subscription The subscription to set content filter options.
* \param[in] options The rcl content filter options.
* \return `RCL_RET_OK` if the query was successful, or
* \return `RCL_RET_INVALID_ARGUMENT` if `subscription` is NULL, or
* \return `RCL_RET_INVALID_ARGUMENT` if `options` is NULL, or
* \return `RCL_RET_UNSUPPORTED` if the implementation does not support content filter topic, or
* \return `RCL_RET_ERROR` if an unspecified error occurs.
*/
RCL_PUBLIC
RCL_WARN_UNUSED
rcl_ret_t
rcl_subscription_set_content_filter(
const rcl_subscription_t * subscription,
const rcl_subscription_content_filter_options_t * options
);

/// Retrieve the filter expression of the subscription.
/**
* This function will return an filter expression by the given subscription.
*
* <hr>
* Attribute | Adherence
* ------------------ | -------------
* Allocates Memory | Yes
* Thread-Safe | No
* Uses Atomics | Maybe [1]
* Lock-Free | Maybe [1]
*
* \param[in] subscription The subscription object to inspect.
* \param[out] options The rcl content filter options.
* It is up to the caller to finalize this options later on, using
* rcl_subscription_content_filter_options_fini().
* \return `RCL_RET_OK` if the query was successful, or
* \return `RCL_RET_INVALID_ARGUMENT` if `subscription` is NULL, or
* \return `RCL_RET_INVALID_ARGUMENT` if `options` is NULL, or
* \return `RCL_RET_BAD_ALLOC` if memory allocation fails, or
* \return `RCL_RET_UNSUPPORTED` if the implementation does not support content filter topic, or
* \return `RCL_RET_ERROR` if an unspecified error occurs.
*/
RCL_PUBLIC
RCL_WARN_UNUSED
rcl_ret_t
rcl_subscription_get_content_filter(
const rcl_subscription_t * subscription,
rcl_subscription_content_filter_options_t * options
);

/// Take a ROS message from a topic using a rcl subscription.
/**
* It is the job of the caller to ensure that the type of the ros_message
Expand Down
Loading