Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

sigc_addon.h

00001 /* -*- c++ -*- */ 00002 /* 00003 * =========================== 00004 * VDK Visual Development Kit 00005 * Version 1.0.3 00006 * November 1999 00007 * =========================== 00008 * 00009 * Copyright (C) 1998, Mario Motta 00010 * Developed by Mario Motta <mmotta@guest.net> 00011 * 00012 * This library is free software; you can redistribute it and/or 00013 * modify it under the terms of the GNU Library General Public 00014 * License as published by the Free Software Foundation; either 00015 * version 2 of the License, or (at your option) any later version. 00016 * 00017 * This library is distributed in the hope that it will be useful, 00018 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00020 * Library General Public License for more details. 00021 * 00022 * You should have received a copy of the GNU Library General Public 00023 * License along with this library; if not, write to the Free Software 00024 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 00025 * 02111-130 00026 */ 00027 #ifndef _sigc_addon_h_ 00028 #define _sigc_addon_h_ 00029 #ifdef USE_SIGCPLUSPLUS 00030 #include <sigc++/signal_system.h> 00031 00032 #ifdef SIGC_CXX_NAMESPACES // currently code depends on this! 00033 using namespace std; 00034 using namespace SigC; 00035 #endif 00036 00057 template<class Ret, class T> 00058 class DualSignal0 : public SigC::Signal1<Ret, T>, 00059 public SigC::Signal0<Ret> 00060 { 00061 private: 00062 /* Ret emit(){}; // Don't use!!! */ 00063 /* Ret operator()(){} // also */ 00064 public: 00065 typedef SigC::Signal0<Ret> short_signal_t; 00066 typedef SigC::Signal1<Ret,T> long_signal_t; 00067 00068 Connection connect(const Slot0<Ret> &sl) 00069 {return short_signal_t::connect(sl);} 00070 00071 Connection connect(const Slot1<Ret, T> &sl) 00072 {return long_signal_t::connect(sl);} 00073 00074 Ret emit(T obj) 00075 {short_signal_t::emit(); 00076 return long_signal_t::emit(obj);} 00077 00078 Ret operator()(T obj) 00079 {short_signal_t::emit(); 00080 return long_signal_t::emit(obj);} 00081 00082 bool empty() const 00083 {return (short_signal_t::empty() && 00084 long_signal_t::empty());} 00085 }; 00086 00087 template<class Ret, class T, class P1> 00088 class 00089 DualSignal1 : public SigC::Signal2<Ret, T, P1>, 00090 public SigC::Signal1<Ret, P1> 00091 { 00092 private: 00093 Ret emit(P1){}; // Don't use!!! 00094 Ret operator()(P1){} // also 00095 public: 00096 typedef SigC::Signal1<Ret,P1> short_signal_t; 00097 typedef SigC::Signal2<Ret,T,P1> long_signal_t; 00098 00099 Connection connect(const Slot1<Ret,P1> &sl) 00100 {return short_signal_t::connect(sl);} 00101 00102 Connection connect(const Slot2<Ret, T,P1> &sl) 00103 {return long_signal_t::connect(sl);} 00104 00105 Ret emit(T obj, P1 p1) 00106 {short_signal_t::emit(p1); 00107 return long_signal_t::emit(obj,p1);} 00108 00109 Ret operator()(T obj, P1 p1) 00110 {short_signal_t::emit(p1); 00111 return long_signal_t::emit(obj,p1);} 00112 00113 bool empty() const 00114 {return (short_signal_t::empty() && 00115 long_signal_t::empty());} 00116 }; 00117 00118 template<class Ret, class T, class P1, class P2> 00119 class 00120 DualSignal2 : public SigC::Signal3<Ret, T, P1, P2>, 00121 public SigC::Signal2<Ret, P1, P2> 00122 { 00123 private: 00124 Ret emit(P1,P2){}; // Don't use!!! 00125 Ret operator()(P1,P2){} // also 00126 public: 00127 typedef SigC::Signal2<Ret,P1,P2> short_signal_t; 00128 typedef SigC::Signal3<Ret,T,P1,P2> long_signal_t; 00129 00130 Connection connect(const Slot2<Ret,P1,P2> &sl) 00131 {return short_signal_t::connect(sl);} 00132 00133 Connection connect(const Slot3<Ret, T,P1,P2> &sl) 00134 {return long_signal_t::connect(sl);} 00135 00136 Ret emit(T obj, P1 p1, P2 p2) 00137 {short_signal_t::emit(p1,p2); 00138 return long_signal_t::emit(obj,p1,p2);} 00139 00140 Ret operator()(T obj, P1 p1, P2 p2) 00141 {short_signal_t::emit(p1,p2); 00142 return long_signal_t::emit(obj,p1,p2);} 00143 00144 bool empty() const 00145 {return (short_signal_t::empty() && 00146 long_signal_t::empty());} 00147 }; 00148 00149 template<class Ret, class T, class P1, class P2, class P3> 00150 class 00151 DualSignal3 : public SigC::Signal4<Ret, T, P1, P2, P3>, 00152 public SigC::Signal3<Ret, P1, P2, P3> 00153 { 00154 private: 00155 Ret emit(P1,P2,P3){}; // Don't use!!! 00156 Ret operator()(P1,P2,P3){} // also 00157 public: 00158 typedef SigC::Signal3<Ret,P1,P2,P3> short_signal_t; 00159 typedef SigC::Signal4<Ret,T,P1,P2,P3> long_signal_t; 00160 00161 Connection connect(const Slot3<Ret,P1,P2,P3> &sl) 00162 {return short_signal_t::connect(sl);} 00163 00164 Connection connect(const Slot4<Ret, T,P1,P2,P3> &sl) 00165 {return long_signal_t::connect(sl);} 00166 00167 Ret emit(T obj, P1 p1, P2 p2,P3 p3) 00168 {short_signal_t::emit(p1,p2,p3); 00169 return long_signal_t::emit(obj,p1,p2,p3);} 00170 00171 Ret operator()(T obj, P1 p1, P2 p2, P3 p3) 00172 {short_signal_t::emit(p1,p2,p3); 00173 return long_signal_t::emit(obj,p1,p2,p3);} 00174 00175 bool empty() const 00176 {return (short_signal_t::empty() && 00177 long_signal_t::empty());} 00178 }; 00179 00180 template<class Ret> 00181 class VDKSignal0 : public DualSignal0<Ret, VDKObject*>{}; 00182 00183 template<class Ret, class P1> 00184 class VDKSignal1 : public DualSignal1<Ret, VDKObject*, P1>{}; 00185 00186 template<class Ret, class P1, class P2> 00187 class VDKSignal2 : public DualSignal2<Ret, VDKObject*, P1, P2>{}; 00188 00189 template<class Ret, class P1, class P2, class P3> 00190 class VDKSignal3 : public DualSignal3<Ret, VDKObject*, P1, P2, P3>{}; 00191 00192 #endif /* USE_SIGCPLUSPLUS */ 00193 #endif /* !_sigc_addon_h_ */ 00194

Generated on Tue Aug 17 12:39:50 2004 for vdk 2.4.0 by doxygen 1.3.7