Skip to content

Commit

Permalink
Update the argument type of interface declaration
Browse files Browse the repository at this point in the history
Signed-off-by: Chen Lihui <lihui.chen@sony.com>
  • Loading branch information
Chen Lihui committed Oct 12, 2021
1 parent d35f876 commit c353990
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 43 deletions.
1 change: 1 addition & 0 deletions rmw/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ include(cmake/configure_rmw_library.cmake)

set(rmw_sources
"src/allocators.c"
"src/content_filtered_topic_options.c"
"src/convert_rcutils_ret_to_rmw_ret.c"
"src/event.c"
"src/init.c"
Expand Down
60 changes: 23 additions & 37 deletions rmw/include/rmw/rmw.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ extern "C"
#include <stddef.h>
#include <stdint.h>

#include "rcutils/allocator.h"
#include "rcutils/macros.h"
#include "rcutils/types.h"

Expand Down Expand Up @@ -1115,11 +1116,10 @@ rmw_subscription_get_actual_qos(
const rmw_subscription_t * subscription,
rmw_qos_profile_t * qos);

/// Set the filter expression and expression parameters for the subscription.
/// Set the content filtered topic options for the subscription.
/**
* This function will set a filter expression and an array of expression parameters
* for the given subscription, but not to update the original rmw_subscription_options_t
* of subscription.
* for the given subscription.
*
* <hr>
* Attribute | Adherence
Expand All @@ -1130,36 +1130,27 @@ rmw_subscription_get_actual_qos(
* Lock-Free | Maybe [1]
* <i>[1] implementation defined, check the implementation documentation</i>
*
* \param[in] subscription the subscription object to inspect.
* \param[in] filter_expression A filter_expression is a string that specifies the criteria
* to select the data samples of interest. It is similar to the WHERE part of an SQL clause.
* Using an empty("") string can reset/clean content filtered topic for the subscription.
* \param[in] expression_parameters An expression_parameters is an array of strings that
* give values to the ‘parameters’ (i.e., "%n" tokens begin from 0) in the filter_expression.
* The number of supplied parameters must fit with the requested values in the filter_expression.
* It can be NULL if there is no "%n" tokens placeholder in filter_expression.
* The maximun size allowance depends on concrete DDS vendor.
* (i.e., it cannot be greater than 100 on RTI_Connext.)
* \return `RMW_RET_OK` if the query was successful, or
* \return `RMW_RET_INVALID_ARGUMENT` if `subscription` is NULL, or
* \return `RMW_RET_INVALID_ARGUMENT` if `filter_expression` is NULL, or
* \return `RMW_RET_INVALID_ARGUMENT` if `expression_parameters` is NULL, or
* \return `RMW_RET_INCORRECT_RMW_IMPLEMENTATION` if the `node` implementation
* \param[in] subscription The subscription to set content filtered topic options.
* \param[in] content_filtered_topic_options The content filtered topic options.
* Use `content_filtered_topic_options.filter_expression` with an empty("") string to
* reset/clean content filtered topic for the subscription.
* \return `RMW_RET_OK` if successful, or
* \return `RMW_RET_INVALID_ARGUMENT` if an argument is null, or
* \return `RMW_RET_INCORRECT_RMW_IMPLEMENTATION` if the `subscription` implementation
* identifier does not match this implementation, or
* \return `RMW_RET_UNSUPPORTED` if the implementation does not support content filter topic, or
* \return `RMW_RET_UNSUPPORTED` if the implementation does not support content filtered topic, or
* \return `RMW_RET_ERROR` if an unspecified error occurs.
*/
RMW_PUBLIC
RMW_WARN_UNUSED
rmw_ret_t
rmw_subscription_set_cft_expression_parameters(
rmw_subscription_t * subscription,
const char * filter_expression,
const rcutils_string_array_t * expression_parameters);
const rmw_content_filtered_topic_options_t * content_filtered_topic_options);

/// Retrieve the filter expression of the subscription.
/// Retrieve the content filtered topic options of the subscription.
/**
* This function will return an filter expression by the given subscription.
* This function will return a content filtered topic options by the given subscription.
*
* <hr>
* Attribute | Adherence
Expand All @@ -1170,29 +1161,24 @@ rmw_subscription_set_cft_expression_parameters(
* Lock-Free | Maybe [1]
* <i>[1] implementation defined, check the implementation documentation</i>
*
* \param[in] subscription the subscription object to inspect.
* \param[out] filter_expression an filter expression, populated on success.
* It is up to the caller to deallocate the filter expression later on,
* using rcutils_get_default_allocator().deallocate().
* \param[out] expression_parameters Array of expression parameters, populated on success.
* It is up to the caller to finalize this array later on, using rcutils_string_array_fini().
* \return `RMW_RET_OK` if the query was successful, or
* \return `RMW_RET_INVALID_ARGUMENT` if `subscription` is NULL, or
* \return `RMW_RET_INVALID_ARGUMENT` if `filter_expression` is NULL or
* \return `RMW_RET_INVALID_ARGUMENT` if `expression_parameters` is NULL, or
* \return `RMW_RET_INCORRECT_RMW_IMPLEMENTATION` if the `node` implementation
* \param[in] subscription The subscription object to inspect.
* \param[in] allocator Allocator to be used when populating the content filtered topic options.
* \param[out] content_filtered_topic_options The content filtered topic options.
* \return `RMW_RET_OK` if successful, or
* \return `RMW_RET_INVALID_ARGUMENT` if an argument is null, or
* \return `RMW_RET_INCORRECT_RMW_IMPLEMENTATION` if the `subscription` implementation
* identifier does not match this implementation, or
* \return `RMW_RET_BAD_ALLOC` if memory allocation fails, or
* \return `RMW_RET_UNSUPPORTED` if the implementation does not support content filter topic, or
* \return `RMW_RET_UNSUPPORTED` if the implementation does not support content filtered topic, or
* \return `RMW_RET_ERROR` if an unspecified error occurs.
*/
RMW_PUBLIC
RMW_WARN_UNUSED
rmw_ret_t
rmw_subscription_get_cft_expression_parameters(
const rmw_subscription_t * subscription,
char ** filter_expression,
rcutils_string_array_t * expression_parameters);
rcutils_allocator_t * allocator,
rmw_content_filtered_topic_options_t * content_filtered_topic_options);

/// Take an incoming ROS message.
/**
Expand Down
4 changes: 2 additions & 2 deletions rmw/include/rmw/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ extern "C"
// map rcutils specific log levels to rmw speicfic type
#include <rcutils/logging.h>

#include "rmw/content_filtered_topic_options.h"
#include "rmw/events_statuses/events_statuses.h"
#include "rmw/init.h"
#include "rmw/init_options.h"
Expand Down Expand Up @@ -179,8 +180,7 @@ typedef struct RMW_PUBLIC_TYPE rmw_subscription_options_s
rmw_unique_network_flow_endpoints_requirement_t require_unique_network_flow_endpoints;

/// Used to create a content filtered topic during subscription creation.
char * filter_expression;
rcutils_string_array_t * expression_parameters;
rmw_content_filtered_topic_options_t * content_filtered_topic_options;
} rmw_subscription_options_t;

typedef struct RMW_PUBLIC_TYPE rmw_subscription_s
Expand Down
3 changes: 1 addition & 2 deletions rmw/src/subscription_options.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ rmw_get_default_subscription_options(void)
.rmw_specific_subscription_payload = NULL,
.ignore_local_publications = false,
.require_unique_network_flow_endpoints = RMW_UNIQUE_NETWORK_FLOW_ENDPOINTS_NOT_REQUIRED,
.filter_expression = NULL,
.expression_parameters = NULL,
.content_filtered_topic_options = NULL,
};
return subscription_options;
}
Expand Down
9 changes: 9 additions & 0 deletions rmw/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,12 @@ if(TARGET test_network_flow_endpoint_array)
target_link_libraries(test_network_flow_endpoint_array ${PROJECT_NAME}
osrf_testing_tools_cpp::memory_tools)
endif()

ament_add_gmock(test_content_filtered_topic_options
test_content_filtered_topic_options.cpp
# Append the directory of librmw so it is found at test time.
APPEND_LIBRARY_DIRS "$<TARGET_FILE_DIR:${PROJECT_NAME}>"
)
if(TARGET test_content_filtered_topic_options)
target_link_libraries(test_content_filtered_topic_options ${PROJECT_NAME})
endif()
3 changes: 1 addition & 2 deletions rmw/test/test_subscription_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,5 @@ TEST(rmw_subscription_options, get_default_subscription_options)
EXPECT_EQ(
options.require_unique_network_flow_endpoints,
RMW_UNIQUE_NETWORK_FLOW_ENDPOINTS_NOT_REQUIRED);
EXPECT_EQ(options.filter_expression, nullptr);
EXPECT_EQ(options.expression_parameters, nullptr);
EXPECT_EQ(options.content_filtered_topic_options, nullptr);
}

0 comments on commit c353990

Please sign in to comment.