vdk 2.4.0
sigc_addon.h
1/* -*- c++ -*- */
2/*
3 * ===========================
4 * VDK Visual Development Kit
5 * Version 1.0.3
6 * November 1999
7 * ===========================
8 *
9 * Copyright (C) 1998, Mario Motta
10 * Developed by Mario Motta <mmotta@guest.net>
11 *
12 * This library is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Library General Public
14 * License as published by the Free Software Foundation; either
15 * version 2 of the License, or (at your option) any later version.
16 *
17 * This library is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Library General Public License for more details.
21 *
22 * You should have received a copy of the GNU Library General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
25 * 02111-130
26 */
27#ifndef _sigc_addon_h_
28#define _sigc_addon_h_
29#ifdef USE_SIGCPLUSPLUS
30#include <sigc++/signal_system.h>
31
32#ifdef SIGC_CXX_NAMESPACES // currently code depends on this!
33using namespace std;
34using namespace SigC;
35#endif
36
57template<class Ret, class T>
58class DualSignal0 : public SigC::Signal1<Ret, T>,
59 public SigC::Signal0<Ret>
60{
61private:
62/* Ret emit(){}; // Don't use!!! */
63/* Ret operator()(){} // also */
64public:
65 typedef SigC::Signal0<Ret> short_signal_t;
66 typedef SigC::Signal1<Ret,T> long_signal_t;
67
68 Connection connect(const Slot0<Ret> &sl)
69 {return short_signal_t::connect(sl);}
70
71 Connection connect(const Slot1<Ret, T> &sl)
72 {return long_signal_t::connect(sl);}
73
74 Ret emit(T obj)
75 {short_signal_t::emit();
76 return long_signal_t::emit(obj);}
77
78 Ret operator()(T obj)
79 {short_signal_t::emit();
80 return long_signal_t::emit(obj);}
81
82 bool empty() const
83 {return (short_signal_t::empty() &&
84 long_signal_t::empty());}
85};
86
87template<class Ret, class T, class P1>
88class
89DualSignal1 : public SigC::Signal2<Ret, T, P1>,
90 public SigC::Signal1<Ret, P1>
91{
92private:
93 Ret emit(P1){}; // Don't use!!!
94 Ret operator()(P1){} // also
95public:
96 typedef SigC::Signal1<Ret,P1> short_signal_t;
97 typedef SigC::Signal2<Ret,T,P1> long_signal_t;
98
99 Connection connect(const Slot1<Ret,P1> &sl)
100 {return short_signal_t::connect(sl);}
101
102 Connection connect(const Slot2<Ret, T,P1> &sl)
103 {return long_signal_t::connect(sl);}
104
105 Ret emit(T obj, P1 p1)
106 {short_signal_t::emit(p1);
107 return long_signal_t::emit(obj,p1);}
108
109 Ret operator()(T obj, P1 p1)
110 {short_signal_t::emit(p1);
111 return long_signal_t::emit(obj,p1);}
112
113 bool empty() const
114 {return (short_signal_t::empty() &&
115 long_signal_t::empty());}
116};
117
118template<class Ret, class T, class P1, class P2>
119class
120DualSignal2 : public SigC::Signal3<Ret, T, P1, P2>,
121 public SigC::Signal2<Ret, P1, P2>
122{
123private:
124 Ret emit(P1,P2){}; // Don't use!!!
125 Ret operator()(P1,P2){} // also
126public:
127 typedef SigC::Signal2<Ret,P1,P2> short_signal_t;
128 typedef SigC::Signal3<Ret,T,P1,P2> long_signal_t;
129
130 Connection connect(const Slot2<Ret,P1,P2> &sl)
131 {return short_signal_t::connect(sl);}
132
133 Connection connect(const Slot3<Ret, T,P1,P2> &sl)
134 {return long_signal_t::connect(sl);}
135
136 Ret emit(T obj, P1 p1, P2 p2)
137 {short_signal_t::emit(p1,p2);
138 return long_signal_t::emit(obj,p1,p2);}
139
140 Ret operator()(T obj, P1 p1, P2 p2)
141 {short_signal_t::emit(p1,p2);
142 return long_signal_t::emit(obj,p1,p2);}
143
144 bool empty() const
145 {return (short_signal_t::empty() &&
146 long_signal_t::empty());}
147};
148
149template<class Ret, class T, class P1, class P2, class P3>
150class
151DualSignal3 : public SigC::Signal4<Ret, T, P1, P2, P3>,
152 public SigC::Signal3<Ret, P1, P2, P3>
153{
154private:
155 Ret emit(P1,P2,P3){}; // Don't use!!!
156 Ret operator()(P1,P2,P3){} // also
157public:
158 typedef SigC::Signal3<Ret,P1,P2,P3> short_signal_t;
159 typedef SigC::Signal4<Ret,T,P1,P2,P3> long_signal_t;
160
161 Connection connect(const Slot3<Ret,P1,P2,P3> &sl)
162 {return short_signal_t::connect(sl);}
163
164 Connection connect(const Slot4<Ret, T,P1,P2,P3> &sl)
165 {return long_signal_t::connect(sl);}
166
167 Ret emit(T obj, P1 p1, P2 p2,P3 p3)
168 {short_signal_t::emit(p1,p2,p3);
169 return long_signal_t::emit(obj,p1,p2,p3);}
170
171 Ret operator()(T obj, P1 p1, P2 p2, P3 p3)
172 {short_signal_t::emit(p1,p2,p3);
173 return long_signal_t::emit(obj,p1,p2,p3);}
174
175 bool empty() const
176 {return (short_signal_t::empty() &&
177 long_signal_t::empty());}
178};
179
180template<class Ret>
181class VDKSignal0 : public DualSignal0<Ret, VDKObject*>{};
182
183template<class Ret, class P1>
184class VDKSignal1 : public DualSignal1<Ret, VDKObject*, P1>{};
185
186template<class Ret, class P1, class P2>
187class VDKSignal2 : public DualSignal2<Ret, VDKObject*, P1, P2>{};
188
189template<class Ret, class P1, class P2, class P3>
190class VDKSignal3 : public DualSignal3<Ret, VDKObject*, P1, P2, P3>{};
191
192#endif /* USE_SIGCPLUSPLUS */
193#endif /* !_sigc_addon_h_ */
194