message_translate.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * fkie_message_filters
4  * Copyright © 2018-2020 Fraunhofer FKIE
5  * Author: Timo Röhling
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  ****************************************************************************/
20 #ifndef INCLUDE_FKIE_MESSAGE_FILTERS_MESSAGE_TRANSLATE_H_
21 #define INCLUDE_FKIE_MESSAGE_FILTERS_MESSAGE_TRANSLATE_H_
22 
23 #include <ros/message_event.h>
25 
26 namespace fkie_message_filters
27 {
28 
29 template<class M>
30 struct RosMessage
31 {
32  using MessageType = M;
33  using PublishType = M;
35  using FilterType = M;
37  {
38  return *t.getConstMessage().get();
39  }
41  {
42  return t;
43  }
44  static const MessageType& filterToMessage(const FilterType& t)
45  {
46  return t;
47  }
48 };
49 
50 template<class M>
52 {
53  using MessageType = M;
54  using PublishType = typename M::ConstPtr;
56  using FilterType = typename M::ConstPtr;
57  static FilterType eventToFilter(const EventType& t) noexcept
58  {
59  return t.getConstMessage();
60  }
61  static PublishType filterToPublish(const FilterType& t) noexcept
62  {
63  return t;
64  }
65  static const MessageType& filterToMessage(const FilterType& t) noexcept
66  {
67  return *t;
68  }
69 };
70 
71 template<class M>
73 {
74  using MessageType = M;
75  using PublishType = typename M::ConstPtr;
77  using FilterType = std::shared_ptr<const M>;
78  static FilterType eventToFilter(const EventType& t) noexcept
79  {
80  return helpers::convert_shared_ptr<FilterType>(t.getConstMessage());
81  }
82  static PublishType filterToPublish(const FilterType& t) noexcept
83  {
84  return helpers::convert_shared_ptr<PublishType>(t);
85  }
86  static const MessageType& filterToMessage(const FilterType& t) noexcept
87  {
88  return *t;
89  }
90 };
91 
92 template<class M>
94 {
95  using MessageType = M;
96  using PublishType = typename M::ConstPtr;
99  static FilterType eventToFilter(const EventType& t) noexcept
100  {
101  return t;
102  }
103  static PublishType filterToPublish(const FilterType& t) noexcept
104  {
105  return t.getConstMessage();
106  }
107  static const MessageType& filterToMessage(const FilterType& t) noexcept
108  {
109  return *t.getConstMessage();
110  }
111 };
112 
113 } // namespace fkie_message_filters
114 
115 #endif /* INCLUDE_FKIE_MESSAGE_FILTERS_MESSAGE_TRANSLATE_H_ */
const boost::shared_ptr< ConstMessage > & getConstMessage() const
static const MessageType & filterToMessage(const FilterType &t) noexcept
static PublishType filterToPublish(const FilterType &t) noexcept
static const MessageType & filterToMessage(const FilterType &t) noexcept
static FilterType eventToFilter(const EventType &t) noexcept
static PublishType filterToPublish(const FilterType &t) noexcept
Primary namespace.
Definition: buffer.h:33
static PublishType filterToPublish(const FilterType &t)
static const MessageType & filterToMessage(const FilterType &t)
static FilterType eventToFilter(const EventType &t)
static FilterType eventToFilter(const EventType &t) noexcept
static FilterType eventToFilter(const EventType &t) noexcept
static const MessageType & filterToMessage(const FilterType &t) noexcept
static PublishType filterToPublish(const FilterType &t) noexcept


fkie_message_filters
Author(s): Timo Röhling
autogenerated on Mon Feb 28 2022 22:21:43