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 
21 #include "rcl/types.h"
22 
23 namespace rclcpp
24 {
25 
26 class QoS;
27 
28 namespace subscription_traits
29 {
30 
31 /*
32  * The current version of uncrustify has a misinterpretion here
33  * between `:` used for inheritance vs for initializer list
34  * The result is that whenever a templated struct is used,
35  * the colon has to be without any whitespace next to it whereas
36  * when no template is used, the colon has to be separated by a space.
37  * Cheers!
38  */
39 template<typename T>
41 {};
42 
43 template<>
45 {};
46 
47 template<>
48 struct is_serialized_subscription_argument<std::shared_ptr<rcl_serialized_message_t>>
50 {};
51 
52 template<typename T>
54 {};
55 
56 template<typename CallbackT>
59  typename rclcpp::function_traits::function_traits<CallbackT>::template argument_type<0>>
60 {};
61 
62 template<typename MessageT>
64 {
66 };
67 
68 template<typename MessageT>
69 struct extract_message_type<std::shared_ptr<MessageT>>: extract_message_type<MessageT>
70 {};
71 
72 template<typename MessageT, typename Deleter>
73 struct extract_message_type<std::unique_ptr<MessageT, Deleter>>: extract_message_type<MessageT>
74 {};
75 
76 template<
77  typename CallbackT,
78  // Do not attempt if CallbackT is an integer (mistaken for depth)
79  typename = std::enable_if_t<!std::is_integral<
80  std::remove_cv_t<std::remove_reference_t<CallbackT>>>::value>,
81  // Do not attempt if CallbackT is a QoS (mistaken for qos)
82  typename = std::enable_if_t<!std::is_base_of<
84  std::remove_cv_t<std::remove_reference_t<CallbackT>>>::value>,
85  // Do not attempt if CallbackT is a rmw_qos_profile_t (mistaken for qos profile)
86  typename = std::enable_if_t<!std::is_same<
88  std::remove_cv_t<std::remove_reference_t<CallbackT>>>::value>
89 >
91  typename rclcpp::function_traits::function_traits<CallbackT>::template argument_type<0>>
92 {};
93 
94 } // namespace subscription_traits
95 } // namespace rclcpp
96 
97 #endif // RCLCPP__SUBSCRIPTION_TRAITS_HPP_
Encapsulation of Quality of Service settings.
Definition: qos.hpp:55
Definition: subscription_traits.hpp:53
This header provides the get_node_topics_interface() template function.
Definition: allocator_common.hpp:24
Definition: subscription_traits.hpp:90
typename std::remove_cv< rclcpp::function_traits::function_traits< CallbackT >::template argument_type< 0 > >::type type
Definition: subscription_traits.hpp:65
Definition: subscription_traits.hpp:63
Definition: subscription_traits.hpp:57