exact_time.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_COMBINER_POLICIES_EXACT_TIME_H_
22 #define INCLUDE_FKIE_MESSAGE_FILTERS_COMBINER_POLICIES_EXACT_TIME_H_
23 
24 #include "policy_base.h"
25 #include <map>
26 #include <mutex>
27 #include <ros/duration.h>
28 
29 namespace fkie_message_filters
30 {
31 namespace combiner_policies
32 {
33 
49 template<typename... IOs>
50 class ExactTime : public PolicyBase<IOs...>
51 {
52 public:
53  template<template<typename...> class, class...> friend class fkie_message_filters::Combiner;
54  using typename PolicyBase<IOs...>::EmitterCB;
55  using typename PolicyBase<IOs...>::IncomingTuples;
56  using typename PolicyBase<IOs...>::OutgoingTuple;
61  ExactTime();
73  ExactTime& set_max_age(const ros::Duration& max_age) noexcept;
81  ExactTime& set_max_queue_size(std::size_t queue_size, const boost::optional<ros::Duration>& max_age = boost::none) noexcept;
82 protected:
87  template<std::size_t N>
88  void add(std::unique_lock<std::mutex>&, const std::tuple_element_t<N, IncomingTuples>&);
89  void reset() noexcept override;
90 private:
91  using typename PolicyBase<IOs...>::MaybeOutgoingTuples;
92  using IncomingQueues = std::tuple<std::map<ros::Time, helpers::io_tuple_t<IOs>>...>;
93  MaybeOutgoingTuples try_assemble_output(const ros::Time& time, bool& complete) noexcept;
95  boost::optional<ros::Duration> max_age_;
97 };
98 
99 } // namespace combiner_policies
100 } // namespace fkie_message_filters
101 
102 #include "exact_time_impl.h"
103 
104 #endif /* INCLUDE_FKIE_MESSAGE_FILTERS_COMBINER_POLICIES_FIFO_H_ */
Base class for combiner policies.
Definition: policy_base.h:37
std::tuple< helpers::io_tuple_t< IOs >... > IncomingTuples
Tuple type of incoming data tuples.
Definition: policy_base.h:42
std::function< void(const OutgoingTuple &)> EmitterCB
Callback for assembled outputs.
Definition: policy_base.h:46
ExactTime & set_max_queue_size(std::size_t queue_size, const boost::optional< ros::Duration > &max_age=boost::none) noexcept
Set maximum queue size.
std::tuple< boost::optional< helpers::io_tuple_t< IOs > >... > MaybeOutgoingTuples
Tuple of outgoing tuple candidates.
Definition: policy_base.h:64
helpers::io_tuple_t< helpers::io_concat_t< IOs... > > OutgoingTuple
Combined tuple type for data output.
Definition: policy_base.h:44
Primary namespace.
Definition: buffer.h:33
void reset() noexcept override
Reset internal state.
typename io_tuple< IO >::type io_tuple_t
Definition: io.h:111
std::tuple< std::map< ros::Time, helpers::io_tuple_t< IOs > >... > IncomingQueues
Definition: exact_time.h:92
MaybeOutgoingTuples try_assemble_output(const ros::Time &time, bool &complete) noexcept
void add(std::unique_lock< std::mutex > &, const std::tuple_element_t< N, IncomingTuples > &)
Input function.
Combine multiple sources into a single one.
Definition: combiner.h:72
boost::optional< ros::Duration > max_age_
Definition: exact_time.h:95
ExactTime & set_max_age(const ros::Duration &max_age) noexcept
Set maximum age of any data in the queue.


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