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() {}
69  Connection connect_to_sink (Sink<Outputs...>& dst) noexcept;
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_ */
fkie_message_filters
Definition: buffer.h:33
fkie_message_filters::Source::send
void send(const Outputs &... out)
Pass data to all connected sinks.
Definition: source_impl.h:69
fkie_message_filters::Source::~Source
virtual ~Source()
Definition: source.h:74
fkie_message_filters::Source::Sink
friend class Sink
Definition: source.h:64
types.h
source_impl.h
boost
fkie_message_filters::Source::Output
IO< Outputs... > Output
Grouped output types.
Definition: source.h:72
fkie_message_filters::Source::NUM_OUTPUTS
static constexpr std::size_t NUM_OUTPUTS
Number of output arguments.
Definition: source.h:67
fkie_message_filters::Source::disconnect_from_all_sinks
void disconnect_from_all_sinks() noexcept
Disconnect from all connected sinks.
Definition: source_impl.h:57
filter_base.h
fkie_message_filters::Connection
boost::signals2::connection Connection
Tracks connections from sources to sinks.
Definition: types.h:49
fkie_message_filters::Source::signal_
boost::signals2::signal< void(const Outputs &...)> signal_
Definition: source.h:111
sink.h
fkie_message_filters::Source::disconnect
virtual void disconnect() noexcept override
Disconnect from all connected sinks.
Definition: source_impl.h:63
fkie_message_filters::Source::connect_to_sink
Connection connect_to_sink(Sink< Outputs... > &dst) noexcept
Connect this source to a sink.
Definition: source_impl.h:48


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