source_impl.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_IMPL_H_
21 #define INCLUDE_FKIE_MESSAGE_FILTERS_SOURCE_IMPL_H_
22 
23 #include "source.h"
24 #include <mutex>
25 
26 namespace fkie_message_filters
27 {
28 
29 template<typename... Outputs>
31 {
32  std::lock_guard<std::mutex> lock(dst.mutex_);
33  Connection c = signal_.connect_extended([&dst](const Connection& conn, const Outputs&... out) { dst.receive_cb(conn, out...); });
34  dst.conn_.push_back(c);
35  return c;
36 }
37 
38 template<typename... Outputs>
40 {
41  signal_.disconnect_all_slots();
42 }
43 
44 template<typename... Outputs>
46 {
47  disconnect_from_all_sinks();
48 }
49 
50 template<typename... Outputs>
51 void Source<Outputs...>::send(const Outputs&... out)
52 {
53  signal_(out...);
54 }
55 
56 } // namespace fkie_message_filters
57 
58 #endif /* INCLUDE_FKIE_MESSAGE_FILTERS_SOURCE_IMPL_H_ */
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
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


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