sequencer.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 
21 #ifndef INCLUDE_FKIE_MESSAGE_FILTERS_SEQUENCER_H_
22 #define INCLUDE_FKIE_MESSAGE_FILTERS_SEQUENCER_H_
23 
24 #include "filter.h"
25 #include <ros/time.h>
26 #include <ros/duration.h>
27 #include <map>
28 
29 namespace fkie_message_filters
30 {
31 
42 template<class... Inputs>
43 class Sequencer : public Filter<IO<Inputs...>, IO<Inputs...>>
44 {
45 public:
52  explicit Sequencer (const ros::Duration& max_delay = ros::Duration(1, 0)) noexcept;
62  void set_max_delay (const ros::Duration& max_delay) noexcept;
71  void flush();
72  void reset() noexcept override;
73 protected:
74  void receive (const Inputs&... in) override;
75 private:
76  using QueueElement = std::tuple<Inputs...>;
77  using Queue = std::multimap<ros::Time, QueueElement>;
78  std::mutex mutex_;
79  ros::Duration max_delay_;
80  ros::Time cutoff_;
81  Queue queue_;
82 };
83 
84 template<class... Inputs>
85 class Sequencer<IO<Inputs...>> : public Sequencer<Inputs...>
86 {
87 public:
88  explicit Sequencer(const ros::Duration& max_delay = ros::Duration(1, 0)) noexcept
89  : Sequencer<Inputs...>(max_delay) {}
90 };
91 
92 } // namespace fkie_message_filters
93 
94 #include "sequencer_impl.h"
95 
96 #endif /* INCLUDE_FKIE_MESSAGE_FILTERS_SEQUENCER_H_ */
fkie_message_filters
Definition: buffer.h:33
fkie_message_filters::Sequencer::set_max_delay
void set_max_delay(const ros::Duration &max_delay) noexcept
Modify maximum delay.
Definition: sequencer_impl.h:58
fkie_message_filters::Sequencer::Sequencer
Sequencer(const ros::Duration &max_delay=ros::Duration(1, 0)) noexcept
Constructor.
Definition: sequencer_impl.h:52
Filter
filter.h
fkie_message_filters::Sequencer::flush
void flush()
Flush the message queue.
Definition: sequencer_impl.h:89
ros
time.h
fkie_message_filters::Sequencer::queue_
Queue queue_
Definition: sequencer.h:117
fkie_message_filters::Sequencer::Queue
std::multimap< ros::Time, QueueElement > Queue
Definition: sequencer.h:113
fkie_message_filters::Sequencer::cutoff_
ros::Time cutoff_
Definition: sequencer.h:116
sequencer_impl.h
duration.h
fkie_message_filters::Sequencer::max_delay_
ros::Duration max_delay_
Definition: sequencer.h:115
fkie_message_filters::Sequencer::reset
void reset() noexcept override
Reset filter state.
Definition: sequencer_impl.h:108
fkie_message_filters::Sequencer::receive
void receive(const Inputs &... in) override
Process incoming data.
Definition: sequencer_impl.h:65
fkie_message_filters::Sequencer::mutex_
std::mutex mutex_
Definition: sequencer.h:114
std
fkie_message_filters::Sequencer::QueueElement
std::tuple< Inputs... > QueueElement
Definition: sequencer.h:112
ros::Duration


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