Goby v2
bind.h
1 // Copyright 2009-2018 Toby Schneider (http://gobysoft.org/index.wt/people/toby)
2 // GobySoft, LLC (2013-)
3 // Massachusetts Institute of Technology (2007-2014)
4 // Community contributors (see AUTHORS file)
5 //
6 //
7 // This file is part of the Goby Underwater Autonomy Project Libraries
8 // ("The Goby Libraries").
9 //
10 // The Goby Libraries are free software: you can redistribute them and/or modify
11 // them under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 2.1 of the License, or
13 // (at your option) any later version.
14 //
15 // The Goby Libraries are distributed in the hope that they will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with Goby. If not, see <http://www.gnu.org/licenses/>.
22 
23 // gives functions for binding the goby-acomms libraries together
24 
25 #ifndef BIND20100120H
26 #define BIND20100120H
27 
28 #include <boost/bind.hpp>
29 
30 #include "goby/acomms/amac.h"
31 #include "goby/acomms/connect.h"
32 #include "goby/acomms/dccl.h"
33 #include "goby/acomms/modem_driver.h"
34 #include "goby/acomms/queue.h"
35 #include "goby/acomms/route.h"
36 #include "goby/common/logger.h"
37 
38 namespace goby
39 {
40 namespace acomms
41 {
43 inline void bind(ModemDriverBase& driver, QueueManager& queue_manager)
44 {
45  goby::acomms::connect(&driver.signal_receive, &queue_manager,
47 
48  goby::acomms::connect(&driver.signal_data_request, &queue_manager,
50 }
51 
53 inline void bind(MACManager& mac, ModemDriverBase& driver)
54 {
57 }
58 
60 inline void bind(QueueManager& queue_manager, RouteManager& route_manager)
61 {
62  route_manager.add_subnet_queue(&queue_manager);
63  goby::acomms::connect(&queue_manager.signal_in_route, &route_manager, &RouteManager::handle_in);
64  goby::acomms::connect(&queue_manager.signal_out_route, &route_manager,
65  &RouteManager::handle_out);
66 }
67 
69 inline void bind(ModemDriverBase& driver, QueueManager& queue_manager, MACManager& mac)
70 {
71  goby::acomms::bind(driver, queue_manager);
72  goby::acomms::bind(mac, driver);
73 }
74 
76 inline void unbind(ModemDriverBase& driver, QueueManager& queue_manager)
77 {
78  goby::acomms::disconnect(&driver.signal_receive, &queue_manager,
80 
81  goby::acomms::disconnect(&driver.signal_data_request, &queue_manager,
83 }
84 
86 inline void unbind(MACManager& mac, ModemDriverBase& driver)
87 {
90 }
91 
93 inline void unbind(QueueManager& queue_manager, RouteManager& route_manager)
94 {
95  route_manager.add_subnet_queue(&queue_manager);
96  goby::acomms::disconnect(&queue_manager.signal_in_route, &route_manager,
97  &RouteManager::handle_in);
98  goby::acomms::disconnect(&queue_manager.signal_out_route, &route_manager,
99  &RouteManager::handle_out);
100 }
101 
103 inline void unbind(ModemDriverBase& driver, QueueManager& queue_manager, MACManager& mac)
104 {
105  goby::acomms::unbind(driver, queue_manager);
106  goby::acomms::unbind(mac, driver);
107 }
108 
109 // examples
114 
115 } // namespace acomms
116 
117 } // namespace goby
118 
119 #endif
provides an API to the goby-acomms Queuing Library.
Definition: queue_manager.h:49
void handle_modem_data_request(protobuf::ModemTransmission *msg)
Finds data to send to the modem.
boost::signals2::signal< void(const protobuf::QueuedMessageMeta &meta, const google::protobuf::Message &data_msg, int modem_id)> signal_in_route
Used by a router to intercept messages and requeue them if desired.
void handle_modem_receive(const protobuf::ModemTransmission &message)
Receive incoming data from the modem.
boost::signals2::signal< void(const protobuf::ModemTransmission &message)> signal_receive
Called when a binary data transmission is received from the modem.
Definition: driver_base.h:85
boost::signals2::signal< void(protobuf::QueuedMessageMeta *meta, const google::protobuf::Message &data_msg, int modem_id)> signal_out_route
Used by a router to change next-hop destination (in meta)
provides an API to the goby-acomms MAC library. MACManager is essentially a std::list<protobuf::Modem...
Definition: mac_manager.h:51
virtual void handle_initiate_transmission(const protobuf::ModemTransmission &m)=0
Virtual initiate_transmission method. Typically connected to MACManager::signal_initiate_transmission...
void connect(Signal *signal, Slot slot)
connect a signal to a slot (e.g. function pointer)
Definition: connect.h:36
The global namespace for the Goby project.
provides an abstract base class for acoustic modem drivers. This is subclassed by the various drivers...
Definition: driver_base.h:47
boost::signals2::signal< void(protobuf::ModemTransmission *msg)> signal_data_request
Called when the modem or modem driver needs data to send. The returned data should be stored in Modem...
Definition: driver_base.h:96
void unbind(ModemDriverBase &driver, QueueManager &queue_manager)
unbinds the driver link-layer callbacks to the QueueManager
Definition: bind.h:76
boost::signals2::signal< void(const protobuf::ModemTransmission &m)> signal_initiate_transmission
Signals when it is time for this platform to begin transmission of an acoustic message at the start o...
Definition: mac_manager.h:91
void bind(ModemDriverBase &driver, QueueManager &queue_manager)
binds the driver link-layer callbacks to the QueueManager
Definition: bind.h:43
void disconnect(Signal *signal, Slot slot)
disconnect a signal to a slot (e.g. function pointer)
Definition: connect.h:63