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;
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_ */
fkie_message_filters
Definition: buffer.h:33
fkie_message_filters::combiner_policies::PolicyBase< IOs... >::IncomingTuples
std::tuple< helpers::io_tuple_t< IOs >... > IncomingTuples
Tuple type of incoming data tuples.
Definition: policy_base.h:60
fkie_message_filters::combiner_policies::Fifo::reset
void reset() noexcept override
Reset internal state.
Definition: fifo_impl.h:128
fkie_message_filters::combiner_policies::Fifo::has_complete_tuple
bool has_complete_tuple() noexcept
Definition: fifo_impl.h:100
fkie_message_filters::combiner_policies::PolicyBase< IOs... >::EmitterCB
std::function< void(const OutgoingTuple &)> EmitterCB
Callback for assembled outputs.
Definition: policy_base.h:64
boost
fkie_message_filters::combiner_policies::Fifo::add
void add(std::unique_lock< std::mutex > &, const std::tuple_element_t< N, IncomingTuples > &)
Input function.
Definition: fifo_impl.h:83
fkie_message_filters::combiner_policies::Fifo::in_
IncomingQueues in_
Definition: fifo.h:124
fkie_message_filters::Combiner
Combine multiple sources into a single one.
Definition: combiner.h:90
fkie_message_filters::combiner_policies::Fifo::assemble_output
MaybeOutgoingTuples assemble_output() noexcept
Definition: fifo_impl.h:114
fkie_message_filters::combiner_policies::Fifo::Fifo
Fifo(std::size_t max_queue_size=1)
Constructor.
Definition: fifo_impl.h:70
policy_base.h
std
fkie_message_filters::combiner_policies::PolicyBase< IOs... >::OutgoingTuple
helpers::io_tuple_t< helpers::io_concat_t< IOs... > > OutgoingTuple
Combined tuple type for data output.
Definition: policy_base.h:62
fkie_message_filters::combiner_policies::PolicyBase< IOs... >::MaybeOutgoingTuples
std::tuple< boost::optional< helpers::io_tuple_t< IOs > >... > MaybeOutgoingTuples
Tuple of outgoing tuple candidates.
Definition: policy_base.h:82
fkie_message_filters::helpers::io_tuple_t
typename io_tuple< IO >::type io_tuple_t
Definition: io.h:129
fkie_message_filters::combiner_policies::Fifo::IncomingQueues
std::tuple< boost::circular_buffer< helpers::io_tuple_t< IOs > >... > IncomingQueues
Definition: fifo.h:121


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