Goby3  3.1.4
2024.02.22
connect.h
Go to the documentation of this file.
1 // Copyright 2011-2023:
2 // GobySoft, LLC (2013-)
3 // Massachusetts Institute of Technology (2007-2014)
4 // Community contributors (see AUTHORS file)
5 // File authors:
6 // Toby Schneider <toby@gobysoft.org>
7 //
8 //
9 // This file is part of the Goby Underwater Autonomy Project Libraries
10 // ("The Goby Libraries").
11 //
12 // The Goby Libraries are free software: you can redistribute them and/or modify
13 // them under the terms of the GNU Lesser General Public License as published by
14 // the Free Software Foundation, either version 2.1 of the License, or
15 // (at your option) any later version.
16 //
17 // The Goby Libraries are distributed in the hope that they will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU Lesser General Public License for more details.
21 //
22 // You should have received a copy of the GNU Lesser General Public License
23 // along with Goby. If not, see <http://www.gnu.org/licenses/>.
24 
25 // gives functions for connecting the slots and signals of the goby-acomms libraries together
26 
27 #ifndef GOBY_ACOMMS_CONNECT_H
28 #define GOBY_ACOMMS_CONNECT_H
29 
30 #include <boost/bind/bind.hpp>
31 #include <boost/signals2.hpp>
32 
33 namespace goby
34 {
35 namespace acomms
36 {
38 template <typename Signal, typename Slot> void connect(Signal* signal, Slot slot)
39 {
40  signal->connect(slot);
41 }
42 
44 template <typename Signal, typename Obj, typename A1>
45 void connect(Signal* signal, Obj* obj, void (Obj::*mem_func)(A1))
46 {
47  connect(signal, boost::bind(mem_func, obj, boost::placeholders::_1));
48 }
49 
51 template <typename Signal, typename Obj, typename A1, typename A2>
52 void connect(Signal* signal, Obj* obj, void (Obj::*mem_func)(A1, A2))
53 {
54  connect(signal, boost::bind(mem_func, obj, boost::placeholders::_1, boost::placeholders::_2));
55 }
56 
58 template <typename Signal, typename Obj, typename A1, typename A2, typename A3>
59 void connect(Signal* signal, Obj* obj, void (Obj::*mem_func)(A1, A2, A3))
60 {
61  connect(signal, boost::bind(mem_func, obj, boost::placeholders::_1, boost::placeholders::_2, boost::placeholders::_3));
62 }
63 
65 template <typename Signal, typename Slot> void disconnect(Signal* signal, Slot slot)
66 {
67  signal->disconnect(slot);
68 }
69 
71 template <typename Signal, typename Obj, typename A1>
72 void disconnect(Signal* signal, Obj* obj, void (Obj::*mem_func)(A1))
73 {
74  disconnect(signal, boost::bind(mem_func, obj, boost::placeholders::_1));
75 }
76 
78 template <typename Signal, typename Obj, typename A1, typename A2>
79 void disconnect(Signal* signal, Obj* obj, void (Obj::*mem_func)(A1, A2))
80 {
81  disconnect(signal, boost::bind(mem_func, obj, boost::placeholders::_1, boost::placeholders::_2));
82 }
83 
85 template <typename Signal, typename Obj, typename A1, typename A2, typename A3>
86 void disconnect(Signal* signal, Obj* obj, void (Obj::*mem_func)(A1, A2, A3))
87 {
88  disconnect(signal, boost::bind(mem_func, obj, boost::placeholders::_1, boost::placeholders::_2, boost::placeholders::_3));
89 }
90 
91 } // namespace acomms
92 } // namespace goby
93 
94 #endif
goby
The global namespace for the Goby project.
Definition: acomms_constants.h:33
goby::acomms::connect
void connect(Signal *signal, Slot slot)
connect a signal to a slot (e.g. function pointer)
Definition: connect.h:38
goby::acomms::bind
void bind(ModemDriverBase &driver, QueueManager &queue_manager)
binds the driver link-layer callbacks to the QueueManager
Definition: bind.h:45
goby::acomms::disconnect
void disconnect(Signal *signal, Slot slot)
disconnect a signal to a slot (e.g. function pointer)
Definition: connect.h:65