add new sigc++2 directory
[ardour.git] / libs / glibmm2 / glib / glibmm / signalproxy.h
1 // -*- c++ -*-
2 /* This is a generated file, do not edit.  Generated from signalproxy.h.m4 */
3
4 #ifndef _GLIBMM_SIGNALPROXY_H
5 #define _GLIBMM_SIGNALPROXY_H
6
7 extern "C"
8 {
9   typedef void (*GCallback) (void);
10   typedef struct _GObject GObject;
11 }
12
13 #include <sigc++/sigc++.h>
14 #include <glibmm/signalproxy_connectionnode.h>
15
16
17 namespace Glib
18 {
19
20 // Forward declarations
21 class ObjectBase;
22
23 #ifndef DOXYGEN_SHOULD_SKIP_THIS
24
25 struct SignalProxyInfo
26 {
27   const char* signal_name;
28   GCallback   callback;
29   GCallback   notify_callback;
30 };
31
32 #endif //DOXYGEN_SHOULD_SKIP_THIS
33
34 // This base class is used by SignalProxyNormal and SignalProxyProperty.
35 class SignalProxyBase
36 {
37 public:
38   SignalProxyBase(Glib::ObjectBase* obj);
39
40 #ifndef DOXYGEN_SHOULD_SKIP_THIS
41   static inline sigc::slot_base* data_to_slot(void* data)
42   {
43     SignalProxyConnectionNode *const pConnectionNode = static_cast<SignalProxyConnectionNode*>(data);
44
45     // Return 0 if the connection is blocked.
46     return (!pConnectionNode->slot_.blocked()) ? &pConnectionNode->slot_ : 0;
47   }
48 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
49
50 protected:
51   ObjectBase* obj_;
52
53 private:
54   SignalProxyBase& operator=(const SignalProxyBase&); // not implemented
55 };
56
57
58 // shared portion of a Signal
59 /** The SignalProxy provides an API similar to sigc::signal that can be used to
60  * connect sigc::slots to glib signals.
61  *
62  * This holds the name of the glib signal and the object
63  * which might emit it. Actually, proxies are controlled by
64  * the template derivatives, which serve as gatekeepers for the
65  * types allowed on a particular signal.
66  *
67  */
68 class SignalProxyNormal : public SignalProxyBase
69 {
70 public:
71   ~SignalProxyNormal();
72
73   /// stops the current signal emmision (not in libsigc++)
74   void emission_stop();
75
76 #ifndef DOXYGEN_SHOULD_SKIP_THIS
77   // This callback for SignalProxy0<void>
78   // is defined here to avoid code duplication.
79   static void slot0_void_callback(GObject*, void* data);
80 #endif
81
82 protected:
83
84   /** Create a proxy for a signal that can be emitted by @a obj.
85    * @param obj The object that can emit the signal.
86    * @param info Information about the signal, including its name, and the C callbacks that should be called by glib.
87    */
88   SignalProxyNormal(Glib::ObjectBase* obj, const SignalProxyInfo* info);
89
90   /** Connects a signal to a generic signal handler. This is called by connect() in derived SignalProxy classes.
91    *
92    * @param slot The signal handler, usually created with sigc::mem_fun(), or sigc::ptr_fun().
93    * @param after Whether this signal handler should be called before or after the default signal handler.
94    */
95   sigc::slot_base& connect_(const sigc::slot_base& slot, bool after);
96
97   /** Connects a signal to a signal handler without a return value.
98    * This is called by connect() in derived SignalProxy classes.
99    *
100    * By default, the signal handler will be called before the default signal handler,
101    * in which case any return value would be replaced anyway by that of the later signal handler.
102    *
103    * @param slot The signal handler, which should have a void return type, usually created with sigc::mem_fun(), or sigc::ptr_fun().
104    * @param after Whether this signal handler should be called before or after the default signal handler.
105    */
106   sigc::slot_base& connect_notify_(const sigc::slot_base& slot, bool after);
107
108 private:
109   const SignalProxyInfo* info_;
110
111   //TODO: We could maybe replace both connect_ and connect_notify_ with this in future, because they don't do anything extra.
112   /** This is called by connect_ and connect_impl_.
113    */
114   sigc::slot_base& connect_impl_(GCallback callback, const sigc::slot_base& slot, bool after);
115
116   // no copy assignment
117   SignalProxyNormal& operator=(const SignalProxyNormal&);
118 };
119
120
121
122
123
124 /**** Glib::SignalProxy0 ***************************************************/
125
126 /** Proxy for signals with 0 arguments.
127  * Use the connect() method, with sigc::mem_fun() or sigc::ptr_fun() to connect signals to signal handlers.
128  */
129 template <class R>
130 class SignalProxy0 : public SignalProxyNormal
131 {
132 public:
133   typedef sigc::slot<R>    SlotType;
134   typedef sigc::slot<void> VoidSlotType;
135
136   SignalProxy0(ObjectBase* obj, const SignalProxyInfo* info)
137     : SignalProxyNormal(obj, info) {}
138
139   /** Connects a signal to a signal handler.
140    * For instance, connect( sigc::mem_fun(*this, &TheClass::on_something) );
141    *
142    * @param slot The signal handler, usually created with sigc::mem_fun(), or sigc::ptr_fun().
143    * @param after Whether this signal handler should be called before or after the default signal handler.
144    */
145   sigc::connection connect(const SlotType& slot, bool after = true)
146     { return sigc::connection(connect_(slot, after)); }
147
148   /** Connects a signal to a signal handler without a return value.
149    * By default, the signal handler will be called before the default signal handler,
150    * in which case any return value would be replaced anyway by that of the later signal handler.
151    *
152    * For instance, connect( sigc::mem_fun(*this, &TheClass::on_something) );
153    *
154    * @param slot The signal handler, which should have a void return type, usually created with sigc::mem_fun(), or sigc::ptr_fun().
155    * @param after Whether this signal handler should be called before or after the default signal handler.
156    */
157   sigc::connection connect_notify(const VoidSlotType& slot, bool after = false)
158     { return sigc::connection(connect_notify_(slot, after)); }
159 };
160
161
162 /**** Glib::SignalProxy1 ***************************************************/
163
164 /** Proxy for signals with 1 arguments.
165  * Use the connect() method, with sigc::mem_fun() or sigc::ptr_fun() to connect signals to signal handlers.
166  */
167 template <class R,class P1>
168 class SignalProxy1 : public SignalProxyNormal
169 {
170 public:
171   typedef sigc::slot<R,P1>    SlotType;
172   typedef sigc::slot<void,P1> VoidSlotType;
173
174   SignalProxy1(ObjectBase* obj, const SignalProxyInfo* info)
175     : SignalProxyNormal(obj, info) {}
176
177   /** Connects a signal to a signal handler.
178    * For instance, connect( sigc::mem_fun(*this, &TheClass::on_something) );
179    *
180    * @param slot The signal handler, usually created with sigc::mem_fun(), or sigc::ptr_fun().
181    * @param after Whether this signal handler should be called before or after the default signal handler.
182    */
183   sigc::connection connect(const SlotType& slot, bool after = true)
184     { return sigc::connection(connect_(slot, after)); }
185
186   /** Connects a signal to a signal handler without a return value.
187    * By default, the signal handler will be called before the default signal handler,
188    * in which case any return value would be replaced anyway by that of the later signal handler.
189    *
190    * For instance, connect( sigc::mem_fun(*this, &TheClass::on_something) );
191    *
192    * @param slot The signal handler, which should have a void return type, usually created with sigc::mem_fun(), or sigc::ptr_fun().
193    * @param after Whether this signal handler should be called before or after the default signal handler.
194    */
195   sigc::connection connect_notify(const VoidSlotType& slot, bool after = false)
196     { return sigc::connection(connect_notify_(slot, after)); }
197 };
198
199
200 /**** Glib::SignalProxy2 ***************************************************/
201
202 /** Proxy for signals with 2 arguments.
203  * Use the connect() method, with sigc::mem_fun() or sigc::ptr_fun() to connect signals to signal handlers.
204  */
205 template <class R,class P1,class P2>
206 class SignalProxy2 : public SignalProxyNormal
207 {
208 public:
209   typedef sigc::slot<R,P1,P2>    SlotType;
210   typedef sigc::slot<void,P1,P2> VoidSlotType;
211
212   SignalProxy2(ObjectBase* obj, const SignalProxyInfo* info)
213     : SignalProxyNormal(obj, info) {}
214
215   /** Connects a signal to a signal handler.
216    * For instance, connect( sigc::mem_fun(*this, &TheClass::on_something) );
217    *
218    * @param slot The signal handler, usually created with sigc::mem_fun(), or sigc::ptr_fun().
219    * @param after Whether this signal handler should be called before or after the default signal handler.
220    */
221   sigc::connection connect(const SlotType& slot, bool after = true)
222     { return sigc::connection(connect_(slot, after)); }
223
224   /** Connects a signal to a signal handler without a return value.
225    * By default, the signal handler will be called before the default signal handler,
226    * in which case any return value would be replaced anyway by that of the later signal handler.
227    *
228    * For instance, connect( sigc::mem_fun(*this, &TheClass::on_something) );
229    *
230    * @param slot The signal handler, which should have a void return type, usually created with sigc::mem_fun(), or sigc::ptr_fun().
231    * @param after Whether this signal handler should be called before or after the default signal handler.
232    */
233   sigc::connection connect_notify(const VoidSlotType& slot, bool after = false)
234     { return sigc::connection(connect_notify_(slot, after)); }
235 };
236
237
238 /**** Glib::SignalProxy3 ***************************************************/
239
240 /** Proxy for signals with 3 arguments.
241  * Use the connect() method, with sigc::mem_fun() or sigc::ptr_fun() to connect signals to signal handlers.
242  */
243 template <class R,class P1,class P2,class P3>
244 class SignalProxy3 : public SignalProxyNormal
245 {
246 public:
247   typedef sigc::slot<R,P1,P2,P3>    SlotType;
248   typedef sigc::slot<void,P1,P2,P3> VoidSlotType;
249
250   SignalProxy3(ObjectBase* obj, const SignalProxyInfo* info)
251     : SignalProxyNormal(obj, info) {}
252
253   /** Connects a signal to a signal handler.
254    * For instance, connect( sigc::mem_fun(*this, &TheClass::on_something) );
255    *
256    * @param slot The signal handler, usually created with sigc::mem_fun(), or sigc::ptr_fun().
257    * @param after Whether this signal handler should be called before or after the default signal handler.
258    */
259   sigc::connection connect(const SlotType& slot, bool after = true)
260     { return sigc::connection(connect_(slot, after)); }
261
262   /** Connects a signal to a signal handler without a return value.
263    * By default, the signal handler will be called before the default signal handler,
264    * in which case any return value would be replaced anyway by that of the later signal handler.
265    *
266    * For instance, connect( sigc::mem_fun(*this, &TheClass::on_something) );
267    *
268    * @param slot The signal handler, which should have a void return type, usually created with sigc::mem_fun(), or sigc::ptr_fun().
269    * @param after Whether this signal handler should be called before or after the default signal handler.
270    */
271   sigc::connection connect_notify(const VoidSlotType& slot, bool after = false)
272     { return sigc::connection(connect_notify_(slot, after)); }
273 };
274
275
276 /**** Glib::SignalProxy4 ***************************************************/
277
278 /** Proxy for signals with 4 arguments.
279  * Use the connect() method, with sigc::mem_fun() or sigc::ptr_fun() to connect signals to signal handlers.
280  */
281 template <class R,class P1,class P2,class P3,class P4>
282 class SignalProxy4 : public SignalProxyNormal
283 {
284 public:
285   typedef sigc::slot<R,P1,P2,P3,P4>    SlotType;
286   typedef sigc::slot<void,P1,P2,P3,P4> VoidSlotType;
287
288   SignalProxy4(ObjectBase* obj, const SignalProxyInfo* info)
289     : SignalProxyNormal(obj, info) {}
290
291   /** Connects a signal to a signal handler.
292    * For instance, connect( sigc::mem_fun(*this, &TheClass::on_something) );
293    *
294    * @param slot The signal handler, usually created with sigc::mem_fun(), or sigc::ptr_fun().
295    * @param after Whether this signal handler should be called before or after the default signal handler.
296    */
297   sigc::connection connect(const SlotType& slot, bool after = true)
298     { return sigc::connection(connect_(slot, after)); }
299
300   /** Connects a signal to a signal handler without a return value.
301    * By default, the signal handler will be called before the default signal handler,
302    * in which case any return value would be replaced anyway by that of the later signal handler.
303    *
304    * For instance, connect( sigc::mem_fun(*this, &TheClass::on_something) );
305    *
306    * @param slot The signal handler, which should have a void return type, usually created with sigc::mem_fun(), or sigc::ptr_fun().
307    * @param after Whether this signal handler should be called before or after the default signal handler.
308    */
309   sigc::connection connect_notify(const VoidSlotType& slot, bool after = false)
310     { return sigc::connection(connect_notify_(slot, after)); }
311 };
312
313
314 /**** Glib::SignalProxy5 ***************************************************/
315
316 /** Proxy for signals with 5 arguments.
317  * Use the connect() method, with sigc::mem_fun() or sigc::ptr_fun() to connect signals to signal handlers.
318  */
319 template <class R,class P1,class P2,class P3,class P4,class P5>
320 class SignalProxy5 : public SignalProxyNormal
321 {
322 public:
323   typedef sigc::slot<R,P1,P2,P3,P4,P5>    SlotType;
324   typedef sigc::slot<void,P1,P2,P3,P4,P5> VoidSlotType;
325
326   SignalProxy5(ObjectBase* obj, const SignalProxyInfo* info)
327     : SignalProxyNormal(obj, info) {}
328
329   /** Connects a signal to a signal handler.
330    * For instance, connect( sigc::mem_fun(*this, &TheClass::on_something) );
331    *
332    * @param slot The signal handler, usually created with sigc::mem_fun(), or sigc::ptr_fun().
333    * @param after Whether this signal handler should be called before or after the default signal handler.
334    */
335   sigc::connection connect(const SlotType& slot, bool after = true)
336     { return sigc::connection(connect_(slot, after)); }
337
338   /** Connects a signal to a signal handler without a return value.
339    * By default, the signal handler will be called before the default signal handler,
340    * in which case any return value would be replaced anyway by that of the later signal handler.
341    *
342    * For instance, connect( sigc::mem_fun(*this, &TheClass::on_something) );
343    *
344    * @param slot The signal handler, which should have a void return type, usually created with sigc::mem_fun(), or sigc::ptr_fun().
345    * @param after Whether this signal handler should be called before or after the default signal handler.
346    */
347   sigc::connection connect_notify(const VoidSlotType& slot, bool after = false)
348     { return sigc::connection(connect_notify_(slot, after)); }
349 };
350
351
352 /**** Glib::SignalProxy6 ***************************************************/
353
354 /** Proxy for signals with 6 arguments.
355  * Use the connect() method, with sigc::mem_fun() or sigc::ptr_fun() to connect signals to signal handlers.
356  */
357 template <class R,class P1,class P2,class P3,class P4,class P5,class P6>
358 class SignalProxy6 : public SignalProxyNormal
359 {
360 public:
361   typedef sigc::slot<R,P1,P2,P3,P4,P5,P6>    SlotType;
362   typedef sigc::slot<void,P1,P2,P3,P4,P5,P6> VoidSlotType;
363
364   SignalProxy6(ObjectBase* obj, const SignalProxyInfo* info)
365     : SignalProxyNormal(obj, info) {}
366
367   /** Connects a signal to a signal handler.
368    * For instance, connect( sigc::mem_fun(*this, &TheClass::on_something) );
369    *
370    * @param slot The signal handler, usually created with sigc::mem_fun(), or sigc::ptr_fun().
371    * @param after Whether this signal handler should be called before or after the default signal handler.
372    */
373   sigc::connection connect(const SlotType& slot, bool after = true)
374     { return sigc::connection(connect_(slot, after)); }
375
376   /** Connects a signal to a signal handler without a return value.
377    * By default, the signal handler will be called before the default signal handler,
378    * in which case any return value would be replaced anyway by that of the later signal handler.
379    *
380    * For instance, connect( sigc::mem_fun(*this, &TheClass::on_something) );
381    *
382    * @param slot The signal handler, which should have a void return type, usually created with sigc::mem_fun(), or sigc::ptr_fun().
383    * @param after Whether this signal handler should be called before or after the default signal handler.
384    */
385   sigc::connection connect_notify(const VoidSlotType& slot, bool after = false)
386     { return sigc::connection(connect_notify_(slot, after)); }
387 };
388
389
390 } // namespace Glib
391
392
393 #endif /* _GLIBMM_SIGNALPROXY_H */
394