source.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 #ifndef INCLUDE_FKIE_MESSAGE_FILTERS_SOURCE_H_
21 #define INCLUDE_FKIE_MESSAGE_FILTERS_SOURCE_H_
22 
23 #include "types.h"
24 #include "filter_base.h"
25 #include <boost/signals2.hpp>
26 
27 namespace fkie_message_filters
28 {
29 
30 template<typename...> class Sink;
31 
43 template<typename... Outputs>
44 class Source : public virtual FilterBase
45 {
46  template<typename...> friend class Sink;
47 public:
49  static constexpr std::size_t NUM_OUTPUTS = sizeof...(Outputs);
54  using Output = IO<Outputs...>;
55 
56  virtual ~Source() {}
76  void disconnect_from_all_sinks() noexcept;
83  virtual void disconnect() noexcept override;
84 protected:
91  void send (const Outputs&... out);
92 private:
93  boost::signals2::signal<void(const Outputs&...)> signal_;
94 };
95 
96 template<typename... Outputs>
97 class Source<IO<Outputs...>> : public Source<Outputs...>
98 {
99 };
100 
101 } // namespace fkie_message_filters
102 
103 #include "sink.h"
104 #include "source_impl.h"
105 
106 #endif /* INCLUDE_FKIE_MESSAGE_FILTERS_SOURCE_H_ */
static constexpr std::size_t NUM_OUTPUTS
Number of output arguments.
Definition: source.h:49
Base class for data consumers.
Definition: sink.h:46
boost::signals2::connection Connection
Tracks connections from sources to sinks.
Definition: types.h:31
Base class for data providers.
Definition: sink.h:33
Group multiple data types as filter input or output.
Definition: io.h:27
void disconnect_from_all_sinks() noexcept
Disconnect from all connected sinks.
Definition: source_impl.h:39
Connection connect_to_sink(Sink< Outputs... > &dst) noexcept
Connect this source to a sink.
Definition: source_impl.h:30
Primary namespace.
Definition: buffer.h:33
void send(const Outputs &... out)
Pass data to all connected sinks.
Definition: source_impl.h:51
virtual void disconnect() noexcept override
Disconnect from all connected sinks.
Definition: source_impl.h:45
boost::signals2::signal< void(const Outputs &...)> signal_
Definition: source.h:93


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