update_filter.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 Pilz GmbH & Co. KG
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8 
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Lesser General Public License for more details.
13 
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef UPDATE_FILTER_H
19 #define UPDATE_FILTER_H
20 
22 
23 #include <vector>
24 
25 namespace message_filters
26 {
39 template <typename M>
40 class UpdateFilter : public SimpleFilter<M>
41 {
42 public:
45 
49  template <typename F>
51  {
52  connectInput(f);
53  }
54 
58  template <class F>
59  void connectInput(F& f)
60  {
63  f.registerCallback(typename UpdateFilter<M>::EventCallback(boost::bind(&UpdateFilter::cb, this, _1)));
64  }
65 
66 private:
67  void cb(const EventType& evt)
68  {
69  if (evt.getMessage()->header.stamp == last_message_time_)
70  {
71  return;
72  }
73 
74  last_message_time_ = evt.getMessage()->header.stamp;
75 
76  this->signalMessage(evt);
77  }
78 
80 
82 };
83 
84 } // namespace message_filters
85 
86 #endif // UPDATE_FILTER_H
ros::MessageEvent< M const > EventType
Definition: update_filter.h:44
void signalMessage(const MConstPtr &msg)
void cb(const EventType &evt)
Definition: update_filter.h:67
boost::shared_ptr< M > getMessage() const
Filters consecutive messages with the same timestamp. Only the first message passes, all consecutive are dropped. It is templated on the message type to be filtered.
Definition: update_filter.h:40
void connectInput(F &f)
Connect to the output of another filter.
Definition: update_filter.h:59
boost::function< void(const EventType &)> EventCallback
boost::shared_ptr< M const > MConstPtr
Definition: update_filter.h:43
UpdateFilter(F &f)
Construct the filter and connect to the output of another filter.
Definition: update_filter.h:50


prbt_hardware_support
Author(s):
autogenerated on Thu Jul 22 2021 02:10:34