15 #ifndef RCLCPP__SUBSCRIPTION_OPTIONS_HPP_
16 #define RCLCPP__SUBSCRIPTION_OPTIONS_HPP_
21 #include <type_traits>
24 #include "rclcpp/callback_group.hpp"
25 #include "rclcpp/detail/rmw_implementation_specific_subscription_payload.hpp"
26 #include "rclcpp/intra_process_buffer_type.hpp"
27 #include "rclcpp/intra_process_setting.hpp"
28 #include "rclcpp/qos.hpp"
29 #include "rclcpp/event_handler.hpp"
30 #include "rclcpp/qos_overriding_options.hpp"
31 #include "rclcpp/subscription_content_filter_options.hpp"
32 #include "rclcpp/topic_statistics_state.hpp"
33 #include "rclcpp/visibility_control.hpp"
53 RMW_UNIQUE_NETWORK_FLOW_ENDPOINTS_NOT_REQUIRED;
65 std::shared_ptr<rclcpp::detail::RMWImplementationSpecificSubscriptionPayload>
75 std::string publish_topic =
"/statistics";
79 std::chrono::milliseconds publish_period{std::chrono::seconds(1)};
95 template<
typename Allocator>
99 std::is_void_v<
typename std::allocator_traits<Allocator>::value_type>,
100 "Subscription allocator value type must be void");
122 result.
allocator = this->get_rcl_allocator();
135 std::vector<const char *> cstrings =
143 rclcpp::exceptions::throw_from_rcl_error(
144 ret,
"failed to set content_filter_options");
151 std::shared_ptr<Allocator>
152 get_allocator()
const
154 if (!this->allocator) {
155 if (!allocator_storage_) {
156 allocator_storage_ = std::make_shared<Allocator>();
158 return allocator_storage_;
164 using PlainAllocator =
165 typename std::allocator_traits<Allocator>::template rebind_alloc<char>;
168 get_rcl_allocator()
const
170 if (!plain_allocator_storage_) {
171 plain_allocator_storage_ =
172 std::make_shared<PlainAllocator>(*this->get_allocator());
174 return rclcpp::allocator::get_rcl_allocator<char>(*plain_allocator_storage_);
179 mutable std::shared_ptr<Allocator> allocator_storage_;
183 mutable std::shared_ptr<PlainAllocator> plain_allocator_storage_;
186 using SubscriptionOptions = SubscriptionOptionsWithAllocator<std::allocator<void>>;
rcutils_allocator_t rcl_allocator_t
Encapsulation of an allocator.
Encapsulation of Quality of Service settings.
rmw_qos_profile_t & get_rmw_qos_profile()
Return the rmw qos profile.
QoS & keep_last(size_t depth)
Set the history to keep last.
Options that are passed in subscription/publisher constructor to specify QoSConfigurability.
Versions of rosidl_typesupport_cpp::get_message_type_support_handle that handle adapted types.
@ NodeDefault
Take topic statistics state from the node.
IntraProcessSetting
Used as argument in create_publisher and create_subscriber.
@ NodeDefault
Take intraprocess configuration from the node.
@ CallbackDefault
Set the data type used in the intra-process buffer as the same used in the callback.
RCLCPP_PUBLIC std::vector< const char * > get_c_vector_string(const std::vector< std::string > &strings_in)
Return the std::vector of C string from the given std::vector<std::string>.
RCLCPP_PUBLIC const char * get_c_string(const char *string_in)
Return the given string.
Options available for a rcl subscription.
rcl_allocator_t allocator
Custom allocator for the subscription, used for incidental allocations.
rmw_qos_profile_t qos
Middleware quality of service settings for the subscription.
rmw_subscription_options_t rmw_subscription_options
rmw specific subscription options, e.g. the rmw implementation specific payload.
Options to configure content filtered topic in the subscription.
std::string filter_expression
Filter expression is similar to the WHERE part of an SQL clause.
std::vector< std::string > expression_parameters
Contains callbacks for non-message events that a Subscription can receive from the middleware.
Non-template base class for subscription options.
IntraProcessSetting use_intra_process_comm
Setting to explicitly set intraprocess communications.
std::shared_ptr< rclcpp::detail::RMWImplementationSpecificSubscriptionPayload > rmw_implementation_payload
Optional RMW implementation specific payload to be used during creation of the subscription.
SubscriptionEventCallbacks event_callbacks
Callbacks for events related to this subscription.
rmw_unique_network_flow_endpoints_requirement_t require_unique_network_flow_endpoints
bool use_default_callbacks
Whether or not to use default callbacks when user doesn't supply any in event_callbacks.
bool ignore_local_publications
True to ignore local publications.
rclcpp::CallbackGroup::SharedPtr callback_group
The callback group for this subscription. NULL to use the default callback group.
IntraProcessBufferType intra_process_buffer_type
Setting the data-type stored in the intraprocess buffer.
Structure containing optional configuration for Subscriptions.
SubscriptionOptionsWithAllocator(const SubscriptionOptionsBase &subscription_options_base)
Constructor using base class as input.
rcl_subscription_options_t to_rcl_subscription_options(const rclcpp::QoS &qos) const
Convert this class, with a rclcpp::QoS, into an rcl_subscription_options_t.
std::shared_ptr< Allocator > allocator
Optional custom allocator.
RCL_PUBLIC RCL_WARN_UNUSED rcl_subscription_options_t rcl_subscription_get_default_options(void)
Return the default subscription options in a rcl_subscription_options_t.
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)
Set the content filter options for the given subscription options.
#define RCL_RET_OK
Success return code.
rmw_ret_t rcl_ret_t
The type that holds an rcl return code.