|
libpsynth 0.2.1
|
00001 /*************************************************************************** 00002 * * 00003 * PSYCHOSYNTH * 00004 * =========== * 00005 * * 00006 * Copyright (C) 2007 Juan Pedro Bolivar Puente * 00007 * * 00008 * This program is free software: you can redistribute it and/or modify * 00009 * it under the terms of the GNU General Public License as published by * 00010 * the Free Software Foundation, either version 3 of the License, or * 00011 * (at your option) any later version. * 00012 * * 00013 * This program is distributed in the hope that it will be useful, * 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00016 * GNU General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU General Public License * 00019 * along with this program. If not, see <http://www.gnu.org/licenses/>. * 00020 * * 00021 ***************************************************************************/ 00022 00023 #ifndef PSYNTH_OSCBROADCAST_H 00024 #define PSYNTH_OSCBROADCAST_H 00025 00026 #include <list> 00027 #include <lo/lo.h> 00028 00029 #include <psynth/net/osc_misc.hpp> 00030 00031 namespace psynth 00032 { 00033 00034 /* 00035 class first_equals 00036 { 00037 T m_ref; 00038 public: 00039 first_equals(const T& r) : m_ref(r) {}; 00040 00041 template<class U> 00042 bool operator() (const std::pair<T,U>& p) { 00043 return p.first == m_ref; 00044 } 00045 }; 00046 */ 00047 00048 class lo_address_equals_func 00049 { 00050 lo_address m_ref; 00051 00052 public: 00053 lo_address_equals_func(lo_address ref) : m_ref(ref) {} 00054 00055 bool operator() (lo_address param) { 00056 return lo_address_equals(m_ref, param); 00057 } 00058 }; 00059 00060 class osc_broadcast 00061 { 00062 std::list<lo_address> m_dest; 00063 lo_server m_sender; 00064 00065 public: 00066 osc_broadcast() 00067 : m_sender(NULL) 00068 {} 00069 00070 ~osc_broadcast() { 00071 clear(); 00072 } 00073 00074 void set_sender(lo_server s) { 00075 m_sender = s; 00076 } 00077 00078 void add_target (lo_address dest) { 00079 m_dest.push_back(dest); 00080 } 00081 00082 void delete_target (lo_address dest); 00083 /*{ 00084 m_dest.remove_if(lo_address_equals_func(dest)); 00085 }*/ 00086 00087 void clear (); 00088 00089 bool is_target (lo_address dest); 00090 00091 void broadcast_message (const char* path, lo_message msg); 00092 00093 void broadcast_message_from (const char* path, lo_message msg, lo_address from); 00094 }; 00095 00096 } /* namespace psynth */ 00097 00098 #endif /* PSYNTH_OSCBROADCAST_H */
1.7.4