fifo.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_FIFO_H_
22 #define INCLUDE_FKIE_MESSAGE_FILTERS_COMBINER_POLICIES_FIFO_H_
23 
24 #include "policy_base.h"
25 #include <boost/circular_buffer.hpp>
26 #include <mutex>
27 
28 namespace fkie_message_filters
29 {
30 namespace combiner_policies
31 {
32 
42 template<typename... IOs>
43 class Fifo : public PolicyBase<IOs...>
44 {
45 public:
46  template<template<typename...> class, class...> friend class fkie_message_filters::Combiner;
47  using typename PolicyBase<IOs...>::EmitterCB;
48  using typename PolicyBase<IOs...>::IncomingTuples;
49  using typename PolicyBase<IOs...>::OutgoingTuple;
56  explicit Fifo(std::size_t max_queue_size = 1);
57 protected:
62  template<std::size_t N>
63  void add(std::unique_lock<std::mutex>&, const std::tuple_element_t<N, IncomingTuples>&);
64  void reset() noexcept override;
65 private:
66  using typename PolicyBase<IOs...>::MaybeOutgoingTuples;
67  using IncomingQueues = std::tuple<boost::circular_buffer<helpers::io_tuple_t<IOs>>...>;
68  bool has_complete_tuple() noexcept;
69  MaybeOutgoingTuples assemble_output() noexcept;
71 };
72 
73 } // namespace combiner_policies
74 } // namespace fkie_message_filters
75 
76 #include "fifo_impl.h"
77 
78 #endif /* INCLUDE_FKIE_MESSAGE_FILTERS_COMBINER_POLICIES_FIFO_H_ */
void add(std::unique_lock< std::mutex > &, const std::tuple_element_t< N, IncomingTuples > &)
Input function.
Definition: fifo_impl.h:47
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
std::tuple< boost::circular_buffer< helpers::io_tuple_t< IOs > >... > IncomingQueues
Definition: fifo.h:67
void reset() noexcept override
Reset internal state.
Definition: fifo_impl.h:92
First-In-First-Out policy.
Definition: fifo.h:43
Fifo(std::size_t max_queue_size=1)
Constructor.
Definition: fifo_impl.h:34
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
MaybeOutgoingTuples assemble_output() noexcept
Definition: fifo_impl.h:78
typename io_tuple< IO >::type io_tuple_t
Definition: io.h:111
Combine multiple sources into a single one.
Definition: combiner.h:72


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