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;
36  static FilterType eventToFilter(const EventType& t)
37  {
38  return *t.getConstMessage().get();
39  }
40  static PublishType filterToPublish(const FilterType& t)
41  {
42  return t;
43  }
44  static const MessageType& filterToMessage(const FilterType& t)
45  {
46  return t;
47  }
48 };
49 
50 template<class M>
51 struct RosMessageConstPtr
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_ */
fkie_message_filters::RosMessageEvent::filterToPublish
static PublishType filterToPublish(const FilterType &t) noexcept
Definition: message_translate.h:121
fkie_message_filters
Definition: buffer.h:33
fkie_message_filters::RosMessageStdSharedPtr::FilterType
std::shared_ptr< const M > FilterType
Definition: message_translate.h:95
shared_ptr_compat.h
fkie_message_filters::RosMessageConstPtr::eventToFilter
static FilterType eventToFilter(const EventType &t) noexcept
Definition: message_translate.h:75
fkie_message_filters::RosMessageStdSharedPtr::filterToMessage
static const MessageType & filterToMessage(const FilterType &t) noexcept
Definition: message_translate.h:104
fkie_message_filters::RosMessageConstPtr::EventType
ros::MessageEvent< const M > EventType
Definition: message_translate.h:73
fkie_message_filters::RosMessageEvent::MessageType
M MessageType
Definition: message_translate.h:113
fkie_message_filters::RosMessageStdSharedPtr::MessageType
M MessageType
Definition: message_translate.h:92
fkie_message_filters::RosMessageEvent::FilterType
ros::MessageEvent< const M > FilterType
Definition: message_translate.h:116
fkie_message_filters::RosMessageConstPtr::MessageType
M MessageType
Definition: message_translate.h:71
fkie_message_filters::RosMessage::filterToPublish
static PublishType filterToPublish(const FilterType &t)
Definition: message_translate.h:76
fkie_message_filters::RosMessageConstPtr::filterToMessage
static const MessageType & filterToMessage(const FilterType &t) noexcept
Definition: message_translate.h:83
fkie_message_filters::RosMessageEvent::PublishType
typename M::ConstPtr PublishType
Definition: message_translate.h:114
fkie_message_filters::RosMessage::filterToMessage
static const MessageType & filterToMessage(const FilterType &t)
Definition: message_translate.h:80
fkie_message_filters::RosMessageStdSharedPtr::filterToPublish
static PublishType filterToPublish(const FilterType &t) noexcept
Definition: message_translate.h:100
fkie_message_filters::RosMessage::MessageType
M MessageType
Definition: message_translate.h:68
fkie_message_filters::RosMessageConstPtr::PublishType
typename M::ConstPtr PublishType
Definition: message_translate.h:72
fkie_message_filters::RosMessageStdSharedPtr
Definition: message_translate.h:90
fkie_message_filters::RosMessageEvent
Definition: message_translate.h:111
fkie_message_filters::RosMessageEvent::eventToFilter
static FilterType eventToFilter(const EventType &t) noexcept
Definition: message_translate.h:117
fkie_message_filters::RosMessageStdSharedPtr::PublishType
typename M::ConstPtr PublishType
Definition: message_translate.h:93
fkie_message_filters::RosMessage::eventToFilter
static FilterType eventToFilter(const EventType &t)
Definition: message_translate.h:72
fkie_message_filters::RosMessageConstPtr
Definition: message_translate.h:69
fkie_message_filters::RosMessageConstPtr::FilterType
typename M::ConstPtr FilterType
Definition: message_translate.h:74
fkie_message_filters::RosMessageEvent::filterToMessage
static const MessageType & filterToMessage(const FilterType &t) noexcept
Definition: message_translate.h:125
fkie_message_filters::RosMessage::FilterType
M FilterType
Definition: message_translate.h:71
fkie_message_filters::RosMessageStdSharedPtr::eventToFilter
static FilterType eventToFilter(const EventType &t) noexcept
Definition: message_translate.h:96
fkie_message_filters::RosMessage::EventType
ros::MessageEvent< const M > EventType
Definition: message_translate.h:70
fkie_message_filters::RosMessageConstPtr::filterToPublish
static PublishType filterToPublish(const FilterType &t) noexcept
Definition: message_translate.h:79
message_event.h
ros::MessageEvent
fkie_message_filters::RosMessage::PublishType
M PublishType
Definition: message_translate.h:69


fkie_message_filters
Author(s): Timo Röhling
autogenerated on Wed Mar 2 2022 00:18:57