Note: Goby version 1 (shown here) is now considered obsolete. Please use version 2 for new projects, and consider upgrading old projects.

Goby Underwater Autonomy Project  Series: 1.1, revision: 163, released on 2013-02-06 14:23:27 -0500
acomms/connect.h
00001 // copyright 2011 t. schneider tes@mit.edu
00002 // 
00003 // this file is part of goby-acomms, which is a collection of libraries 
00004 // for acoustic underwater networking
00005 //
00006 // This program is free software: you can redistribute it and/or modify
00007 // it under the terms of the GNU General Public License as published by
00008 // the Free Software Foundation, either version 3 of the License, or
00009 // (at your option) any later version.
00010 //
00011 // This software is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU General Public License
00017 // along with this software.  If not, see <http://www.gnu.org/licenses/>.
00018 
00019 // gives functions for connecting the slots and signals of the goby-acomms libraries together
00020 
00021 #ifndef CONNECT20110121H
00022 #define CONNECT20110121H
00023 
00024 #include <boost/bind.hpp>
00025 #include <boost/signal.hpp>
00026 
00027 namespace goby
00028 {
00029     namespace acomms
00030     {   
00031 
00033         template<typename Signal, typename Slot>
00034             void connect(Signal* signal, Slot slot)
00035         { signal->connect(slot); }
00036 
00038         template<typename Signal, typename Obj, typename A1> 
00039             void connect(Signal* signal, Obj* obj, void(Obj::*mem_func)(A1))
00040         { connect(signal, boost::bind(mem_func, obj, _1)); }
00041 
00043         template<typename Signal, typename Obj, typename A1, typename A2> 
00044             void connect(Signal* signal, Obj* obj, void(Obj::*mem_func)(A1, A2))
00045         { connect(signal, boost::bind(mem_func, obj, _1, _2)); }
00046 
00048         template<typename Signal, typename Obj, typename A1, typename A2, typename A3> 
00049             void connect(Signal* signal, Obj* obj, void(Obj::*mem_func)(A1, A2, A3))
00050         { connect(signal, boost::bind(mem_func, obj, _1, _2, _3)); }
00051     }
00052 }
00053 
00054 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends