rclcpp  master
C++ ROS Client Library API
subscription_traits.hpp
Go to the documentation of this file.
1 // Copyright 2017 Open Source Robotics Foundation, Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef RCLCPP__SUBSCRIPTION_TRAITS_HPP_
16 #define RCLCPP__SUBSCRIPTION_TRAITS_HPP_
17 
18 #include <memory>
19 
23 #include "rcl/types.h"
24 
25 namespace rclcpp
26 {
27 
28 class QoS;
29 
30 namespace subscription_traits
31 {
32 
33 /*
34  * The current version of uncrustify has a misinterpretion here
35  * between `:` used for inheritance vs for initializer list
36  * The result is that whenever a templated struct is used,
37  * the colon has to be without any whitespace next to it whereas
38  * when no template is used, the colon has to be separated by a space.
39  * Cheers!
40  */
41 template<typename T>
43 {};
44 
45 template<>
47 {};
48 
49 template<>
50 struct is_serialized_subscription_argument<std::shared_ptr<SerializedMessage>>
52 {};
53 
54 template<typename T>
56 {};
57 
58 template<typename CallbackT>
61  typename rclcpp::function_traits::function_traits<CallbackT>::template argument_type<0>>
62 {};
63 
64 template<typename MessageT>
66 {
67  using type = typename std::remove_cv_t<std::remove_reference_t<MessageT>>;
68 };
69 
70 template<typename MessageT>
71 struct extract_message_type<std::shared_ptr<MessageT>>: extract_message_type<MessageT>
72 {};
73 
74 template<typename MessageT, typename Deleter>
75 struct extract_message_type<std::unique_ptr<MessageT, Deleter>>: extract_message_type<MessageT>
76 {};
77 
78 template<
79  typename CallbackT,
80  typename AllocatorT = std::allocator<void>,
81  // Do not attempt if CallbackT is an integer (mistaken for depth)
82  typename = std::enable_if_t<!std::is_integral<
83  std::remove_cv_t<std::remove_reference_t<CallbackT>>>::value>,
84  // Do not attempt if CallbackT is a QoS (mistaken for qos)
85  typename = std::enable_if_t<!std::is_base_of<
87  std::remove_cv_t<std::remove_reference_t<CallbackT>>>::value>,
88  // Do not attempt if CallbackT is a rmw_qos_profile_t (mistaken for qos profile)
89  typename = std::enable_if_t<!std::is_same<
91  std::remove_cv_t<std::remove_reference_t<CallbackT>>>::value>,
92  // Do not attempt if CallbackT is a rclcpp::SubscriptionOptionsWithAllocator
93  typename = std::enable_if_t<!std::is_same<
95  std::remove_cv_t<std::remove_reference_t<CallbackT>>>::value>
96 >
98  typename rclcpp::function_traits::function_traits<CallbackT>::template argument_type<0>>
99 {};
100 
101 } // namespace subscription_traits
102 } // namespace rclcpp
103 
104 #endif // RCLCPP__SUBSCRIPTION_TRAITS_HPP_
std::is_same
std::false_type
rclcpp::subscription_traits::is_serialized_subscription
Definition: subscription_traits.hpp:55
rclcpp::SubscriptionOptionsWithAllocator
Structure containing optional configuration for Subscriptions.
Definition: subscription_options.hpp:87
serialized_message.hpp
rclcpp
This header provides the get_node_base_interface() template function.
Definition: allocator_common.hpp:24
rclcpp::subscription_traits::extract_message_type< rclcpp::function_traits::function_traits< CallbackT >::template argument_type< 0 > >::type
typename std::remove_cv_t< std::remove_reference_t< rclcpp::function_traits::function_traits< CallbackT >::template argument_type< 0 > > > type
Definition: subscription_traits.hpp:67
rclcpp::subscription_traits::is_serialized_callback
Definition: subscription_traits.hpp:59
rclcpp::QoS
Encapsulation of Quality of Service settings.
Definition: qos.hpp:110
rclcpp::subscription_traits::has_message_type
Definition: subscription_traits.hpp:97
std::is_integral
function_traits.hpp
rclcpp::subscription_traits::is_serialized_subscription_argument
Definition: subscription_traits.hpp:42
rclcpp::subscription_traits::extract_message_type
Definition: subscription_traits.hpp:65
subscription_options.hpp
std
rclcpp::SerializedMessage
Object oriented version of rcl_serialized_message_t with destructor to avoid memory leaks.
Definition: serialized_message.hpp:27
rmw_qos_profile_t
std::allocator
types.h
std::is_base_of