rclcpp  master
C++ ROS Client Library API
resolve_intra_process_buffer_type.hpp
Go to the documentation of this file.
1 // Copyright 2019 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__DETAIL__RESOLVE_INTRA_PROCESS_BUFFER_TYPE_HPP_
16 #define RCLCPP__DETAIL__RESOLVE_INTRA_PROCESS_BUFFER_TYPE_HPP_
17 
18 #include <stdexcept>
19 
22 
23 namespace rclcpp
24 {
25 
26 namespace detail
27 {
28 
30 template<typename CallbackMessageT, typename AllocatorT>
33  const rclcpp::IntraProcessBufferType buffer_type,
34  const rclcpp::AnySubscriptionCallback<CallbackMessageT, AllocatorT> & any_subscription_callback)
35 {
36  rclcpp::IntraProcessBufferType resolved_buffer_type = buffer_type;
37 
38  // If the user has not specified a type for the intra-process buffer, use the callback's type.
39  if (resolved_buffer_type == IntraProcessBufferType::CallbackDefault) {
40  if (any_subscription_callback.use_take_shared_method()) {
41  resolved_buffer_type = IntraProcessBufferType::SharedPtr;
42  } else {
43  resolved_buffer_type = IntraProcessBufferType::UniquePtr;
44  }
45  }
46 
47  return resolved_buffer_type;
48 }
49 
50 } // namespace detail
51 
52 } // namespace rclcpp
53 
54 #endif // RCLCPP__DETAIL__RESOLVE_INTRA_PROCESS_BUFFER_TYPE_HPP_
bool use_take_shared_method() const
Definition: any_subscription_callback.hpp:230
This header provides the get_node_base_interface() template function.
Definition: allocator_common.hpp:24
Set the data type used in the intra-process buffer as the same used in the callback.
rclcpp::IntraProcessBufferType resolve_intra_process_buffer_type(const rclcpp::IntraProcessBufferType buffer_type, const rclcpp::AnySubscriptionCallback< CallbackMessageT, AllocatorT > &any_subscription_callback)
Return the buffer type, resolving the "CallbackDefault" type to an actual type if needed...
Definition: resolve_intra_process_buffer_type.hpp:32
Set the data type used in the intra-process buffer as std::shared_ptr<MessageT>
IntraProcessBufferType
Definition: intra_process_buffer_type.hpp:23
Set the data type used in the intra-process buffer as std::unique_ptr<MessageT>