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_;
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_ */
void flush()
Flush the message queue.
Enforce correct temporal order.
Definition: sequencer.h:43
std::multimap< ros::Time, QueueElement > Queue
Definition: sequencer.h:77
Group multiple data types as filter input or output.
Definition: io.h:27
Sequencer(const ros::Duration &max_delay=ros::Duration(1, 0)) noexcept
Definition: sequencer.h:88
Typed base class for filters.
Definition: filter.h:35
void reset() noexcept override
Reset filter state.
void receive(const Inputs &... in) override
Process incoming data.
Primary namespace.
Definition: buffer.h:33
std::tuple< Inputs... > QueueElement
Definition: sequencer.h:76
void set_max_delay(const ros::Duration &max_delay) noexcept
Modify maximum delay.
Sequencer(const ros::Duration &max_delay=ros::Duration(1, 0)) noexcept
Constructor.


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