c++-gtk-utils
callback.h
Go to the documentation of this file.
1 /* Copyright (C) 2008 to 2014 Chris Vine
2 
3 The library comprised in this file or of which this file is part is
4 distributed by Chris Vine under the GNU Lesser General Public
5 License as follows:
6 
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Lesser General Public License
9  as published by the Free Software Foundation; either version 2.1 of
10  the License, or (at your option) any later version.
11 
12  This library is distributed in the hope that it will be useful, but
13  WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Lesser General Public License, version 2.1, for more details.
16 
17  You should have received a copy of the GNU Lesser General Public
18  License, version 2.1, along with this library (see the file LGPL.TXT
19  which came with this source code package in the c++-gtk-utils
20  sub-directory); if not, write to the Free Software Foundation, Inc.,
21  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 
23 However, it is not intended that the object code of a program whose
24 source code instantiates a template from this file or uses macros or
25 inline functions (of any length) should by reason only of that
26 instantiation or use be subject to the restrictions of use in the GNU
27 Lesser General Public License. With that in mind, the words "and
28 macros, inline functions and instantiations of templates (of any
29 length)" shall be treated as substituted for the words "and small
30 macros and small inline functions (ten lines or less in length)" in
31 the fourth paragraph of section 5 of that licence. This does not
32 affect any other reason why object code may be subject to the
33 restrictions in that licence (nor for the avoidance of doubt does it
34 affect the application of section 2 of that licence to modifications
35 of the source code in this file).
36 
37 */
38 
39 #ifndef CGU_CALLBACK_H
40 #define CGU_CALLBACK_H
41 
42 /**
43  * @file callback.h
44  * @brief This file provides classes encapsulating callbacks.
45  *
46  * \#include <c++-gtk-utils/callback.h>
47  *
48  * These classes encapsulate callbacks (they are closures). They
49  * comprise a generic callback creation and execution interface.
50  * There is a basic Callback::Callback type, which is an entire
51  * closure or 'thunk', where all the arguments are bound in the
52  * constructor and is completely opaque. Callback::CallbackArg<T> is
53  * a class which takes one unbound argument of type T when the
54  * callback is dispatched, with any other arguments being bound at
55  * construction time. (The opaque Callback::Callback type is in fact
56  * just a typedef for Callback::CallbackArg<void>: the two types are
57  * interchangeable.) In addition, from version 1.2.10 of the library,
58  * by default a callback can be executed by a Callback::CallbackArg<T>
59  * object with two or three unbound arguments by providing a
60  * Cgu::TypeTuple struct as the template type: see under "Usage" below
61  * and @ref TypeTuple for further information.
62  *
63  * The classes can represent static and non-static member functions
64  * and plain functions. In the case of a non-static member function,
65  * the object whose member function the callback represents must
66  * remain in existence until any invocations of the callback have
67  * completed. The function referred to must be one of void return
68  * type.
69  *
70  * The clases are particularly relevant where a callback object may
71  * need to be handed between threads, or in other cases where a
72  * callback object has to be passed by pointer (which will happen at
73  * some stage with glib or pthreads). They are therefore useful for
74  * general event passing when used together with the Callback::post()
75  * functions, or as the data argument of a call to
76  * g_signal_connect_data() in a case where a better design arises when
77  * passing arguments known at connect time by storing them in the
78  * callback object itself, or as the continuation for GIO async
79  * operations.
80  *
81  * The classes are also used in the Emitter/EmitterArg classes in
82  * emitter.h, which enable callbacks to be connected to an emitter and
83  * provide for automatic disconnection where a class object whose
84  * member a callback represents ceases to exist.
85  *
86  * The Callback::make() functions
87  * ------------------------------
88  *
89  * The templated helper Callback::make() functions make it trivial to
90  * create a callback object of the correct type. A maximum of two
91  * bound arguments to pass to the relevant function or class method is
92  * provided for and from version 1.2.10 a maximum of three unbound
93  * arguments to pass at call time - but this can be extended
94  * indefinitely (prior to version 1.2.10 only one unbound argument was
95  * provided for). If there are unbound arguments, they must be the
96  * last (trailing) arguments of the relevant function or method to be
97  * called. Callback/CallbackArg classes do not provide for a return
98  * value. If a result is wanted, users should pass an unbound
99  * argument by reference or pointer (or pointer to pointer).
100  *
101  * Although as mentioned above only two bound and three unbound
102  * arguments are provided for, as any of those arguments can be a
103  * struct, any number of arguments can be passed as members of a
104  * struct (or, in C++11, a std::tuple).
105  *
106  * The Callback::make() functions do a direct type mapping from the
107  * bound arguments of the function or method represented by the
108  * callback object to the arguments stored by the callback object.
109  * Bound value arguments of the relevant function or method to be
110  * called are therefore stored by value in the callback object. A
111  * bound argument can comprise a reference argument (T& or const T&)
112  * if the template parameters of the Callback::make() call are
113  * qualified by hand to avoid a type mismatch: see under "Usage" below
114  * for further particulars, and if the reference argument is non-const
115  * this allows the referenced argument to be mutated. However as this
116  * would result in the lifetime of the argument not being controlled
117  * by the callback object (it would not keep its own copy), it will
118  * often be unsafe to do so. (The documentation on
119  * Thread::JoinableHandle gives a usage where where binding a
120  * reference argument would be safe.)
121  *
122  * From version 1.2.13, the library also provides Callback::make_ref()
123  * functions, which force the callback object to keep a copy of the
124  * value passed where a target function argument is a const reference.
125  * It is therefore safe with const reference arguments. No explicit
126  * type qualification is required by Callback::make_ref(). In
127  * addition the Callback::make_ref() functions provide for more
128  * efficient passing of class type bound arguments than does
129  * Callback::make(): see further below.
130  *
131  * Where more than one unbound argument is to be passed to the target
132  * function, the Cgu::TypeTuple type container struct is used - see
133  * under Usage below for examples.
134  *
135  * The Callback::make_ref() functions
136  * ----------------------------------
137  *
138  * In order to enable the widest variety of types to be accepted as
139  * arguments (including mutating non-const reference arguments in
140  * those cases where it is safe, and also string literals), as
141  * mentioned above when constructing a callback object
142  * Callback::make() receives non-reference bound arguments by value,
143  * and if unoptimised these may be copied up to two times, and once
144  * more when the target function is dispatched. Where a bound
145  * argument is a pointer or a fundamental type (an integral or
146  * floating-point type), optimization by copy elision will reduce the
147  * number of times argument copying takes place when constructing a
148  * callback object to once, but the standard does not permit that with
149  * class types where the constructor or destructor have side effects
150  * or it cannot be ascertained whether they have side effects.
151  *
152  * Therefore, to cater for cases where a target function takes a class
153  * type argument by const reference or value, from version 1.2.13 the
154  * Callback::make_ref() functions are provided. Unlike
155  * Callback::make(), when constructing a callback for a target
156  * function taking a const reference bound argument,
157  * Callback::make_ref() will force the callback object to keep a copy
158  * of the argument instead of a reference to that argument. This
159  * makes the use of const reference arguments safe (at the cost of the
160  * taking of that copy). It cannot be used with non-const references.
161  * In addition, Callback::make_ref() automatically passes class type
162  * arguments for storage by the callback object by reference to const,
163  * so reducing the number of times they are copied, when stored, to
164  * once.
165  *
166  * In the case of a value argument, at callback dispatch time one
167  * additional copy will be made in the normal way when the target
168  * function is called, but in the case of a const reference argument
169  * no such additional copy will be made. What all this means is that,
170  * where bound arguments include a non-trivial class type, the most
171  * efficient and exception safe strategy is usually to construct the
172  * object of the class type on free store and held by Cgu::SharedPtr
173  * or Cgu::SharedLockPtr, have the target function take it by const
174  * Cgu::SharedPtr& or const Cgu::SharedLockPtr&, and construct the
175  * callback object using Callback::make_ref().
176  *
177  * This flexibility of Callback::make_ref() has a downside: unlike
178  * Callback::make(), Callback::make_ref() cannot resolve overloaded
179  * functions by argument type. Where a function has two or more
180  * overloads taking the same number of arguments, explicit
181  * disambiguation by the user is required (see further below under
182  * Overloaded Functions).
183  *
184  * Summary: If a callback object's bound arguments are all simple
185  * fundamental types such as pointers (including C strings), integers
186  * or floating points, use Callback::make(). Where bound arguments
187  * include class types, use Callback::make_ref().
188  *
189  * The Callback::make_val() functions
190  * ----------------------------------
191  *
192  * The library also provides Callback::make_val() functions. These
193  * are retained to keep code compatibility with earlier versions of
194  * the library. They were optimised for use where a target function
195  * takes bound arguments of class type by value, but are now
196  * deprecated and superseded by the automatic variable type mapping of
197  * Callback::make_ref(). Callback::make_ref() should now be used
198  * instead of Callback::make_val().
199  *
200  * Functors
201  * --------
202  *
203  * If a functor class of void return type is required (say for passing
204  * to a c++ algorithm or container, or for automatic lifetime
205  * management of the Callback object), the Callback::Functor and
206  * Callback::FunctorArg wrapper classes can be used. However, for
207  * many c++ algorithms where anonymous functors created as temporaries
208  * can be used, the std::ptr_fun() and MemFun::make() factory
209  * functions will be a more obvious choice.
210  *
211  * Callback::SafeFunctor and Callback::SafeFunctorArg classes are the
212  * same as Callback::Functor and Callback::FunctorArg classes, except
213  * that objects of the safe version may be passed and copied between
214  * threads and put in different containers in different threads (that
215  * is, the reference count maintained with respect to the contained
216  * callback object is thread-safe). They use a SharedLockPtr object
217  * to hold the referenced callback object.
218  *
219  * Memory allocation
220  * -----------------
221  *
222  * If the library is installed using the
223  * \--with-glib-memory-slices-compat or
224  * \--with-glib-memory-slices-no-compat configuration options, any
225  * Callback::Functor, Callback::FunctorArg, Callback::SafeFunctor or
226  * Callback::SafeFunctorArg objects constructed on free store (usually
227  * they won't be) will be constructed in glib memory slices. A
228  * contained Callback::Callback or Callback::CallbackArg object, which
229  * will always be constructed on free store, will be constructed in
230  * glib memory slices if the \--with-glib-memory-slices-no-compat
231  * configuration option is chosen.
232  *
233  * Usage
234  * -----
235  *
236  * For a class object my_obj of type MyClass, with a method void
237  * MyClass::my_method(int, const char*), usage for a fully bound
238  * callback or functor would be:
239  *
240  * @code
241  * using namespace Cgu;
242  * int arg = 1;
243  * Callback::Callback* cb =
244  * Callback::make(my_obj, &MyClass::my_method, arg, "Hello\n");
245  * cb->dispatch();
246  * delete cb;
247  *
248  * Callback::Functor f(Callback::make(my_obj, &MyClass::my_method, arg, "Hello\n"));
249  * f();
250  * @endcode
251  *
252  * Or for a partially bound callback or functor:
253  *
254  * @code
255  * using namespace Cgu;
256  * int arg = 1;
257  * Callback::CallbackArg<const char*>* cb =
258  * Callback::make(my_obj, &MyClass::my_method, arg);
259  * cb->dispatch("Hello\n");
260  * delete cb;
261  *
262  * Callback::FunctorArg<const char*> f(Callback::make(my_obj, &MyClass::my_method, arg));
263  * f("Hello\n");
264  * @endcode
265  *
266  * To provide for two or three unbound arguments, from version 1.2.10
267  * of the library the Cgu::TypeTuple struct is used (this struct has
268  * no members and is never instantiated, so it does not impose any
269  * overhead: see @ref TypeTuple for further information). As in the
270  * case of a single unbound argument, if there are bound arguments
271  * these multiple unbound arguments must be the last (trailing)
272  * arguments of the function to be called. For a class object my_obj
273  * of type MyClass, with a method void MyClass::my_method2(int, int,
274  * int, const char*), usage with two unbound arguments would be:
275  *
276  * @code
277  * int arg1 = 1, arg2 = 2, arg3 = 3;
278  * Cgu::Callback::CallbackArg<Cgu::TypeTuple<int, const char*> >* cb =
279  * Cgu::Callback::make(my_obj, &MyClass::my_method2, arg1, arg2);
280  * cb->dispatch(arg3, "Hello\n");
281  * delete cb;
282  *
283  * Cgu::Callback::FunctorArg<Cgu::TypeTuple<int, const char*> > f(Cgu::Callback::make(my_obj, &MyClass::my_method2, arg1, arg2));
284  * f(arg3, "Hello\n");
285  * @endcode
286  *
287  * and for three unbound arguments:
288  *
289  * @code
290  * int arg1 = 1, arg2 = 2, arg3 = 3;
291  * Cgu::Callback::CallbackArg<Cgu::TypeTuple<int, int, const char*> >* cb =
292  * Cgu::Callback::make(my_obj, &MyClass::my_method2, arg1);
293  * cb->dispatch(arg2, arg3, "Hello\n");
294  * delete cb;
295  *
296  * Cgu::Callback::FunctorArg<Cgu::TypeTuple<int, int, const char*> > f(Cgu::Callback::make(my_obj, &MyClass::my_method2, arg1));
297  * f(arg2, arg3, "Hello\n");
298  * @endcode
299  *
300  * The syntax for the construction of a callback object representing a
301  * static member function with a signature void MyClass::my_func(int,
302  * const char*), or for a normal function, is similar to the
303  * non-static member function case, except that the call to
304  * Callback::make would comprise:
305  *
306  * @code
307  * Callback::make(&MyClass::my_func, arg, "Hello\n");
308  * @endcode
309  * (fully bound), or
310  * @code
311  * Callback::make(&MyClass::my_func, arg);
312  * @endcode
313  * (partially bound), and so on.
314  *
315  * To bind to reference arguments, the call to Callback::make() must
316  * be explicitly typed. For a class object my_obj of type MyClass,
317  * with a method void MyClass::my_method(int&), usage for a fully
318  * bound callback or functor would be:
319  *
320  * @code
321  * int arg = 1;
322  * Callback::Callback* cb =
323  * Callback::make<MyClass, int&>(my_obj, &MyClass::my_method, arg);
324  * @endcode
325  *
326  * Note however the caveats above about binding to reference
327  * arguments.
328  *
329  * No similar explicit typing is required by Callback::make_ref().
330  * Thus for a class object my_obj of type MyClass, with a method void
331  * MyClass::my_method(int, const Something&), usage for a fully bound
332  * callback or functor would be:
333  *
334  * @code
335  * int arg1 = 1;
336  * Something arg2;
337  * Callback::Callback* cb =
338  * Callback::make_ref(my_obj, &MyClass::my_method, arg1, arg2);
339  * @endcode
340  *
341  * Overloaded functions
342  * --------------------
343  *
344  * Note that creating callbacks for overloaded functions can give rise
345  * to an ambiguity when using Callback::make(), arising from the fact
346  * that the callback object may have an unbound argument. For
347  * example:
348  *
349  * @code
350  * class MyClass {
351  * ...
352  * void add(int i);
353  * void add(int i, int j);
354  * void add(double d);
355  * };
356  * MyClass obj;
357  * using namespace Cgu;
358  * Callback::Callback* cb1 = Callback::make(obj, &MyClass::add, 1, 2); // ok
359  * Callback::Callback* cb2 = Callback::make(obj, &MyClass::add, 1.0); // ok
360  * Callback::Callback* cb3 = Callback::make(obj, &MyClass::add, 1); // ambiguous - compilation failure
361  * @endcode
362  *
363  * The third call to Callback::make() is ambiguous, as it could be
364  * creating a callback for either the function MyClass::add(int) with
365  * no unbound argument (that is, creating a Callback::Callback
366  * object), or the function MyClass::add(int, int) with an unbound int
367  * argument (that is, creating a Callback::CallbackArg<int> object).
368  * This situation could be disambiguated by specifically stating the
369  * type of the function which is to be chosen, namely, to instantiate
370  * the callback in the third call with:
371  *
372  * @code
373  * // either:
374  * Callback::Callback* cb3 =
375  * Callback::make(obj, static_cast<void (MyClass::*)(int)>(&MyClass::add), 1);
376  * // or:
377  * Callback::CallbackArg<int>* cb3 =
378  * Callback::make(obj, static_cast<void (MyClass::*)(int, int)>(&MyClass::add), 1);
379  * @endcode
380  *
381  * Callback::make_ref() is less capable than Callback::make() at
382  * deducing template types. It cannot resolve overloaded functions by
383  * examining the arguments passed to it. For example, take a class
384  * MyClass as follows:
385  *
386  * @code
387  * class MyClass {
388  * ...
389  * void add(int i, const double& d);
390  * void add(const int& j, const int& k);
391  * };
392  * @endcode
393  *
394  * Callback::make_ref() would require explicit disambiguation like
395  * this:
396  *
397  * @code
398  * Callback::Callback* cb1 =
399  * Callback::make_ref(obj, static_cast<void (MyClass::*)(int, const double&)>(&MyClass::add), 1, 2.2);
400  * Callback::Callback* cb2 =
401  * Callback::make_ref(obj, static_cast<void (MyClass::*)(const int&, const int&)>(&MyClass::add), 4, 5);
402  * @endcode
403  *
404  * Posting of callbacks
405  * --------------------
406  *
407  * This file also provides a Callback::post() function which will
408  * execute a callback in a glib main loop and can be used (amongst
409  * other things) to pass an event from a worker thread to the main
410  * program thread. In that respect, it provides an alternative to the
411  * Notifier class. It is passed a pointer to a Callback::CallbackArg
412  * object created with a call to Callback::make() or
413  * Callback::make_ref().
414  *
415  * To provide for thread-safe automatic disconnection of the callback
416  * if the callback represents a non-static method of an object which
417  * may be destroyed before the callback executes in the main loop,
418  * include a Releaser as a public member of that object and pass the
419  * Releaser object as the second argument of Callback::post(). Note
420  * that for this to be race free, the lifetime of the remote object
421  * whose method is to be invoked must be determined by the thread to
422  * whose main loop the callback has been attached. When the main loop
423  * begins invoking the execution of the callback, the remote object
424  * must either wholly exist (in which case the callback will be
425  * invoked) or have been destroyed (in which case the callback will be
426  * ignored), and not be in some transient half-state governed by
427  * another thread.
428  *
429  * Advantages as against Notifier:
430  *
431  * 1. If there are a lot of different events requiring callbacks to be
432  * dispatched in the program from worker threads to the main
433  * thread, this avoids having separate Notifier objects for each
434  * event.
435  * 2. It is easier to pass arguments with varying values - they can be
436  * passed as bound arguments of the callback and no special
437  * synchronisation is normally required (the call to
438  * g_source_attach() invokes locking of the main loop which will
439  * have the effect of ensuring memory visibility). With a Notifier
440  * object it may be necessary to use an asynchronous queue to pass
441  * variable values (or to bind a reference to the data, thus
442  * normally requiring separate synchronisation).
443  * 3. Although the callback would normally be sent for execution by
444  * the main program loop, and that is the default, it can be sent
445  * for execution by any thread which has its own
446  * GMainContext/GMainLoop objects. Thus callbacks can be passed
447  * for execution between worker threads, or from the main program
448  * thread to worker threads, as well as from worker threads to the
449  * main program thread.
450  *
451  * Disadvantages as against Notifier:
452  *
453  * 1. Less efficient, as a new callback object has to be created on
454  * freestore every time the callback is invoked, together with a
455  * new SafeEmitter object if a Releaser is used to track the
456  * callback.
457  * 2. Multiple callbacks relevant to a single event cannot be invoked
458  * from a single call for the event - each callback has to be
459  * separately dispatched.
460  */
461 
462 /**
463  * @namespace Cgu::Callback
464  * @brief This namespace provides classes encapsulating callbacks.
465  *
466  * \#include <c++-gtk-utils/callback.h>
467  *
468  * These classes encapsulate callbacks (they are closures). They
469  * comprise a generic callback creation and execution interface.
470  * There is a basic Callback::Callback type, which is an entire
471  * closure or 'thunk', where all the arguments are bound in the
472  * constructor and is completely opaque. Callback::CallbackArg<T> is
473  * a class which takes one unbound argument of type T when the
474  * callback is dispatched, with any other arguments being bound at
475  * construction time. (The opaque Callback::Callback type is in fact
476  * just a typedef for Callback::CallbackArg<void>: the two types are
477  * interchangeable.) In addition, from version 1.2.10 of the library,
478  * by default a callback can be executed by a Callback::CallbackArg<T>
479  * object with two or three unbound arguments by providing a
480  * Cgu::TypeTuple struct as the template type: see under "Usage" below
481  * and @ref TypeTuple for further information.
482  *
483  * The classes can represent static and non-static member functions
484  * and plain functions. In the case of a non-static member function,
485  * the object whose member function the callback represents must
486  * remain in existence until any invocations of the callback have
487  * completed. The function referred to must be one of void return
488  * type.
489  *
490  * The clases are particularly relevant where a callback object may
491  * need to be handed between threads, or in other cases where a
492  * callback object has to be passed by pointer (which will happen at
493  * some stage with glib or pthreads). They are therefore useful for
494  * general event passing when used together with the Callback::post()
495  * functions, or as the data argument of a call to
496  * g_signal_connect_data() in a case where a better design arises when
497  * passing arguments known at connect time by storing them in the
498  * callback object itself, or as the continuation for GIO async
499  * operations.
500  *
501  * The classes are also used in the Emitter/EmitterArg classes in
502  * emitter.h, which enable callbacks to be connected to an emitter and
503  * provide for automatic disconnection where a class object whose
504  * member a callback represents ceases to exist.
505  *
506  * The Callback::make() functions
507  * ------------------------------
508  *
509  * The templated helper Callback::make() functions make it trivial to
510  * create a callback object of the correct type. A maximum of two
511  * bound arguments to pass to the relevant function or class method is
512  * provided for and from version 1.2.10 a maximum of three unbound
513  * arguments to pass at call time - but this can be extended
514  * indefinitely (prior to version 1.2.10 only one unbound argument was
515  * provided for). If there are unbound arguments, they must be the
516  * last (trailing) arguments of the relevant function or method to be
517  * called. Callback/CallbackArg classes do not provide for a return
518  * value. If a result is wanted, users should pass an unbound
519  * argument by reference or pointer (or pointer to pointer).
520  *
521  * Although as mentioned above only two bound and three unbound
522  * arguments are provided for, as any of those arguments can be a
523  * struct, any number of arguments can be passed as members of a
524  * struct (or, in C++11, a std::tuple).
525  *
526  * The Callback::make() functions do a direct type mapping from the
527  * bound arguments of the function or method represented by the
528  * callback object to the arguments stored by the callback object.
529  * Bound value arguments of the relevant function or method to be
530  * called are therefore stored by value in the callback object. A
531  * bound argument can comprise a reference argument (T& or const T&)
532  * if the template parameters of the Callback::make() call are
533  * qualified by hand to avoid a type mismatch: see under "Usage" below
534  * for further particulars, and if the reference argument is non-const
535  * this allows the referenced argument to be mutated. However as this
536  * would result in the lifetime of the argument not being controlled
537  * by the callback object (it would not keep its own copy), it will
538  * often be unsafe to do so. (The documentation on
539  * Thread::JoinableHandle gives a usage where where binding a
540  * reference argument would be safe.)
541  *
542  * From version 1.2.13, the library also provides Callback::make_ref()
543  * functions, which force the callback object to keep a copy of the
544  * value passed where a target function argument is a const reference.
545  * It is therefore safe with const reference arguments. No explicit
546  * type qualification is required by Callback::make_ref(). In
547  * addition the Callback::make_ref() functions provide for more
548  * efficient passing of class type bound arguments than does
549  * Callback::make(): see further below.
550  *
551  * Where more than one unbound argument is to be passed to the target
552  * function, the Cgu::TypeTuple type container struct is used - see
553  * under Usage below for examples.
554  *
555  * The Callback::make_ref() functions
556  * ----------------------------------
557  *
558  * In order to enable the widest variety of types to be accepted as
559  * arguments (including mutating non-const reference arguments in
560  * those cases where it is safe, and also string literals), as
561  * mentioned above when constructing a callback object
562  * Callback::make() receives non-reference bound arguments by value,
563  * and if unoptimised these may be copied up to two times, and once
564  * more when the target function is dispatched. Where a bound
565  * argument is a pointer or a fundamental type (an integral or
566  * floating-point type), optimization by copy elision will reduce the
567  * number of times argument copying takes place when constructing a
568  * callback object to once, but the standard does not permit that with
569  * class types where the constructor or destructor have side effects
570  * or it cannot be ascertained whether they have side effects.
571  *
572  * Therefore, to cater for cases where a target function takes a class
573  * type argument by const reference or value, from version 1.2.13 the
574  * Callback::make_ref() functions are provided. Unlike
575  * Callback::make(), when constructing a callback for a target
576  * function taking a const reference bound argument,
577  * Callback::make_ref() will force the callback object to keep a copy
578  * of the argument instead of a reference to that argument. This
579  * makes the use of const reference arguments safe (at the cost of the
580  * taking of that copy). It cannot be used with non-const references.
581  * In addition, Callback::make_ref() automatically passes class type
582  * arguments for storage by the callback object by reference to const,
583  * so reducing the number of times they are copied, when stored, to
584  * once.
585  *
586  * In the case of a value argument, at callback dispatch time one
587  * additional copy will be made in the normal way when the target
588  * function is called, but in the case of a const reference argument
589  * no such additional copy will be made. What all this means is that,
590  * where bound arguments include a non-trivial class type, the most
591  * efficient and exception safe strategy is usually to construct the
592  * object of the class type on free store and held by Cgu::SharedPtr
593  * or Cgu::SharedLockPtr, have the target function take it by const
594  * Cgu::SharedPtr& or const Cgu::SharedLockPtr&, and construct the
595  * callback object using Callback::make_ref().
596  *
597  * This flexibility of Callback::make_ref() has a downside: unlike
598  * Callback::make(), Callback::make_ref() cannot resolve overloaded
599  * functions by argument type. Where a function has two or more
600  * overloads taking the same number of arguments, explicit
601  * disambiguation by the user is required (see further below under
602  * Overloaded Functions).
603  *
604  * Summary: If a callback object's bound arguments are all simple
605  * fundamental types such as pointers (including C strings), integers
606  * or floating points, use Callback::make(). Where bound arguments
607  * include class types, use Callback::make_ref().
608  *
609  * The Callback::make_val() functions
610  * ----------------------------------
611  *
612  * The library also provides Callback::make_val() functions. These
613  * are retained to keep code compatibility with earlier versions of
614  * the library. They were optimised for use where a target function
615  * takes bound arguments of class type by value, but are now
616  * deprecated and superseded by the automatic variable type mapping of
617  * Callback::make_ref(). Callback::make_ref() should now be used
618  * instead of Callback::make_val().
619  *
620  * Functors
621  * --------
622  *
623  * If a functor class of void return type is required (say for passing
624  * to a c++ algorithm or container, or for automatic lifetime
625  * management of the Callback object), the Callback::Functor and
626  * Callback::FunctorArg wrapper classes can be used. However, for
627  * many c++ algorithms where anonymous functors created as temporaries
628  * can be used, the std::ptr_fun() and MemFun::make() factory
629  * functions will be a more obvious choice.
630  *
631  * Callback::SafeFunctor and Callback::SafeFunctorArg classes are the
632  * same as Callback::Functor and Callback::FunctorArg classes, except
633  * that objects of the safe version may be passed and copied between
634  * threads and put in different containers in different threads (that
635  * is, the reference count maintained with respect to the contained
636  * callback object is thread-safe). They use a SharedLockPtr object
637  * to hold the referenced callback object.
638  *
639  * Memory allocation
640  * -----------------
641  *
642  * If the library is installed using the
643  * \--with-glib-memory-slices-compat or
644  * \--with-glib-memory-slices-no-compat configuration options, any
645  * Callback::Functor, Callback::FunctorArg, Callback::SafeFunctor or
646  * Callback::SafeFunctorArg objects constructed on free store (usually
647  * they won't be) will be constructed in glib memory slices. A
648  * contained Callback::Callback or Callback::CallbackArg object, which
649  * will always be constructed on free store, will be constructed in
650  * glib memory slices if the \--with-glib-memory-slices-no-compat
651  * configuration option is chosen.
652  *
653  * Usage
654  * -----
655  *
656  * For a class object my_obj of type MyClass, with a method void
657  * MyClass::my_method(int, const char*), usage for a fully bound
658  * callback or functor would be:
659  *
660  * @code
661  * using namespace Cgu;
662  * int arg = 1;
663  * Callback::Callback* cb =
664  * Callback::make(my_obj, &MyClass::my_method, arg, "Hello\n");
665  * cb->dispatch();
666  * delete cb;
667  *
668  * Callback::Functor f(Callback::make(my_obj, &MyClass::my_method, arg, "Hello\n"));
669  * f();
670  * @endcode
671  *
672  * Or for a partially bound callback or functor:
673  *
674  * @code
675  * using namespace Cgu;
676  * int arg = 1;
677  * Callback::CallbackArg<const char*>* cb =
678  * Callback::make(my_obj, &MyClass::my_method, arg);
679  * cb->dispatch("Hello\n");
680  * delete cb;
681  *
682  * Callback::FunctorArg<const char*> f(Callback::make(my_obj, &MyClass::my_method, arg));
683  * f("Hello\n");
684  * @endcode
685  *
686  * To provide for two or three unbound arguments, from version 1.2.10
687  * of the library the Cgu::TypeTuple struct is used (this struct has
688  * no members and is never instantiated, so it does not impose any
689  * overhead: see @ref TypeTuple for further information). As in the
690  * case of a single unbound argument, if there are bound arguments
691  * these multiple unbound arguments must be the last (trailing)
692  * arguments of the function to be called. For a class object my_obj
693  * of type MyClass, with a method void MyClass::my_method2(int, int,
694  * int, const char*), usage with two unbound arguments would be:
695  *
696  * @code
697  * int arg1 = 1, arg2 = 2, arg3 = 3;
698  * Cgu::Callback::CallbackArg<Cgu::TypeTuple<int, const char*> >* cb =
699  * Cgu::Callback::make(my_obj, &MyClass::my_method2, arg1, arg2);
700  * cb->dispatch(arg3, "Hello\n");
701  * delete cb;
702  *
703  * Cgu::Callback::FunctorArg<Cgu::TypeTuple<int, const char*> > f(Cgu::Callback::make(my_obj, &MyClass::my_method2, arg1, arg2));
704  * f(arg3, "Hello\n");
705  * @endcode
706  *
707  * and for three unbound arguments:
708  *
709  * @code
710  * int arg1 = 1, arg2 = 2, arg3 = 3;
711  * Cgu::Callback::CallbackArg<Cgu::TypeTuple<int, int, const char*> >* cb =
712  * Cgu::Callback::make(my_obj, &MyClass::my_method2, arg1);
713  * cb->dispatch(arg2, arg3, "Hello\n");
714  * delete cb;
715  *
716  * Cgu::Callback::FunctorArg<Cgu::TypeTuple<int, int, const char*> > f(Cgu::Callback::make(my_obj, &MyClass::my_method2, arg1));
717  * f(arg2, arg3, "Hello\n");
718  * @endcode
719  *
720  * The syntax for the construction of a callback object representing a
721  * static member function with a signature void MyClass::my_func(int,
722  * const char*), or for a normal function, is similar to the
723  * non-static member function case, except that the call to
724  * Callback::make would comprise:
725  *
726  * @code
727  * Callback::make(&MyClass::my_func, arg, "Hello\n");
728  * @endcode
729  * (fully bound), or
730  * @code
731  * Callback::make(&MyClass::my_func, arg);
732  * @endcode
733  * (partially bound), and so on.
734  *
735  * To bind to reference arguments, the call to Callback::make() must
736  * be explicitly typed. For a class object my_obj of type MyClass,
737  * with a method void MyClass::my_method(int&), usage for a fully
738  * bound callback or functor would be:
739  *
740  * @code
741  * int arg = 1;
742  * Callback::Callback* cb =
743  * Callback::make<MyClass, int&>(my_obj, &MyClass::my_method, arg);
744  * @endcode
745  *
746  * Note however the caveats above about binding to reference
747  * arguments.
748  *
749  * No similar explicit typing is required by Callback::make_ref().
750  * Thus for a class object my_obj of type MyClass, with a method void
751  * MyClass::my_method(int, const Something&), usage for a fully bound
752  * callback or functor would be:
753  *
754  * @code
755  * int arg1 = 1;
756  * Something arg2;
757  * Callback::Callback* cb =
758  * Callback::make_ref(my_obj, &MyClass::my_method, arg1, arg2);
759  * @endcode
760  *
761  * Overloaded functions
762  * --------------------
763  *
764  * Note that creating callbacks for overloaded functions can give rise
765  * to an ambiguity when using Callback::make(), arising from the fact
766  * that the callback object may have an unbound argument. For
767  * example:
768  *
769  * @code
770  * class MyClass {
771  * ...
772  * void add(int i);
773  * void add(int i, int j);
774  * void add(double d);
775  * };
776  * MyClass obj;
777  * using namespace Cgu;
778  * Callback::Callback* cb1 = Callback::make(obj, &MyClass::add, 1, 2); // ok
779  * Callback::Callback* cb2 = Callback::make(obj, &MyClass::add, 1.0); // ok
780  * Callback::Callback* cb3 = Callback::make(obj, &MyClass::add, 1); // ambiguous - compilation failure
781  * @endcode
782  *
783  * The third call to Callback::make() is ambiguous, as it could be
784  * creating a callback for either the function MyClass::add(int) with
785  * no unbound argument (that is, creating a Callback::Callback
786  * object), or the function MyClass::add(int, int) with an unbound int
787  * argument (that is, creating a Callback::CallbackArg<int> object).
788  * This situation could be disambiguated by specifically stating the
789  * type of the function which is to be chosen, namely, to instantiate
790  * the callback in the third call with:
791  *
792  * @code
793  * // either:
794  * Callback::Callback* cb3 =
795  * Callback::make(obj, static_cast<void (MyClass::*)(int)>(&MyClass::add), 1);
796  * // or:
797  * Callback::CallbackArg<int>* cb3 =
798  * Callback::make(obj, static_cast<void (MyClass::*)(int, int)>(&MyClass::add), 1);
799  * @endcode
800  *
801  * Callback::make_ref() is less capable than Callback::make() at
802  * deducing template types. It cannot resolve overloaded functions by
803  * examining the arguments passed to it. For example, take a class
804  * MyClass as follows:
805  *
806  * @code
807  * class MyClass {
808  * ...
809  * void add(int i, const double& d);
810  * void add(const int& j, const int& k);
811  * };
812  * @endcode
813  *
814  * Callback::make_ref() would require explicit disambiguation like
815  * this:
816  *
817  * @code
818  * Callback::Callback* cb1 =
819  * Callback::make_ref(obj, static_cast<void (MyClass::*)(int, const double&)>(&MyClass::add), 1, 2.2);
820  * Callback::Callback* cb2 =
821  * Callback::make_ref(obj, static_cast<void (MyClass::*)(const int&, const int&)>(&MyClass::add), 4, 5);
822  * @endcode
823  *
824  * Posting of callbacks
825  * --------------------
826  *
827  * This namespace also provides a Callback::post() function which will
828  * execute a callback in a glib main loop and can be used (amongst
829  * other things) to pass an event from a worker thread to the main
830  * program thread. In that respect, it provides an alternative to the
831  * Notifier class. It is passed a pointer to a Callback::CallbackArg
832  * object created with a call to Callback::make() or
833  * Callback::make_ref().
834  *
835  * To provide for thread-safe automatic disconnection of the callback
836  * if the callback represents a non-static method of an object which
837  * may be destroyed before the callback executes in the main loop,
838  * include a Releaser as a public member of that object and pass the
839  * Releaser object as the second argument of Callback::post(). Note
840  * that for this to be race free, the lifetime of the remote object
841  * whose method is to be invoked must be determined by the thread to
842  * whose main loop the callback has been attached. When the main loop
843  * begins invoking the execution of the callback, the remote object
844  * must either wholly exist (in which case the callback will be
845  * invoked) or have been destroyed (in which case the callback will be
846  * ignored), and not be in some transient half-state governed by
847  * another thread.
848  *
849  * Advantages as against Notifier:
850  *
851  * 1. If there are a lot of different events requiring callbacks to be
852  * dispatched in the program from worker threads to the main
853  * thread, this avoids having separate Notifier objects for each
854  * event.
855  * 2. It is easier to pass arguments with varying values - they can be
856  * passed as bound arguments of the callback and no special
857  * synchronisation is normally required (the call to
858  * g_source_attach() invokes locking of the main loop which will
859  * have the effect of ensuring memory visibility). With a Notifier
860  * object it may be necessary to use an asynchronous queue to pass
861  * variable values (or to bind a reference to the data, thus
862  * normally requiring separate synchronisation).
863  * 3. Although the callback would normally be sent for execution by
864  * the main program loop, and that is the default, it can be sent
865  * for execution by any thread which has its own
866  * GMainContext/GMainLoop objects. Thus callbacks can be passed
867  * for execution between worker threads, or from the main program
868  * thread to worker threads, as well as from worker threads to the
869  * main program thread.
870  *
871  * Disadvantages as against Notifier:
872  *
873  * 1. Less efficient, as a new callback object has to be created on
874  * freestore every time the callback is invoked, together with a
875  * new SafeEmitter object if a Releaser is used to track the
876  * callback.
877  * 2. Multiple callbacks relevant to a single event cannot be invoked
878  * from a single call for the event - each callback has to be
879  * separately dispatched.
880  */
881 
882 #include <functional> // for std::less
883 
884 #include <glib.h>
885 
887 #include <c++-gtk-utils/param.h>
889 
890 namespace Cgu {
891 
892 namespace Callback {
893 
894 /*
895  The CallbackArg class could be additionally templated to provide a
896  return value, but that would affect the simplicity of the
897  interface, and if a case were to arise where a result is needed, an
898  alternative is for users to pass an argument by reference or
899  pointer (or pointer to pointer) rather than have a return value.
900 */
901 
902 /* Declare the two basic interface types */
903 
904 template <class FreeArg> class CallbackArg;
906 
907 /* now the class definitions */
908 
909 /**
910  * @class CallbackArg callback.h c++-gtk-utils/callback.h
911  * @brief The callback interface class
912  * @sa Callback namespace
913  * @sa FunctorArg SafeFunctorArg
914  *
915  * This provides the basic interface class that users will generally
916  * see. The template type is the type of the unbound argument or
917  * container of unbound argument types, if any.
918  * Callback::CallbackArg<void> is typedef'ed to Callback::Callback.
919  *
920  * @b Usage
921  *
922  * For a class object my_obj of type MyClass, with a method void
923  * MyClass::my_method(int, const char*), usage for a fully bound
924  * callback would be:
925  *
926  * @code
927  * using namespace Cgu;
928  * int arg = 1;
929  * Callback::Callback* cb =
930  * Callback::make(my_obj, &MyClass::my_method, arg, "Hello\n");
931  * cb->dispatch();
932  * delete cb;
933  * @endcode
934  *
935  * Or for a partially bound callback:
936  *
937  * @code
938  * using namespace Cgu;
939  * int arg = 1;
940  * Callback::CallbackArg<const char*>* cb =
941  * Callback::make(my_obj, &MyClass::my_method, arg);
942  * cb->dispatch("Hello\n");
943  * delete cb;
944  * @endcode
945  *
946  * There may be up to two bound arguments and up to three unbound
947  * arguments. Callback/CallbackArg classes do not provide for a
948  * return value. If a result is wanted, users should pass an unbound
949  * argument by reference or pointer (or pointer to pointer).
950  *
951  * For further background, including about the Callback::make() and
952  * Callback::make_ref() functions, and the use of the Cgu::TypeTuple
953  * struct for calls involving two or three unbound arguments, read
954  * this: Callback
955  */
956 
957 template <class FreeArg>
958 class CallbackArg {
959 public:
960 /**
961  * This will execute the referenced function or class method
962  * encapsulated by this class. It will only throw if the dispatched
963  * function or class method throws, or if the copy constructor of a
964  * free or bound argument throws and it is not a reference argument.
965  * It is thread safe if the referenced function or class method is
966  * thread safe.
967  * @param arg The argument to be passed to the referenced function or
968  * class method, if any.
969  * @note 1. We use dispatch() to execute the callback, because the
970  * callback would normally be invoked through a base class pointer.
971  * To invoke it through operator()(), use the FunctorArg wrapper
972  * class.
973  * @note 2. This function is specialised for Callback::Callback (ie
974  * Callback::CallbackArg<void>) to take no argument, and for
975  * Callback::CallbackArg<TypeTuple<T1, T2> > and
976  * Callback::CallbackArg<TypeTuple<T1, T2, T3> > to take two and three
977  * arguments respectively.
978  */
979  virtual void dispatch(typename Cgu::Param<FreeArg>::ParamType arg) const = 0;
980 
981 /**
982  * The constructor will not throw unless the copy constructor of an
983  * argument bound to the derived implementation class throws.
984  */
986 
987 /**
988  * The destructor will not throw unless the destructor of an argument
989  * bound to the derived implementation class throws.
990  */
991  virtual ~CallbackArg() {}
992 
993 /* these functions will be inherited by the derived callback classes */
994 #ifdef CGU_USE_GLIB_MEMORY_SLICES_NO_COMPAT
996 #endif
997 };
998 
999 #ifndef DOXYGEN_PARSING
1000 
1001 /*
1002  * Partial template specialisation could be used to provide more than
1003  * one unbound argument to a CallbackArg object, by having a maximum
1004  * number of template arguments which then have a default value of
1005  * 'void' so enabling instantiation (by partial template
1006  * specialisation) of less arguments. The problem with that approach
1007  * is that if the maximum number of unbound arguments is changed,
1008  * binary compatibility of the library is broken.
1009  *
1010  * Accordingly, the approach taken in this library is to provide the
1011  * template struct Cgu::TypeTuple, defined in the param.h header file.
1012  * This struct is never instantiated, but is instead just used as a
1013  * type holder. The advantage of this approach is that binary
1014  * compatibility of the library is maintained, so that a user can
1015  * extend the number of unbound arguments by extending the type holder
1016  * struct (or to use, say, Loki typelists) and write additional
1017  * specialisations of the CallbackArg* classes.
1018  *
1019  * TODO: we could implement this scheme better by passing all the
1020  * class data members of the CallbackArg0, CallbackArg1, etc, concrete
1021  * classes to an intermediate base class, so that the specialised
1022  * child classes just had a dispatch() method, which would avoid much
1023  * of the code duplication arising from the specialisations for 2 and
1024  * 3 unbound arguments as added in version 1.2.10: the only function
1025  * we actually need to specialise for these additional arguments is
1026  * the dispatch() method. However, as these classes are not PODSs
1027  * this would give rise to binary breakage of 1.2.9 and earlier, so we
1028  * have to await a suitable ABI breakage release to clean this up.
1029  */
1030 
1031 template <class FreeArg1, class FreeArg2>
1032 class CallbackArg <TypeTuple<FreeArg1, FreeArg2> > {
1033 public:
1034  virtual void dispatch(typename Cgu::Param<FreeArg1>::ParamType arg1,
1035  typename Cgu::Param<FreeArg2>::ParamType arg2) const = 0;
1036  CallbackArg() {}
1037  virtual ~CallbackArg() {}
1038 
1039 /* these functions will be inherited by the derived callback classes */
1040 #ifdef CGU_USE_GLIB_MEMORY_SLICES_NO_COMPAT
1042 #endif
1043 };
1044 
1045 template <class FreeArg1, class FreeArg2, class FreeArg3>
1046 class CallbackArg <TypeTuple<FreeArg1, FreeArg2, FreeArg3> > {
1047 public:
1048  virtual void dispatch(typename Cgu::Param<FreeArg1>::ParamType arg1,
1049  typename Cgu::Param<FreeArg2>::ParamType arg2,
1050  typename Cgu::Param<FreeArg3>::ParamType arg3) const = 0;
1051  CallbackArg() {}
1052  virtual ~CallbackArg() {}
1053 
1054 /* these functions will be inherited by the derived callback classes */
1055 #ifdef CGU_USE_GLIB_MEMORY_SLICES_NO_COMPAT
1057 #endif
1058 };
1059 
1060 template <>
1061 class CallbackArg<void> {
1062 public:
1063  virtual void dispatch() const = 0;
1064  CallbackArg() {}
1065  virtual ~CallbackArg() {}
1066 
1067 /* these functions will be inherited by the derived callback classes */
1068 #ifdef CGU_USE_GLIB_MEMORY_SLICES_NO_COMPAT
1070 #endif
1071 };
1072 
1073 #endif // DOXYGEN_PARSING
1074 
1075 /* The four basic functor types */
1076 
1077 template <class FreeArg> class FunctorArg;
1078 template <class FreeArg> class SafeFunctorArg;
1079 typedef FunctorArg<void> Functor;
1081 
1082 /* Functor friend functions */
1083 
1084 // we can use built-in operator == when comparing pointers referencing
1085 // different objects of the same type
1086 /**
1087  * Two FunctorArg objects compare equal if the addresses of the
1088  * CallbackArg objects they contain are the same. This comparison
1089  * operator does not throw.
1090  */
1091 template <class T>
1092 bool operator==(const FunctorArg<T>& f1, const FunctorArg<T>& f2) {
1093  return (f1.cb_s.get() == f2.cb_s.get());
1094 }
1095 
1096 /**
1097  * Two FunctorArg objects compare unequal if the addresses of the
1098  * CallbackArg objects they contain are not the same. This comparison
1099  * operator does not throw.
1100  *
1101  * Since 1.2.5
1102  */
1103 template <class T>
1104 bool operator!=(const FunctorArg<T>& f1, const FunctorArg<T>& f2) {
1105  return !(f1 == f2);
1106 }
1107 
1108 // we must use std::less rather than the < built-in operator for
1109 // pointers to objects not within the same array or object: "For
1110 // templates greater, less, greater_equal, and less_equal, the
1111 // specializations for any pointer type yield a total order, even if
1112 // the built-in operators <, >, <=, >= do not." (para 20.3.3/8).
1113 /**
1114  * One FunctorArg object is less than another if the address of the
1115  * CallbackArg object contained by the first is regarded by std::less
1116  * as less than the address of the CallbackArg object contained by the
1117  * other. This comparison operator does not throw unless std::less
1118  * applied to pointer types throws (which it would not do with any
1119  * sane implementation).
1120  */
1121 template <class T>
1122 bool operator<(const FunctorArg<T>& f1, const FunctorArg<T>& f2) {
1123  return std::less<const CallbackArg<T>*>()(f1.cb_s.get(), f2.cb_s.get());
1124 }
1125 
1126 /**
1127  * Two SafeFunctorArg objects compare equal if the addresses of the
1128  * CallbackArg objects they contain are not the same. This comparison
1129  * operator does not throw.
1130  */
1131 template <class T>
1132 bool operator==(const SafeFunctorArg<T>& f1, const SafeFunctorArg<T>& f2) {
1133  return (f1.cb_s.get() == f2.cb_s.get());
1134 }
1135 
1136 /**
1137  * Two SafeFunctorArg objects compare unequal if the addresses of the
1138  * CallbackArg objects they contain are not the same. This comparison
1139  * operator does not throw.
1140  *
1141  * Since 1.2.5
1142  */
1143 template <class T>
1144 bool operator!=(const SafeFunctorArg<T>& f1, const SafeFunctorArg<T>& f2) {
1145  return !(f1 == f2);
1146 }
1147 
1148 /**
1149  * One SafeFunctorArg object is less than another if the address of
1150  * the CallbackArg object contained by the first is regarded by
1151  * std::less as less than the address of the CallbackArg object
1152  * contained by the other. This comparison operator does not throw
1153  * unless std::less applied to pointer types throws (which it would
1154  * not do with any sane implementation).
1155  */
1156 template <class T>
1157 bool operator<(const SafeFunctorArg<T>& f1, const SafeFunctorArg<T>& f2) {
1158  return std::less<const CallbackArg<T>*>()(f1.cb_s.get(), f2.cb_s.get());
1159 }
1160 
1161 /* the functor classes */
1162 
1163 /**
1164  * @class FunctorArg callback.h c++-gtk-utils/callback.h
1165  * @brief Functor class holding a Callback::CallbackArg object.
1166  * @sa SafeFunctorArg
1167  * @sa Callback namespace
1168  *
1169  * This class wraps a CallbackArg object. The callback object is kept
1170  * by SharedPtr so the functor can be copied and offers automatic
1171  * lifetime management of the wrapped callback object, as well as
1172  * providing an operator()() function. Ownership is taken of the
1173  * CallbackArg object passed to the constructor taking a CallbackArg
1174  * pointer, so that constructor should be treated like a shared
1175  * pointer constructor - only pass a newly allocated object to it (or
1176  * copy construct it or assign to it from another existing FunctorArg
1177  * object.). The template type is the type of the unbound argument or
1178  * container of unbound argument types, if any.
1179  * Callback::FunctorArg<void> is typedef'ed to Callback::Functor.
1180  *
1181  * The constructor taking a Callback::CallbackArg pointer is not
1182  * marked explicit, so the results of Callback::make() can be passed
1183  * directly to a function taking a Callback::FunctorArg argument, and
1184  * implicit conversion will take place.
1185  *
1186  * @b Usage
1187  *
1188  * For a class object my_obj of type MyClass, with a method void
1189  * MyClass::my_method(int, const char*), usage for a fully bound functor
1190  * would be:
1191  *
1192  * @code
1193  * using namespace Cgu;
1194  * int arg = 1;
1195  * Callback::Functor f(Callback::make(my_obj, &MyClass::my_method, arg, "Hello\n"));
1196  * f();
1197  * @endcode
1198  *
1199  * Or for a partially bound functor:
1200  *
1201  * @code
1202  * using namespace Cgu;
1203  * int arg = 1;
1204  * Callback::FunctorArg<const char*> f(Callback::make(my_obj, &MyClass::my_method, arg));
1205  * f("Hello\n");
1206  * @endcode
1207  *
1208  * Callback/CallbackArg classes do not provide for a return value. If
1209  * a result is wanted, users should pass an unbound argument by
1210  * reference or pointer (or pointer to pointer).
1211  *
1212  * For further background, including about the Callback::make() and
1213  * Callback::make_ref() functions, and the use of the Cgu::TypeTuple
1214  * struct for calls with two or three unbound arguments, read this:
1215  * Callback
1216  */
1217 
1218 template <class FreeArg>
1219 class FunctorArg {
1221 public:
1222 /**
1223  * This will execute the function or class method referenced by the
1224  * callback encapsulated by this object, or do nothing if this object
1225  * has not been initialized with a callback. It will only throw if
1226  * the executed function or class method throws, or if the copy
1227  * constructor of a free or bound argument throws and it is not a
1228  * reference argument. It is thread safe if the referenced function
1229  * or class method is thread safe.
1230  * @param arg The argument to be passed to the referenced function or
1231  * class method, if any.
1232  * @note This function is specialised for Callback::Functor (ie
1233  * Callback::FunctorArg<void>) to take no argument, and for
1234  * Callback::FunctorArg<TypeTuple<T1, T2> > and
1235  * Callback::FunctorArg<TypeTuple<T1, T2, T3> > to take two and three
1236  * arguments respectively.
1237  */
1238  void operator()(typename Cgu::Param<FreeArg>::ParamType arg) const {
1239  if (cb_s.get()) cb_s->dispatch(arg);
1240  }
1241 
1242 /**
1243  * This comparison operator does not throw (this friend function is
1244  * also called by operator!=<>() from version 1.2.5).
1245  */
1246  friend bool operator== <>(const FunctorArg&, const FunctorArg&);
1247 /**
1248  * This comparison operator does not throw.
1249  */
1250  friend bool operator< <>(const FunctorArg&, const FunctorArg&);
1251 
1252 /**
1253  * Constructor of first FunctorArg holding the referenced callback.
1254  * As it is not marked explicit, it is also a type conversion
1255  * constructor.
1256  * @param cb The CallbackArg object which the functor is to manage.
1257  * @exception std::bad_alloc This might throw std::bad_alloc if
1258  * memory is exhausted and the system throws in that case. Note that
1259  * if such an exception is thrown, then this constructor will clean
1260  * itself up and also delete the callback object passed to it.
1261  * @note 1. std::bad_alloc will not be thrown if the library has been
1262  * installed using the \--with-glib-memory-slices-no-compat
1263  * configuration option: instead glib will terminate the program if
1264  * it is unable to obtain memory from the operating system.
1265  * @note 2. This function is specialised for Callback::Functor (ie
1266  * Callback::FunctorArg<void>) to take a Callback::Callback argument,
1267  * and for Callback::FunctorArg<TypeTuple<T1, T2> > and
1268  * Callback::FunctorArg<TypeTuple<T1, T2, T3> > to take a
1269  * Callback::CallbackArg<TypeTuple<T1, T2> > and
1270  * Callback::CallbackArg<TypeTuple<T1, T2, T3> > argument
1271  * respectively.
1272  */
1273  FunctorArg(const CallbackArg<FreeArg>* cb): cb_s(cb) {}
1274 
1275 /**
1276  * The copy constructor does not throw.
1277  * @param f The assignor.
1278  */
1279  FunctorArg(const FunctorArg& f): cb_s(f.cb_s) {}
1280 
1281  /**
1282  * Default constructor, where a Callback::CallbackArg object is to be
1283  * assigned later (via the type conversion constructor and/or the
1284  * implicit assignment operator). This constructor does not throw.
1285  */
1287 
1288 /* Only has effect if --with-glib-memory-slices-compat or
1289  --with-glib-memory-slices-no-compat option picked */
1291 };
1292 
1293 #ifndef DOXYGEN_PARSING
1294 
1295 template <class FreeArg1, class FreeArg2>
1296 class FunctorArg <TypeTuple<FreeArg1, FreeArg2> > {
1298 public:
1299  void operator()(typename Cgu::Param<FreeArg1>::ParamType arg1,
1300  typename Cgu::Param<FreeArg2>::ParamType arg2) const {
1301  if (cb_s.get()) cb_s->dispatch(arg1, arg2);
1302  }
1303 
1304  friend bool operator== <>(const FunctorArg&, const FunctorArg&);
1305  friend bool operator< <>(const FunctorArg&, const FunctorArg&);
1306 
1307  FunctorArg(const CallbackArg<TypeTuple<FreeArg1, FreeArg2> >* cb): cb_s(cb) {}
1308  FunctorArg(const FunctorArg& f): cb_s(f.cb_s) {}
1309  FunctorArg() {}
1310 
1311 /* Only has effect if --with-glib-memory-slices-compat or
1312  --with-glib-memory-slices-no-compat option picked */
1314 };
1315 
1316 template <class FreeArg1, class FreeArg2, class FreeArg3>
1317 class FunctorArg <TypeTuple<FreeArg1, FreeArg2, FreeArg3> > {
1318  SharedPtr<const CallbackArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> > > cb_s;
1319 public:
1320  void operator()(typename Cgu::Param<FreeArg1>::ParamType arg1,
1321  typename Cgu::Param<FreeArg2>::ParamType arg2,
1322  typename Cgu::Param<FreeArg3>::ParamType arg3) const {
1323  if (cb_s.get()) cb_s->dispatch(arg1, arg2, arg3);
1324  }
1325 
1326  friend bool operator== <>(const FunctorArg&, const FunctorArg&);
1327  friend bool operator< <>(const FunctorArg&, const FunctorArg&);
1328 
1329  FunctorArg(const CallbackArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> >* cb): cb_s(cb) {}
1330  FunctorArg(const FunctorArg& f): cb_s(f.cb_s) {}
1331  FunctorArg() {}
1332 
1333 /* Only has effect if --with-glib-memory-slices-compat or
1334  --with-glib-memory-slices-no-compat option picked */
1336 };
1337 
1338 template <>
1339 class FunctorArg<void> {
1340  SharedPtr<const Callback> cb_s;
1341 public:
1342  void operator()() const {if (cb_s.get()) cb_s->dispatch();}
1343 
1344  friend bool operator== <>(const FunctorArg&, const FunctorArg&);
1345  friend bool operator< <>(const FunctorArg&, const FunctorArg&);
1346 
1347  FunctorArg(const Callback* cb_p): cb_s(cb_p) {}
1348  FunctorArg(const FunctorArg& f): cb_s(f.cb_s) {}
1349  FunctorArg() {}
1350 
1351 /* Only has effect if --with-glib-memory-slices-compat or
1352  --with-glib-memory-slices-no-compat option picked */
1354 };
1355 
1356 #endif // DOXYGEN_PARSING
1357 
1358 /**
1359  * @class SafeFunctorArg callback.h c++-gtk-utils/callback.h
1360  * @brief Functor class holding a Callback::CallbackArg object, with
1361  * thread-safe reference count.
1362  * @sa FunctorArg
1363  * @sa Callback namespace
1364  *
1365  * This class is the same as Callback::FunctorArg except that it will
1366  * provide synchronisation of the reference count between threads.
1367  * Use it where a functor wrapper object is to be passed between
1368  * threads. The FunctorArg documentation gives details on usage.
1369  *
1370  * Callback::SafeFunctorArg<void> is typedef'ed to
1371  * Callback::SafeFunctor.
1372  *
1373  * For further background, read this: Callback
1374  */
1375 
1376 template <class FreeArg>
1377 class SafeFunctorArg {
1378  SharedLockPtr<const CallbackArg<FreeArg> > cb_s;
1379 public:
1380 /**
1381  * This will execute the function or class method referenced by the
1382  * callback encapsulated by this object, or do nothing if this object
1383  * has not been initialized with a callback. It will only throw if
1384  * the executed function or class method throws, or if the copy
1385  * constructor of a free or bound argument throws and it is not a
1386  * reference argument. It is thread safe if the referenced function
1387  * or class method is thread safe.
1388  * @param arg The argument to be passed to the referenced function or
1389  * class method, if any.
1390  * @note This function is specialised for Callback::SafeFunctor (ie
1391  * Callback::SafeFunctorArg<void>) to take no argument, and for
1392  * Callback::SafeFunctorArg<TypeTuple<T1, T2> > and
1393  * Callback::SafeFunctorArg<TypeTuple<T1, T2, T3> > to take two and
1394  * three arguments respectively.
1395  */
1396  void operator()(typename Cgu::Param<FreeArg>::ParamType arg) const {
1397  if (cb_s.get()) cb_s->dispatch(arg);
1398  }
1399 
1400 /**
1401  * This comparison operator does not throw (this friend function is
1402  * also called by operator!=<>() from version 1.2.5).
1403  */
1404  friend bool operator== <>(const SafeFunctorArg&, const SafeFunctorArg&);
1405 /**
1406  * This comparison operator does not throw.
1407  */
1408  friend bool operator< <>(const SafeFunctorArg&, const SafeFunctorArg&);
1409 
1410  /**
1411  * Constructor of first SafeFunctorArg holding the referenced
1412  * callback. As it is not marked explicit, it is also a type
1413  * conversion constructor.
1414  * @param cb The CallbackArg object which the functor is to manage.
1415  * @exception std::bad_alloc This might throw std::bad_alloc if
1416  * memory is exhausted and the system throws in that case. Note that
1417  * if such an exception is thrown, then this constructor will clean
1418  * itself up and also delete the callback object passed to it.
1419  * @note 1. std::bad_alloc will not be thrown if the library has been
1420  * installed using the \--with-glib-memory-slices-no-compat
1421  * configuration option: instead glib will terminate the program if
1422  * it is unable to obtain memory from the operating system.
1423  * @note 2. This function is specialised for Callback::SafeFunctor (ie
1424  * Callback::SafeFunctorArg<void>) to take a Callback::Callback
1425  * argument, and for Callback::SafeFunctorArg<TypeTuple<T1, T2> > and
1426  * Callback::SafeFunctorArg<TypeTuple<T1, T2, T3> > to take a
1427  * Callback::CallbackArg<TypeTuple<T1, T2> > and
1428  * Callback::CallbackArg<TypeTuple<T1, T2, T3> > argument
1429  * respectively.
1430  */
1431  SafeFunctorArg(const CallbackArg<FreeArg>* cb): cb_s(cb) {}
1432 
1433 /**
1434  * The copy constructor does not throw.
1435  * @param f The assignor.
1436  */
1437  SafeFunctorArg(const SafeFunctorArg& f): cb_s(f.cb_s) {}
1438 
1439  /**
1440  * Default constructor, where a Callback::CallbackArg object is to be
1441  * assigned later (via the type conversion constructor and/or the
1442  * implicit assignment operator). This constructor does not throw.
1443  * @note The reference count maintained with respect to the contained
1444  * callback object is thread-safe, so SafeFunctorArg objects may be
1445  * copied between threads by the implicit assignment operator and put
1446  * in different containers in different threads. They use a
1447  * SharedLockPtr object to hold the referenced callback object.
1448  */
1450 
1451 /* Only has effect if --with-glib-memory-slices-compat or
1452  --with-glib-memory-slices-no-compat option picked */
1454 };
1455 
1456 #ifndef DOXYGEN_PARSING
1457 
1458 template <class FreeArg1, class FreeArg2>
1459 class SafeFunctorArg <TypeTuple<FreeArg1, FreeArg2> > {
1461 public:
1462  void operator()(typename Cgu::Param<FreeArg1>::ParamType arg1,
1463  typename Cgu::Param<FreeArg2>::ParamType arg2) const {
1464  if (cb_s.get()) cb_s->dispatch(arg1, arg2);
1465  }
1466 
1467  friend bool operator== <>(const SafeFunctorArg&, const SafeFunctorArg&);
1468  friend bool operator< <>(const SafeFunctorArg&, const SafeFunctorArg&);
1469 
1470  SafeFunctorArg(const CallbackArg<TypeTuple<FreeArg1, FreeArg2> >* cb): cb_s(cb) {}
1471  SafeFunctorArg(const SafeFunctorArg& f): cb_s(f.cb_s) {}
1472  SafeFunctorArg() {}
1473 
1474 /* Only has effect if --with-glib-memory-slices-compat or
1475  --with-glib-memory-slices-no-compat option picked */
1477 };
1478 
1479 template <class FreeArg1, class FreeArg2, class FreeArg3>
1480 class SafeFunctorArg <TypeTuple<FreeArg1, FreeArg2, FreeArg3> > {
1481  SharedLockPtr<const CallbackArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> > > cb_s;
1482 public:
1483  void operator()(typename Cgu::Param<FreeArg1>::ParamType arg1,
1484  typename Cgu::Param<FreeArg2>::ParamType arg2,
1485  typename Cgu::Param<FreeArg3>::ParamType arg3) const {
1486  if (cb_s.get()) cb_s->dispatch(arg1, arg2, arg3);
1487  }
1488 
1489  friend bool operator== <>(const SafeFunctorArg&, const SafeFunctorArg&);
1490  friend bool operator< <>(const SafeFunctorArg&, const SafeFunctorArg&);
1491 
1492  SafeFunctorArg(const CallbackArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> >* cb): cb_s(cb) {}
1493  SafeFunctorArg(const SafeFunctorArg& f): cb_s(f.cb_s) {}
1494  SafeFunctorArg() {}
1495 
1496 /* Only has effect if --with-glib-memory-slices-compat or
1497  --with-glib-memory-slices-no-compat option picked */
1499 };
1500 
1501 template <>
1502 class SafeFunctorArg<void> {
1503  SharedLockPtr<const Callback> cb_s;
1504 public:
1505  void operator()() const {if (cb_s.get()) cb_s->dispatch();}
1506 
1507  friend bool operator== <>(const SafeFunctorArg&, const SafeFunctorArg&);
1508  friend bool operator< <>(const SafeFunctorArg&, const SafeFunctorArg&);
1509 
1510  SafeFunctorArg(const Callback* cb_p): cb_s(cb_p) {}
1511  SafeFunctorArg(const SafeFunctorArg& f): cb_s(f.cb_s) {}
1512  SafeFunctorArg() {}
1513 
1514 /* Only has effect if --with-glib-memory-slices-compat or
1515  --with-glib-memory-slices-no-compat option picked */
1517 };
1518 
1519 #endif // DOXYGEN_PARSING
1520 
1521 /* the callback implementation classes */
1522 
1523 template <class T>
1524 class Callback0: public Callback {
1525 public:
1526  typedef void (T::* MemFunc)();
1527 private:
1528  T* obj;
1529  MemFunc func;
1530 public:
1531  void dispatch() const {(obj->*func)();}
1532  Callback0(T& obj_, MemFunc func_): obj(&obj_), func(func_) {}
1533 };
1534 
1535 template <class T, class FreeArg>
1536 class CallbackArg0: public CallbackArg<FreeArg> {
1537 public:
1538  typedef void (T::* MemFunc)(FreeArg);
1539 private:
1540  T* obj;
1541  MemFunc func;
1542 public:
1543  void dispatch(typename Cgu::Param<FreeArg>::ParamType free_arg) const {
1544  (obj->*func)(free_arg);
1545  }
1546  CallbackArg0(T& obj_, MemFunc func_): obj(&obj_), func(func_) {}
1547 };
1548 
1549 #ifndef DOXYGEN_PARSING
1550 
1551 template <class T, class FreeArg1, class FreeArg2>
1552 class CallbackArg0 <T, TypeTuple<FreeArg1, FreeArg2> >:
1553  public CallbackArg<TypeTuple<FreeArg1, FreeArg2> > {
1554 public:
1555  typedef void (T::* MemFunc)(FreeArg1, FreeArg2);
1556 private:
1557  T* obj;
1558  MemFunc func;
1559 public:
1560  void dispatch(typename Cgu::Param<FreeArg1>::ParamType free_arg1,
1561  typename Cgu::Param<FreeArg2>::ParamType free_arg2) const {
1562  (obj->*func)(free_arg1, free_arg2);
1563  }
1564  CallbackArg0(T& obj_, MemFunc func_): obj(&obj_), func(func_) {}
1565 };
1566 
1567 template <class T, class FreeArg1, class FreeArg2, class FreeArg3>
1568 class CallbackArg0 <T, TypeTuple<FreeArg1, FreeArg2, FreeArg3> >:
1569  public CallbackArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> > {
1570 public:
1571  typedef void (T::* MemFunc)(FreeArg1, FreeArg2, FreeArg3);
1572 private:
1573  T* obj;
1574  MemFunc func;
1575 public:
1576  void dispatch(typename Cgu::Param<FreeArg1>::ParamType free_arg1,
1577  typename Cgu::Param<FreeArg2>::ParamType free_arg2,
1578  typename Cgu::Param<FreeArg3>::ParamType free_arg3) const {
1579  (obj->*func)(free_arg1, free_arg2, free_arg3);
1580  }
1581  CallbackArg0(T& obj_, MemFunc func_): obj(&obj_), func(func_) {}
1582 };
1583 
1584 #endif // DOXYGEN_PARSING
1585 
1586 template <bool unref, class T, class BoundArg>
1587 class Callback1_: public Callback {
1588 public:
1589  typedef void (T::* MemFunc)(BoundArg);
1590 private:
1591  T* obj;
1592  MemFunc func;
1594 public:
1595  void dispatch() const {(obj->*func)(arg);}
1596  Callback1_(T& obj_, MemFunc func_,
1597  typename Cgu::Param<BoundArg>::ParamType arg_): obj(&obj_), func(func_), arg(arg_) {}
1598 };
1599 
1600 template <bool unref, class T, class BoundArg, class FreeArg>
1601 class CallbackArg1_: public CallbackArg<FreeArg> {
1602 public:
1603  typedef void (T::* MemFunc)(BoundArg, FreeArg);
1604 private:
1605  T* obj;
1606  MemFunc func;
1608 public:
1609  void dispatch(typename Cgu::Param<FreeArg>::ParamType free_arg) const {
1610  (obj->*func)(arg, free_arg);
1611  }
1612  CallbackArg1_(T& obj_, MemFunc func_,
1613  typename Cgu::Param<BoundArg>::ParamType arg_): obj(&obj_), func(func_), arg(arg_) {}
1614 };
1615 
1616 #ifndef DOXYGEN_PARSING
1617 
1618 template <bool unref, class T, class BoundArg, class FreeArg1, class FreeArg2>
1619 class CallbackArg1_ <unref, T, BoundArg, TypeTuple<FreeArg1, FreeArg2> >:
1620  public CallbackArg<TypeTuple<FreeArg1, FreeArg2> > {
1621 public:
1622  typedef void (T::* MemFunc)(BoundArg, FreeArg1, FreeArg2);
1623 private:
1624  T* obj;
1625  MemFunc func;
1627 public:
1628  void dispatch(typename Cgu::Param<FreeArg1>::ParamType free_arg1,
1629  typename Cgu::Param<FreeArg2>::ParamType free_arg2) const {
1630  (obj->*func)(arg, free_arg1, free_arg2);
1631  }
1632  CallbackArg1_(T& obj_, MemFunc func_,
1633  typename Cgu::Param<BoundArg>::ParamType arg_): obj(&obj_), func(func_), arg(arg_) {}
1634 };
1635 
1636 template <bool unref, class T, class BoundArg, class FreeArg1, class FreeArg2, class FreeArg3>
1637 class CallbackArg1_ <unref, T, BoundArg, TypeTuple<FreeArg1, FreeArg2, FreeArg3> >:
1638  public CallbackArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> > {
1639 public:
1640  typedef void (T::* MemFunc)(BoundArg, FreeArg1, FreeArg2, FreeArg3);
1641 private:
1642  T* obj;
1643  MemFunc func;
1645 public:
1646  void dispatch(typename Cgu::Param<FreeArg1>::ParamType free_arg1,
1647  typename Cgu::Param<FreeArg2>::ParamType free_arg2,
1648  typename Cgu::Param<FreeArg3>::ParamType free_arg3) const {
1649  (obj->*func)(arg, free_arg1, free_arg2, free_arg3);
1650  }
1651  CallbackArg1_(T& obj_, MemFunc func_,
1652  typename Cgu::Param<BoundArg>::ParamType arg_): obj(&obj_), func(func_), arg(arg_) {}
1653 };
1654 
1655 #endif // DOXYGEN_PARSING
1656 
1657 template <bool unref, class T, class BoundArg1, class BoundArg2>
1658 class Callback2_: public Callback {
1659 public:
1660  typedef void (T::* MemFunc)(BoundArg1, BoundArg2);
1661 private:
1662  T* obj;
1663  MemFunc func;
1666 public:
1667  void dispatch() const {(obj->*func)(arg1, arg2);}
1668  Callback2_(T& obj_, MemFunc func_,
1669  typename Cgu::Param<BoundArg1>::ParamType arg1_,
1670  typename Cgu::Param<BoundArg2>::ParamType arg2_): obj(&obj_), func(func_), arg1(arg1_), arg2(arg2_) {}
1671 };
1672 
1673 template <bool unref, class T, class BoundArg1, class BoundArg2, class FreeArg>
1674 class CallbackArg2_: public CallbackArg<FreeArg> {
1675 public:
1676  typedef void (T::* MemFunc)(BoundArg1, BoundArg2, FreeArg);
1677 private:
1678  T* obj;
1679  MemFunc func;
1682 public:
1683  void dispatch(typename Cgu::Param<FreeArg>::ParamType free_arg) const {
1684  (obj->*func)(arg1, arg2, free_arg);
1685  }
1686  CallbackArg2_(T& obj_, MemFunc func_,
1687  typename Cgu::Param<BoundArg1>::ParamType arg1_,
1688  typename Cgu::Param<BoundArg2>::ParamType arg2_): obj(&obj_), func(func_), arg1(arg1_), arg2(arg2_) {}
1689 };
1690 
1691 #ifndef DOXYGEN_PARSING
1692 
1693 template <bool unref, class T, class BoundArg1, class BoundArg2, class FreeArg1, class FreeArg2>
1694 class CallbackArg2_ <unref, T, BoundArg1, BoundArg2, TypeTuple<FreeArg1, FreeArg2> >:
1695  public CallbackArg<TypeTuple<FreeArg1, FreeArg2> > {
1696 public:
1697  typedef void (T::* MemFunc)(BoundArg1, BoundArg2, FreeArg1, FreeArg2);
1698 private:
1699  T* obj;
1700  MemFunc func;
1703 public:
1704  void dispatch(typename Cgu::Param<FreeArg1>::ParamType free_arg1,
1705  typename Cgu::Param<FreeArg2>::ParamType free_arg2) const {
1706  (obj->*func)(arg1, arg2, free_arg1, free_arg2);
1707  }
1708  CallbackArg2_(T& obj_, MemFunc func_,
1709  typename Cgu::Param<BoundArg1>::ParamType arg1_,
1710  typename Cgu::Param<BoundArg2>::ParamType arg2_): obj(&obj_), func(func_), arg1(arg1_), arg2(arg2_) {}
1711 };
1712 
1713 template <bool unref, class T, class BoundArg1, class BoundArg2,
1714  class FreeArg1, class FreeArg2, class FreeArg3>
1715 class CallbackArg2_ <unref, T, BoundArg1, BoundArg2, TypeTuple<FreeArg1, FreeArg2, FreeArg3> >:
1716  public CallbackArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> > {
1717 public:
1718  typedef void (T::* MemFunc)(BoundArg1, BoundArg2, FreeArg1, FreeArg2, FreeArg3);
1719 private:
1720  T* obj;
1721  MemFunc func;
1724 public:
1725  void dispatch(typename Cgu::Param<FreeArg1>::ParamType free_arg1,
1726  typename Cgu::Param<FreeArg2>::ParamType free_arg2,
1727  typename Cgu::Param<FreeArg3>::ParamType free_arg3) const {
1728  (obj->*func)(arg1, arg2, free_arg1, free_arg2, free_arg3);
1729  }
1730  CallbackArg2_(T& obj_, MemFunc func_,
1731  typename Cgu::Param<BoundArg1>::ParamType arg1_,
1732  typename Cgu::Param<BoundArg2>::ParamType arg2_): obj(&obj_), func(func_), arg1(arg1_), arg2(arg2_) {}
1733 };
1734 
1735 #endif // DOXYGEN_PARSING
1736 
1737 /* const versions, for binding to const methods */
1738 
1739 template <class T>
1740 class Callback0_const: public Callback {
1741 public:
1742  typedef void (T::* MemFunc)() const;
1743 private:
1744  const T* obj;
1745  MemFunc func;
1746 public:
1747  void dispatch() const {(obj->*func)();}
1748  Callback0_const(const T& obj_, MemFunc func_): obj(&obj_), func(func_) {}
1749 };
1750 
1751 template <class T, class FreeArg>
1752 class CallbackArg0_const: public CallbackArg<FreeArg> {
1753 public:
1754  typedef void (T::* MemFunc)(FreeArg) const;
1755 private:
1756  const T* obj;
1757  MemFunc func;
1758 public:
1759  void dispatch(typename Cgu::Param<FreeArg>::ParamType free_arg) const {
1760  (obj->*func)(free_arg);
1761  }
1762  CallbackArg0_const(const T& obj_, MemFunc func_): obj(&obj_), func(func_) {}
1763 };
1764 
1765 #ifndef DOXYGEN_PARSING
1766 
1767 template <class T, class FreeArg1, class FreeArg2>
1768 class CallbackArg0_const <T, TypeTuple<FreeArg1, FreeArg2> >:
1769  public CallbackArg<TypeTuple<FreeArg1, FreeArg2> > {
1770 public:
1771  typedef void (T::* MemFunc)(FreeArg1, FreeArg2) const;
1772 private:
1773  const T* obj;
1774  MemFunc func;
1775 public:
1776  void dispatch(typename Cgu::Param<FreeArg1>::ParamType free_arg1,
1777  typename Cgu::Param<FreeArg2>::ParamType free_arg2) const {
1778  (obj->*func)(free_arg1, free_arg2);
1779  }
1780  CallbackArg0_const(const T& obj_, MemFunc func_): obj(&obj_), func(func_) {}
1781 };
1782 
1783 template <class T, class FreeArg1, class FreeArg2, class FreeArg3>
1784 class CallbackArg0_const <T, TypeTuple<FreeArg1, FreeArg2, FreeArg3> >:
1785  public CallbackArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> > {
1786 public:
1787  typedef void (T::* MemFunc)(FreeArg1, FreeArg2, FreeArg3) const;
1788 private:
1789  const T* obj;
1790  MemFunc func;
1791 public:
1792  void dispatch(typename Cgu::Param<FreeArg1>::ParamType free_arg1,
1793  typename Cgu::Param<FreeArg2>::ParamType free_arg2,
1794  typename Cgu::Param<FreeArg3>::ParamType free_arg3) const {
1795  (obj->*func)(free_arg1, free_arg2, free_arg3);
1796  }
1797  CallbackArg0_const(const T& obj_, MemFunc func_): obj(&obj_), func(func_) {}
1798 };
1799 
1800 #endif // DOXYGEN_PARSING
1801 
1802 template <bool unref, class T, class BoundArg>
1804 public:
1805  typedef void (T::* MemFunc)(BoundArg) const;
1806 private:
1807  const T* obj;
1808  MemFunc func;
1810 public:
1811  void dispatch() const {(obj->*func)(arg);}
1812  Callback1_const_(const T& obj_, MemFunc func_,
1813  typename Cgu::Param<BoundArg>::ParamType arg_): obj(&obj_), func(func_), arg(arg_) {}
1814 };
1815 
1816 template <bool unref, class T, class BoundArg, class FreeArg>
1817 class CallbackArg1_const_: public CallbackArg<FreeArg> {
1818 public:
1819  typedef void (T::* MemFunc)(BoundArg, FreeArg) const;
1820 private:
1821  const T* obj;
1822  MemFunc func;
1824 public:
1825  void dispatch(typename Cgu::Param<FreeArg>::ParamType free_arg) const {
1826  (obj->*func)(arg, free_arg);
1827  }
1828  CallbackArg1_const_(const T& obj_, MemFunc func_,
1829  typename Cgu::Param<BoundArg>::ParamType arg_): obj(&obj_), func(func_), arg(arg_) {}
1830 };
1831 
1832 #ifndef DOXYGEN_PARSING
1833 
1834 template <bool unref, class T, class BoundArg, class FreeArg1, class FreeArg2>
1835 class CallbackArg1_const_ <unref, T, BoundArg, TypeTuple<FreeArg1, FreeArg2> >:
1836  public CallbackArg<TypeTuple<FreeArg1, FreeArg2> > {
1837 public:
1838  typedef void (T::* MemFunc)(BoundArg, FreeArg1, FreeArg2) const;
1839 private:
1840  const T* obj;
1841  MemFunc func;
1843 public:
1844  void dispatch(typename Cgu::Param<FreeArg1>::ParamType free_arg1,
1845  typename Cgu::Param<FreeArg2>::ParamType free_arg2) const {
1846  (obj->*func)(arg, free_arg1, free_arg2);
1847  }
1848  CallbackArg1_const_(const T& obj_, MemFunc func_,
1849  typename Cgu::Param<BoundArg>::ParamType arg_): obj(&obj_), func(func_), arg(arg_) {}
1850 };
1851 
1852 template <bool unref, class T, class BoundArg, class FreeArg1, class FreeArg2, class FreeArg3>
1853 class CallbackArg1_const_ <unref, T, BoundArg, TypeTuple<FreeArg1, FreeArg2, FreeArg3> >:
1854  public CallbackArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> > {
1855 public:
1856  typedef void (T::* MemFunc)(BoundArg, FreeArg1, FreeArg2, FreeArg3) const;
1857 private:
1858  const T* obj;
1859  MemFunc func;
1861 public:
1862  void dispatch(typename Cgu::Param<FreeArg1>::ParamType free_arg1,
1863  typename Cgu::Param<FreeArg2>::ParamType free_arg2,
1864  typename Cgu::Param<FreeArg3>::ParamType free_arg3) const {
1865  (obj->*func)(arg, free_arg1, free_arg2, free_arg3);
1866  }
1867  CallbackArg1_const_(const T& obj_, MemFunc func_,
1868  typename Cgu::Param<BoundArg>::ParamType arg_): obj(&obj_), func(func_), arg(arg_) {}
1869 };
1870 
1871 #endif // DOXYGEN_PARSING
1872 
1873 template <bool unref, class T, class BoundArg1, class BoundArg2>
1875 public:
1876  typedef void (T::* MemFunc)(BoundArg1, BoundArg2) const;
1877 private:
1878  const T* obj;
1879  MemFunc func;
1882 public:
1883  void dispatch() const {(obj->*func)(arg1, arg2);}
1884  Callback2_const_(const T& obj_, MemFunc func_,
1885  typename Cgu::Param<BoundArg1>::ParamType arg1_,
1886  typename Cgu::Param<BoundArg2>::ParamType arg2_): obj(&obj_), func(func_), arg1(arg1_), arg2(arg2_) {}
1887 };
1888 
1889 template <bool unref, class T, class BoundArg1, class BoundArg2, class FreeArg>
1890 class CallbackArg2_const_: public CallbackArg<FreeArg> {
1891 public:
1892  typedef void (T::* MemFunc)(BoundArg1, BoundArg2, FreeArg) const;
1893 private:
1894  const T* obj;
1895  MemFunc func;
1898 public:
1899  void dispatch(typename Cgu::Param<FreeArg>::ParamType free_arg) const {
1900  (obj->*func)(arg1, arg2, free_arg);
1901  }
1902  CallbackArg2_const_(const T& obj_, MemFunc func_,
1903  typename Cgu::Param<BoundArg1>::ParamType arg1_,
1904  typename Cgu::Param<BoundArg2>::ParamType arg2_): obj(&obj_), func(func_), arg1(arg1_), arg2(arg2_) {}
1905 };
1906 
1907 #ifndef DOXYGEN_PARSING
1908 
1909 template <bool unref, class T, class BoundArg1, class BoundArg2, class FreeArg1, class FreeArg2>
1910 class CallbackArg2_const_ <unref, T, BoundArg1, BoundArg2, TypeTuple<FreeArg1, FreeArg2> >:
1911  public CallbackArg<TypeTuple<FreeArg1, FreeArg2> > {
1912 public:
1913  typedef void (T::* MemFunc)(BoundArg1, BoundArg2, FreeArg1, FreeArg2) const;
1914 private:
1915  const T* obj;
1916  MemFunc func;
1919 public:
1920  void dispatch(typename Cgu::Param<FreeArg1>::ParamType free_arg1,
1921  typename Cgu::Param<FreeArg2>::ParamType free_arg2) const {
1922  (obj->*func)(arg1, arg2, free_arg1, free_arg2);
1923  }
1924  CallbackArg2_const_(const T& obj_, MemFunc func_,
1925  typename Cgu::Param<BoundArg1>::ParamType arg1_,
1926  typename Cgu::Param<BoundArg2>::ParamType arg2_): obj(&obj_), func(func_), arg1(arg1_), arg2(arg2_) {}
1927 };
1928 
1929 template <bool unref, class T, class BoundArg1, class BoundArg2,
1930  class FreeArg1, class FreeArg2, class FreeArg3>
1931 class CallbackArg2_const_ <unref, T, BoundArg1, BoundArg2, TypeTuple<FreeArg1, FreeArg2, FreeArg3> >:
1932  public CallbackArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> > {
1933 public:
1934  typedef void (T::* MemFunc)(BoundArg1, BoundArg2, FreeArg1, FreeArg2, FreeArg3) const;
1935 private:
1936  const T* obj;
1937  MemFunc func;
1940 public:
1941  void dispatch(typename Cgu::Param<FreeArg1>::ParamType free_arg1,
1942  typename Cgu::Param<FreeArg2>::ParamType free_arg2,
1943  typename Cgu::Param<FreeArg3>::ParamType free_arg3) const {
1944  (obj->*func)(arg1, arg2, free_arg1, free_arg2, free_arg3);
1945  }
1946  CallbackArg2_const_(const T& obj_, MemFunc func_,
1947  typename Cgu::Param<BoundArg1>::ParamType arg1_,
1948  typename Cgu::Param<BoundArg2>::ParamType arg2_): obj(&obj_), func(func_), arg1(arg1_), arg2(arg2_) {}
1949 };
1950 
1951 #endif // DOXYGEN_PARSING
1952 
1953 /* for static class methods and non-class functions */
1954 
1956 public:
1957  typedef void (*Func)();
1958 private:
1959  Func func;
1960 public:
1961  void dispatch() const {func();}
1962  Callback0_static(Func func_): func(func_) {}
1963 };
1964 
1965 template <class FreeArg>
1966 class CallbackArg0_static: public CallbackArg<FreeArg> {
1967 public:
1968  typedef void (*Func)(FreeArg);
1969 private:
1970  Func func;
1971 public:
1972  void dispatch(typename Cgu::Param<FreeArg>::ParamType free_arg) const {
1973  func(free_arg);
1974  }
1975  CallbackArg0_static(Func func_): func(func_) {}
1976 };
1977 
1978 #ifndef DOXYGEN_PARSING
1979 
1980 template <class FreeArg1, class FreeArg2>
1981 class CallbackArg0_static<TypeTuple<FreeArg1, FreeArg2> >:
1982  public CallbackArg<TypeTuple<FreeArg1, FreeArg2> > {
1983 public:
1984  typedef void (*Func)(FreeArg1, FreeArg2);
1985 private:
1986  Func func;
1987 public:
1988  void dispatch(typename Cgu::Param<FreeArg1>::ParamType free_arg1,
1989  typename Cgu::Param<FreeArg2>::ParamType free_arg2) const {
1990  func(free_arg1, free_arg2);
1991  }
1992  CallbackArg0_static(Func func_): func(func_) {}
1993 };
1994 
1995 template <class FreeArg1, class FreeArg2, class FreeArg3>
1996 class CallbackArg0_static<TypeTuple<FreeArg1, FreeArg2, FreeArg3> >:
1997  public CallbackArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> > {
1998 public:
1999  typedef void (*Func)(FreeArg1, FreeArg2, FreeArg3);
2000 private:
2001  Func func;
2002 public:
2003  void dispatch(typename Cgu::Param<FreeArg1>::ParamType free_arg1,
2004  typename Cgu::Param<FreeArg2>::ParamType free_arg2,
2005  typename Cgu::Param<FreeArg3>::ParamType free_arg3) const {
2006  func(free_arg1, free_arg2, free_arg3);
2007  }
2008  CallbackArg0_static(Func func_): func(func_) {}
2009 };
2010 
2011 #endif // DOXYGEN_PARSING
2012 
2013 template <bool unref, class BoundArg>
2015 public:
2016  typedef void (*Func)(BoundArg);
2017 private:
2018  Func func;
2020 public:
2021  void dispatch() const {func(arg);}
2022  Callback1_static_(Func func_, typename Cgu::Param<BoundArg>::ParamType arg_): func(func_), arg(arg_) {}
2023 };
2024 
2025 template <bool unref, class BoundArg, class FreeArg>
2026 class CallbackArg1_static_: public CallbackArg<FreeArg> {
2027 public:
2028  typedef void (*Func)(BoundArg, FreeArg);
2029 private:
2030  Func func;
2032 public:
2033  void dispatch(typename Cgu::Param<FreeArg>::ParamType free_arg) const {
2034  func(arg, free_arg);
2035  }
2036  CallbackArg1_static_(Func func_, typename Cgu::Param<BoundArg>::ParamType arg_): func(func_), arg(arg_) {}
2037 };
2038 
2039 #ifndef DOXYGEN_PARSING
2040 
2041 template <bool unref, class BoundArg, class FreeArg1, class FreeArg2>
2042 class CallbackArg1_static_ <unref, BoundArg, TypeTuple<FreeArg1, FreeArg2> >:
2043  public CallbackArg<TypeTuple<FreeArg1, FreeArg2> > {
2044 public:
2045  typedef void (*Func)(BoundArg, FreeArg1, FreeArg2);
2046 private:
2047  Func func;
2049 public:
2050  void dispatch(typename Cgu::Param<FreeArg1>::ParamType free_arg1,
2051  typename Cgu::Param<FreeArg2>::ParamType free_arg2) const {
2052  func(arg, free_arg1, free_arg2);
2053  }
2054  CallbackArg1_static_(Func func_, typename Cgu::Param<BoundArg>::ParamType arg_): func(func_), arg(arg_) {}
2055 };
2056 
2057 template <bool unref, class BoundArg, class FreeArg1, class FreeArg2, class FreeArg3>
2058 class CallbackArg1_static_ <unref, BoundArg, TypeTuple<FreeArg1, FreeArg2, FreeArg3> >:
2059  public CallbackArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> > {
2060 public:
2061  typedef void (*Func)(BoundArg, FreeArg1, FreeArg2, FreeArg3);
2062 private:
2063  Func func;
2065 public:
2066  void dispatch(typename Cgu::Param<FreeArg1>::ParamType free_arg1,
2067  typename Cgu::Param<FreeArg2>::ParamType free_arg2,
2068  typename Cgu::Param<FreeArg3>::ParamType free_arg3) const {
2069  func(arg, free_arg1, free_arg2, free_arg3);
2070  }
2071  CallbackArg1_static_(Func func_, typename Cgu::Param<BoundArg>::ParamType arg_): func(func_), arg(arg_) {}
2072 };
2073 
2074 #endif // DOXYGEN_PARSING
2075 
2076 template <bool unref, class BoundArg1, class BoundArg2>
2078 public:
2079  typedef void (*Func)(BoundArg1, BoundArg2);
2080 private:
2081  Func func;
2084 public:
2085  void dispatch() const {func(arg1, arg2);}
2087  typename Cgu::Param<BoundArg2>::ParamType arg2_): func(func_), arg1(arg1_), arg2(arg2_) {}
2088 };
2089 
2090 template <bool unref, class BoundArg1, class BoundArg2, class FreeArg>
2091 class CallbackArg2_static_: public CallbackArg<FreeArg> {
2092 public:
2093  typedef void (*Func)(BoundArg1, BoundArg2, FreeArg);
2094 private:
2095  Func func;
2098 public:
2099  void dispatch(typename Cgu::Param<FreeArg>::ParamType free_arg) const {
2100  func(arg1, arg2, free_arg);
2101  }
2103  typename Cgu::Param<BoundArg2>::ParamType arg2_): func(func_), arg1(arg1_), arg2(arg2_) {}
2104 };
2105 
2106 #ifndef DOXYGEN_PARSING
2107 
2108 template <bool unref, class BoundArg1, class BoundArg2, class FreeArg1, class FreeArg2>
2109 class CallbackArg2_static_ <unref, BoundArg1, BoundArg2, TypeTuple<FreeArg1, FreeArg2> >:
2110  public CallbackArg<TypeTuple<FreeArg1, FreeArg2> > {
2111 public:
2112  typedef void (*Func)(BoundArg1, BoundArg2, FreeArg1, FreeArg2);
2113 private:
2114  Func func;
2117 public:
2118  void dispatch(typename Cgu::Param<FreeArg1>::ParamType free_arg1,
2119  typename Cgu::Param<FreeArg2>::ParamType free_arg2) const {
2120  func(arg1, arg2, free_arg1, free_arg2);
2121  }
2123  typename Cgu::Param<BoundArg2>::ParamType arg2_): func(func_), arg1(arg1_), arg2(arg2_) {}
2124 };
2125 
2126 template <bool unref, class BoundArg1, class BoundArg2, class FreeArg1, class FreeArg2, class FreeArg3>
2127 class CallbackArg2_static_ <unref, BoundArg1, BoundArg2, TypeTuple<FreeArg1, FreeArg2, FreeArg3> >:
2128  public CallbackArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> > {
2129 public:
2130  typedef void (*Func)(BoundArg1, BoundArg2, FreeArg1, FreeArg2, FreeArg3);
2131 private:
2132  Func func;
2135 public:
2136  void dispatch(typename Cgu::Param<FreeArg1>::ParamType free_arg1,
2137  typename Cgu::Param<FreeArg2>::ParamType free_arg2,
2138  typename Cgu::Param<FreeArg3>::ParamType free_arg3) const {
2139  func(arg1, arg2, free_arg1, free_arg2, free_arg3);
2140  }
2142  typename Cgu::Param<BoundArg2>::ParamType arg2_): func(func_), arg1(arg1_), arg2(arg2_) {}
2143 };
2144 
2145 #endif // DOXYGEN_PARSING
2146 
2147 #ifndef DOXYGEN_PARSING
2148 // TODO - remove on API break
2149 // these are for API compatibility only (they are not necessary
2150 // for ABI compatibility as the library produces these only by
2151 // base pointer, but a user may have instantiated them by hand
2152 // in user code)
2153 
2154 template <class T, class BoundArg>
2155 struct Callback1: public Callback1_<false, T, BoundArg> {
2156  typedef void (T::* MemFunc)(BoundArg);
2157  Callback1(T& obj, MemFunc func, typename Cgu::Param<BoundArg>::ParamType arg):
2158  Callback1_<false, T, BoundArg>(obj, func, arg) {}
2159 };
2160 
2161 template <class T, class BoundArg, class FreeArg>
2162 struct CallbackArg1: public CallbackArg1_<false, T, BoundArg, FreeArg> {
2163  typedef void (T::* MemFunc)(BoundArg, FreeArg);
2164  CallbackArg1(T& obj, MemFunc func, typename Cgu::Param<BoundArg>::ParamType arg):
2165  CallbackArg1_<false, T, BoundArg, FreeArg>(obj, func, arg) {}
2166 };
2167 
2168 template <class T, class BoundArg, class FreeArg1, class FreeArg2>
2169 struct CallbackArg1<T, BoundArg, TypeTuple<FreeArg1, FreeArg2> >:
2170  public CallbackArg1_ <false, T, BoundArg, TypeTuple<FreeArg1, FreeArg2> > {
2171  typedef void (T::* MemFunc)(BoundArg, FreeArg1, FreeArg2);
2172  CallbackArg1(T& obj, MemFunc func, typename Cgu::Param<BoundArg>::ParamType arg):
2173  CallbackArg1_<false, T, BoundArg, TypeTuple<FreeArg1, FreeArg2> >(obj, func, arg) {}
2174 };
2175 
2176 template <class T, class BoundArg, class FreeArg1, class FreeArg2, class FreeArg3>
2177 struct CallbackArg1<T, BoundArg, TypeTuple<FreeArg1, FreeArg2, FreeArg3> >:
2178  public CallbackArg1_ <false, T, BoundArg, TypeTuple<FreeArg1, FreeArg2, FreeArg3> > {
2179  typedef void (T::* MemFunc)(BoundArg, FreeArg1, FreeArg2, FreeArg3);
2180  CallbackArg1(T& obj, MemFunc func, typename Cgu::Param<BoundArg>::ParamType arg):
2181  CallbackArg1_<false, T, BoundArg, TypeTuple<FreeArg1, FreeArg2, FreeArg3> >(obj, func, arg) {}
2182 };
2183 
2184 template <class T, class BoundArg1, class BoundArg2>
2185 struct Callback2: public Callback2_<false, T, BoundArg1, BoundArg2> {
2186  typedef void (T::* MemFunc)(BoundArg1, BoundArg2);
2187  Callback2(T& obj, MemFunc func,
2188  typename Cgu::Param<BoundArg1>::ParamType arg1,
2189  typename Cgu::Param<BoundArg2>::ParamType arg2):
2190  Callback2_<false, T, BoundArg1, BoundArg2>(obj, func, arg1, arg2) {}
2191 };
2192 
2193 template <class T, class BoundArg1, class BoundArg2, class FreeArg>
2194 struct CallbackArg2: public CallbackArg2_<false, T, BoundArg1, BoundArg2, FreeArg> {
2195  typedef void (T::* MemFunc)(BoundArg1, BoundArg2, FreeArg);
2196  CallbackArg2(T& obj, MemFunc func,
2197  typename Cgu::Param<BoundArg1>::ParamType arg1,
2198  typename Cgu::Param<BoundArg2>::ParamType arg2):
2199  CallbackArg2_<false, T, BoundArg1, BoundArg2, FreeArg>(obj, func, arg1, arg2) {}
2200 };
2201 
2202 template <class T, class BoundArg1, class BoundArg2, class FreeArg1, class FreeArg2>
2203 struct CallbackArg2<T, BoundArg1, BoundArg2, TypeTuple<FreeArg1, FreeArg2> >:
2204  public CallbackArg2_ <false, T, BoundArg1, BoundArg2, TypeTuple<FreeArg1, FreeArg2> > {
2205  typedef void (T::* MemFunc)(BoundArg1, BoundArg2, FreeArg1, FreeArg2);
2206  CallbackArg2(T& obj, MemFunc func,
2207  typename Cgu::Param<BoundArg1>::ParamType arg1,
2208  typename Cgu::Param<BoundArg2>::ParamType arg2):
2209  CallbackArg2_<false, T, BoundArg1, BoundArg2, TypeTuple<FreeArg1, FreeArg2> >(obj, func, arg1, arg2) {}
2210 };
2211 
2212 template <class T, class BoundArg1, class BoundArg2, class FreeArg1, class FreeArg2, class FreeArg3>
2213 struct CallbackArg2<T, BoundArg1, BoundArg2, TypeTuple<FreeArg1, FreeArg2, FreeArg3> >:
2214  public CallbackArg2_ <false, T, BoundArg1, BoundArg2, TypeTuple<FreeArg1, FreeArg2, FreeArg3> > {
2215  typedef void (T::* MemFunc)(BoundArg1, BoundArg2, FreeArg1, FreeArg2, FreeArg3);
2216  CallbackArg2(T& obj, MemFunc func,
2217  typename Cgu::Param<BoundArg1>::ParamType arg1,
2218  typename Cgu::Param<BoundArg2>::ParamType arg2):
2219  CallbackArg2_<false, T, BoundArg1, BoundArg2, TypeTuple<FreeArg1, FreeArg2, FreeArg3> >(obj, func, arg1, arg2) {}
2220 };
2221 
2222 template <class T, class BoundArg>
2223 struct Callback1_const: public Callback1_const_<false, T, BoundArg> {
2224  typedef void (T::* MemFunc)(BoundArg) const;
2225  Callback1_const(const T& obj, MemFunc func, typename Cgu::Param<BoundArg>::ParamType arg):
2226  Callback1_const_<false, T, BoundArg>(obj, func, arg) {}
2227 };
2228 
2229 template <class T, class BoundArg, class FreeArg>
2230 struct CallbackArg1_const: public CallbackArg1_const_<false, T, BoundArg, FreeArg> {
2231  typedef void (T::* MemFunc)(BoundArg, FreeArg) const;
2232  CallbackArg1_const(const T& obj, MemFunc func, typename Cgu::Param<BoundArg>::ParamType arg):
2233  CallbackArg1_const_<false, T, BoundArg, FreeArg>(obj, func, arg) {}
2234 };
2235 
2236 template <class T, class BoundArg, class FreeArg1, class FreeArg2>
2237 struct CallbackArg1_const<T, BoundArg, TypeTuple<FreeArg1, FreeArg2> >:
2238  public CallbackArg1_const_ <false, T, BoundArg, TypeTuple<FreeArg1, FreeArg2> > {
2239  typedef void (T::* MemFunc)(BoundArg, FreeArg1, FreeArg2) const;
2240  CallbackArg1_const(const T& obj, MemFunc func, typename Cgu::Param<BoundArg>::ParamType arg):
2241  CallbackArg1_const_<false, T, BoundArg, TypeTuple<FreeArg1, FreeArg2> >(obj, func, arg) {}
2242 };
2243 
2244 template <class T, class BoundArg, class FreeArg1, class FreeArg2, class FreeArg3>
2245 struct CallbackArg1_const<T, BoundArg, TypeTuple<FreeArg1, FreeArg2, FreeArg3> >:
2246  public CallbackArg1_const_ <false, T, BoundArg, TypeTuple<FreeArg1, FreeArg2, FreeArg3> > {
2247  typedef void (T::* MemFunc)(BoundArg, FreeArg1, FreeArg2, FreeArg3) const;
2248  CallbackArg1_const(const T& obj, MemFunc func, typename Cgu::Param<BoundArg>::ParamType arg):
2249  CallbackArg1_const_<false, T, BoundArg, TypeTuple<FreeArg1, FreeArg2, FreeArg3> >(obj, func, arg) {}
2250 };
2251 
2252 template <class T, class BoundArg1, class BoundArg2>
2253 struct Callback2_const: public Callback2_const_<false, T, BoundArg1, BoundArg2> {
2254  typedef void (T::* MemFunc)(BoundArg1, BoundArg2) const;
2255  Callback2_const(const T& obj, MemFunc func,
2256  typename Cgu::Param<BoundArg1>::ParamType arg1,
2257  typename Cgu::Param<BoundArg2>::ParamType arg2):
2258  Callback2_const_<false, T, BoundArg1, BoundArg2>(obj, func, arg1, arg2) {}
2259 };
2260 
2261 template <class T, class BoundArg1, class BoundArg2, class FreeArg>
2262 struct CallbackArg2_const: public CallbackArg2_const_<false, T, BoundArg1, BoundArg2, FreeArg> {
2263  typedef void (T::* MemFunc)(BoundArg1, BoundArg2, FreeArg) const;
2264  CallbackArg2_const(const T& obj, MemFunc func,
2265  typename Cgu::Param<BoundArg1>::ParamType arg1,
2266  typename Cgu::Param<BoundArg2>::ParamType arg2):
2267  CallbackArg2_const_<false, T, BoundArg1, BoundArg2, FreeArg>(obj, func, arg1, arg2) {}
2268 };
2269 
2270 template <class T, class BoundArg1, class BoundArg2, class FreeArg1, class FreeArg2>
2271 struct CallbackArg2_const<T, BoundArg1, BoundArg2, TypeTuple<FreeArg1, FreeArg2> >:
2272  public CallbackArg2_const_ <false, T, BoundArg1, BoundArg2, TypeTuple<FreeArg1, FreeArg2> > {
2273  typedef void (T::* MemFunc)(BoundArg1, BoundArg2, FreeArg1, FreeArg2) const;
2274  CallbackArg2_const(const T& obj, MemFunc func,
2275  typename Cgu::Param<BoundArg1>::ParamType arg1,
2276  typename Cgu::Param<BoundArg2>::ParamType arg2):
2277  CallbackArg2_const_<false, T, BoundArg1, BoundArg2, TypeTuple<FreeArg1, FreeArg2> >(obj, func, arg1, arg2) {}
2278 };
2279 
2280 template <class T, class BoundArg1, class BoundArg2, class FreeArg1, class FreeArg2, class FreeArg3>
2281 struct CallbackArg2_const<T, BoundArg1, BoundArg2, TypeTuple<FreeArg1, FreeArg2, FreeArg3> >:
2282  public CallbackArg2_const_ <false, T, BoundArg1, BoundArg2, TypeTuple<FreeArg1, FreeArg2, FreeArg3> > {
2283  typedef void (T::* MemFunc)(BoundArg1, BoundArg2, FreeArg1, FreeArg2, FreeArg3) const;
2284  CallbackArg2_const(const T& obj, MemFunc func,
2285  typename Cgu::Param<BoundArg1>::ParamType arg1,
2286  typename Cgu::Param<BoundArg2>::ParamType arg2):
2287  CallbackArg2_const_<false, T, BoundArg1, BoundArg2, TypeTuple<FreeArg1, FreeArg2, FreeArg3> >(obj, func, arg1, arg2) {}
2288 };
2289 
2290 template <class BoundArg>
2291 struct Callback1_static: public Callback1_static_<false, BoundArg> {
2292  typedef void (*Func)(BoundArg);
2293  Callback1_static(Func func, typename Cgu::Param<BoundArg>::ParamType arg):
2294  Callback1_static_<false, BoundArg>(func, arg) {}
2295 };
2296 
2297 template <class BoundArg, class FreeArg>
2298 struct CallbackArg1_static: public CallbackArg1_static_<false, BoundArg, FreeArg> {
2299  typedef void (*Func)(BoundArg, FreeArg);
2300  CallbackArg1_static(Func func, typename Cgu::Param<BoundArg>::ParamType arg):
2301  CallbackArg1_static_<false, BoundArg, FreeArg>(func, arg) {}
2302 };
2303 
2304 template <class BoundArg, class FreeArg1, class FreeArg2>
2305 struct CallbackArg1_static<BoundArg, TypeTuple<FreeArg1, FreeArg2> >:
2306  public CallbackArg1_static_ <false, BoundArg, TypeTuple<FreeArg1, FreeArg2> > {
2307  typedef void (*Func)(BoundArg, FreeArg1, FreeArg2);
2308  CallbackArg1_static(Func func, typename Cgu::Param<BoundArg>::ParamType arg):
2309  CallbackArg1_static_<false, BoundArg, TypeTuple<FreeArg1, FreeArg2> >(func, arg) {}
2310 };
2311 
2312 template <class BoundArg, class FreeArg1, class FreeArg2, class FreeArg3>
2313 struct CallbackArg1_static<BoundArg, TypeTuple<FreeArg1, FreeArg2, FreeArg3> >:
2314  public CallbackArg1_static_ <false, BoundArg, TypeTuple<FreeArg1, FreeArg2, FreeArg3> > {
2315  typedef void (*Func)(BoundArg, FreeArg1, FreeArg2, FreeArg3);
2316  CallbackArg1_static(Func func, typename Cgu::Param<BoundArg>::ParamType arg):
2317  CallbackArg1_static_<false, BoundArg, TypeTuple<FreeArg1, FreeArg2, FreeArg3> >(func, arg) {}
2318 };
2319 
2320 template <class BoundArg1, class BoundArg2>
2321 struct Callback2_static: public Callback2_static_<false, BoundArg1, BoundArg2> {
2322  typedef void (*Func)(BoundArg1, BoundArg2);
2323  Callback2_static(Func func,
2324  typename Cgu::Param<BoundArg1>::ParamType arg1,
2325  typename Cgu::Param<BoundArg2>::ParamType arg2):
2326  Callback2_static_<false, BoundArg1, BoundArg2>(func, arg1, arg2) {}
2327 };
2328 
2329 template <class BoundArg1, class BoundArg2, class FreeArg>
2330 struct CallbackArg2_static: public CallbackArg2_static_<false, BoundArg1, BoundArg2, FreeArg> {
2331  typedef void (*Func)(BoundArg1, BoundArg2, FreeArg);
2332  CallbackArg2_static(Func func,
2333  typename Cgu::Param<BoundArg1>::ParamType arg1,
2334  typename Cgu::Param<BoundArg2>::ParamType arg2):
2335  CallbackArg2_static_<false, BoundArg1, BoundArg2, FreeArg>(func, arg1, arg2) {}
2336 };
2337 
2338 template <class BoundArg1, class BoundArg2, class FreeArg1, class FreeArg2>
2339 struct CallbackArg2_static<BoundArg1, BoundArg2, TypeTuple<FreeArg1, FreeArg2> >:
2340  public CallbackArg2_static_ <false, BoundArg1, BoundArg2, TypeTuple<FreeArg1, FreeArg2> > {
2341  typedef void (*Func)(BoundArg1, BoundArg2, FreeArg1, FreeArg2);
2342  CallbackArg2_static(Func func,
2343  typename Cgu::Param<BoundArg1>::ParamType arg1,
2344  typename Cgu::Param<BoundArg2>::ParamType arg2):
2345  CallbackArg2_static_<false, BoundArg1, BoundArg2, TypeTuple<FreeArg1, FreeArg2> >(func, arg1, arg2) {}
2346 };
2347 
2348 template <class BoundArg1, class BoundArg2, class FreeArg1, class FreeArg2, class FreeArg3>
2349 struct CallbackArg2_static<BoundArg1, BoundArg2, TypeTuple<FreeArg1, FreeArg2, FreeArg3> >:
2350  public CallbackArg2_static_ <false, BoundArg1, BoundArg2, TypeTuple<FreeArg1, FreeArg2, FreeArg3> > {
2351  typedef void (*Func)(BoundArg1, BoundArg2, FreeArg1, FreeArg2, FreeArg3);
2352  CallbackArg2_static(Func func,
2353  typename Cgu::Param<BoundArg1>::ParamType arg1,
2354  typename Cgu::Param<BoundArg2>::ParamType arg2):
2355  CallbackArg2_static_<false, BoundArg1, BoundArg2, TypeTuple<FreeArg1, FreeArg2, FreeArg3> >(func, arg1, arg2) {}
2356 };
2357 
2358 #endif
2359 
2360 /* Convenience functions making callback objects on freestore. These
2361  * can for example be passed as the first argument of the
2362  * Thread::start() method in thread.h. They are also used by the
2363  * Callback::post() function.
2364 */
2365 
2366 /**
2367  * A convenience function to make Callback::CallbackArg objects
2368  * @exception std::bad_alloc It might throw std::bad_alloc if memory
2369  * is exhausted and the system throws in that case. This exception
2370  * will not be thrown if the library has been installed using the
2371  * \--with-glib-memory-slices-no-compat configuration option (instead
2372  * glib will terminate the program if it is unable to obtain memory
2373  * from the operating system).
2374  */
2375 template <class T>
2377  void (T::*func)()) {
2378  return new Callback0<T>(t, func);
2379 }
2380 
2381 /**
2382  * DEPRECATED.
2383  *
2384  * Since this function constructs a callback which does not take a
2385  * bound argument, it is a synonym for make() (the two are identical).
2386  * @exception std::bad_alloc It might throw std::bad_alloc if memory
2387  * is exhausted and the system throws in that case. This exception
2388  * will not be thrown if the library has been installed using the
2389  * \--with-glib-memory-slices-no-compat configuration option (instead
2390  * glib will terminate the program if it is unable to obtain memory
2391  * from the operating system).
2392  *
2393  * Since 1.2.8
2394  */
2395 template <class T>
2397  void (T::*func)()) {
2398  return new Callback0<T>(t, func);
2399 }
2400 
2401 /**
2402  * Since this function constructs a callback which does not take a
2403  * bound argument, it is a synonym for make() (the two are identical).
2404  * @exception std::bad_alloc It might throw std::bad_alloc if memory
2405  * is exhausted and the system throws in that case. This exception
2406  * will not be thrown if the library has been installed using the
2407  * \--with-glib-memory-slices-no-compat configuration option (instead
2408  * glib will terminate the program if it is unable to obtain memory
2409  * from the operating system).
2410  *
2411  * Since 1.2.13
2412  */
2413 template <class T>
2415  void (T::*func)()) {
2416  return new Callback0<T>(t, func);
2417 }
2418 
2419 /**
2420  * A convenience function to make Callback::CallbackArg objects
2421  * @exception std::bad_alloc It might throw std::bad_alloc if memory
2422  * is exhausted and the system throws in that case. This exception
2423  * will not be thrown if the library has been installed using the
2424  * \--with-glib-memory-slices-no-compat configuration option (instead
2425  * glib will terminate the program if it is unable to obtain memory
2426  * from the operating system).
2427  */
2428 template <class T, class FreeArg>
2430  void (T::*func)(FreeArg)) {
2431  return new CallbackArg0<T, FreeArg>(t, func);
2432 }
2433 
2434 /**
2435  * DEPRECATED.
2436  *
2437  * Since this function constructs a callback which does not take a
2438  * bound argument, it is a synonym for make() (the two are identical).
2439  * @exception std::bad_alloc It might throw std::bad_alloc if memory
2440  * is exhausted and the system throws in that case. This exception
2441  * will not be thrown if the library has been installed using the
2442  * \--with-glib-memory-slices-no-compat configuration option (instead
2443  * glib will terminate the program if it is unable to obtain memory
2444  * from the operating system).
2445  *
2446  * Since 1.2.8
2447  */
2448 template <class T, class FreeArg>
2450  void (T::*func)(FreeArg)) {
2451  return new CallbackArg0<T, FreeArg>(t, func);
2452 }
2453 
2454 /**
2455  * Since this function constructs a callback which does not take a
2456  * bound argument, it is a synonym for make() (the two are identical).
2457  * @exception std::bad_alloc It might throw std::bad_alloc if memory
2458  * is exhausted and the system throws in that case. This exception
2459  * will not be thrown if the library has been installed using the
2460  * \--with-glib-memory-slices-no-compat configuration option (instead
2461  * glib will terminate the program if it is unable to obtain memory
2462  * from the operating system).
2463  *
2464  * Since 1.2.13
2465  */
2466 template <class T, class FreeArg>
2468  void (T::*func)(FreeArg)) {
2469  return new CallbackArg0<T, FreeArg>(t, func);
2470 }
2471 
2472 #if defined(CGU_USE_TYPE_TUPLE_ARGS) || defined(DOXYGEN_PARSING)
2473 /**
2474  * A convenience function to make Callback::CallbackArg objects
2475  * @exception std::bad_alloc It might throw std::bad_alloc if memory
2476  * is exhausted and the system throws in that case. This exception
2477  * will not be thrown if the library has been installed using the
2478  * \--with-glib-memory-slices-no-compat configuration option (instead
2479  * glib will terminate the program if it is unable to obtain memory
2480  * from the operating system).
2481  *
2482  * Since 1.2.10
2483  */
2484 template <class T, class FreeArg1, class FreeArg2>
2486  void (T::*func)(FreeArg1, FreeArg2)) {
2487  return new CallbackArg0<T, TypeTuple<FreeArg1, FreeArg2> >(t, func);
2488 }
2489 
2490 /**
2491  * DEPRECATED.
2492  *
2493  * Since this function constructs a callback which does not take a
2494  * bound argument, it is a synonym for make() (the two are identical).
2495  * @exception std::bad_alloc It might throw std::bad_alloc if memory
2496  * is exhausted and the system throws in that case. This exception
2497  * will not be thrown if the library has been installed using the
2498  * \--with-glib-memory-slices-no-compat configuration option (instead
2499  * glib will terminate the program if it is unable to obtain memory
2500  * from the operating system).
2501  *
2502  * Since 1.2.10
2503  */
2504 template <class T, class FreeArg1, class FreeArg2>
2506  void (T::*func)(FreeArg1, FreeArg2)) {
2507  return new CallbackArg0<T, TypeTuple<FreeArg1, FreeArg2> >(t, func);
2508 }
2509 
2510 /**
2511  * Since this function constructs a callback which does not take a
2512  * bound argument, it is a synonym for make() (the two are identical).
2513  * @exception std::bad_alloc It might throw std::bad_alloc if memory
2514  * is exhausted and the system throws in that case. This exception
2515  * will not be thrown if the library has been installed using the
2516  * \--with-glib-memory-slices-no-compat configuration option (instead
2517  * glib will terminate the program if it is unable to obtain memory
2518  * from the operating system).
2519  *
2520  * Since 1.2.13
2521  */
2522 template <class T, class FreeArg1, class FreeArg2>
2524  void (T::*func)(FreeArg1, FreeArg2)) {
2525  return new CallbackArg0<T, TypeTuple<FreeArg1, FreeArg2> >(t, func);
2526 }
2527 
2528 /**
2529  * A convenience function to make Callback::CallbackArg objects
2530  * @exception std::bad_alloc It might throw std::bad_alloc if memory
2531  * is exhausted and the system throws in that case. This exception
2532  * will not be thrown if the library has been installed using the
2533  * \--with-glib-memory-slices-no-compat configuration option (instead
2534  * glib will terminate the program if it is unable to obtain memory
2535  * from the operating system).
2536  *
2537  * Since 1.2.10
2538  */
2539 template <class T, class FreeArg1, class FreeArg2, class FreeArg3>
2541  void (T::*func)(FreeArg1, FreeArg2, FreeArg3)) {
2543 }
2544 
2545 /**
2546  * DEPRECATED.
2547  *
2548  * Since this function constructs a callback which does not take a
2549  * bound argument, it is a synonym for make() (the two are identical).
2550  * @exception std::bad_alloc It might throw std::bad_alloc if memory
2551  * is exhausted and the system throws in that case. This exception
2552  * will not be thrown if the library has been installed using the
2553  * \--with-glib-memory-slices-no-compat configuration option (instead
2554  * glib will terminate the program if it is unable to obtain memory
2555  * from the operating system).
2556  *
2557  * Since 1.2.10
2558  */
2559 template <class T, class FreeArg1, class FreeArg2, class FreeArg3>
2561  void (T::*func)(FreeArg1, FreeArg2, FreeArg3)) {
2563 }
2564 /**
2565  * Since this function constructs a callback which does not take a
2566  * bound argument, it is a synonym for make() (the two are identical).
2567  * @exception std::bad_alloc It might throw std::bad_alloc if memory
2568  * is exhausted and the system throws in that case. This exception
2569  * will not be thrown if the library has been installed using the
2570  * \--with-glib-memory-slices-no-compat configuration option (instead
2571  * glib will terminate the program if it is unable to obtain memory
2572  * from the operating system).
2573  *
2574  * Since 1.2.13
2575  */
2576 template <class T, class FreeArg1, class FreeArg2, class FreeArg3>
2578  void (T::*func)(FreeArg1, FreeArg2, FreeArg3)) {
2580 }
2581 #endif // CGU_USE_TYPE_TUPLE_ARGS
2582 
2583 /**
2584  * A convenience function to make Callback::CallbackArg objects
2585  * @exception std::bad_alloc It might throw std::bad_alloc if memory
2586  * is exhausted and the system throws in that case (this exception
2587  * will not be thrown if the library has been installed using the
2588  * \--with-glib-memory-slices-no-compat configuration option: instead
2589  * glib will terminate the program if it is unable to obtain memory
2590  * from the operating system). It will also throw if the copy
2591  * constructor of a bound argument throws and it is not a reference
2592  * argument.
2593  */
2594 template <class T, class BoundArg>
2596  void (T::*func)(BoundArg),
2597  BoundArg arg) {
2598  return new Callback1<T, BoundArg>(t, func, arg);
2599 }
2600 
2601 /**
2602  * DEPRECATED: use Callback::make_ref() instead.
2603  *
2604  * An alternative function to make Callback::CallbackArg objects,
2605  * which is for use where a target function receives an argument of
2606  * class type by value which is to be a bound argument, so the
2607  * compiler is not able to carry out copy elision when constructing
2608  * the callback object.
2609  * @exception std::bad_alloc It might throw std::bad_alloc if memory
2610  * is exhausted and the system throws in that case (this exception
2611  * will not be thrown if the library has been installed using the
2612  * \--with-glib-memory-slices-no-compat configuration option: instead
2613  * glib will terminate the program if it is unable to obtain memory
2614  * from the operating system). It will also throw if the copy
2615  * constructor of a bound argument throws and it is not a reference
2616  * argument.
2617  *
2618  * Since 1.2.8
2619  */
2620 template <class T, class BoundArg>
2622  void (T::*func)(BoundArg),
2623  const BoundArg& arg) {
2624  return new Callback1<T, BoundArg>(t, func, arg);
2625 }
2626 
2627 /**
2628  * An alternative function to make Callback::CallbackArg objects,
2629  * which is for use where a target function either receives a class
2630  * type bound argument by value, or receives a bound argument by
2631  * reference to const in a case where the generated CallbackArg object
2632  * is to store a copy of that argument instead of just keeping a
2633  * reference.
2634  * @exception std::bad_alloc It might throw std::bad_alloc if memory
2635  * is exhausted and the system throws in that case (this exception
2636  * will not be thrown if the library has been installed using the
2637  * \--with-glib-memory-slices-no-compat configuration option: instead
2638  * glib will terminate the program if it is unable to obtain memory
2639  * from the operating system). It will also throw if the copy
2640  * constructor of a bound argument throws.
2641  *
2642  * Since 1.2.13
2643  */
2644 template <class T, class BoundArg>
2646  void (T::*func)(BoundArg),
2647  typename Cgu::Param<BoundArg>::ParamType arg) {
2648  return new Callback1_<true, T, BoundArg>(t, func, arg);
2649 }
2650 
2651 /**
2652  * A convenience function to make Callback::CallbackArg objects
2653  * @exception std::bad_alloc It might throw std::bad_alloc if memory
2654  * is exhausted and the system throws in that case (this exception
2655  * will not be thrown if the library has been installed using the
2656  * \--with-glib-memory-slices-no-compat configuration option: instead
2657  * glib will terminate the program if it is unable to obtain memory
2658  * from the operating system). It will also throw if the copy
2659  * constructor of a bound argument throws and it is not a reference
2660  * argument.
2661  */
2662 template <class T, class BoundArg, class FreeArg>
2664  void (T::*func)(BoundArg, FreeArg),
2665  BoundArg arg) {
2666  return new CallbackArg1<T, BoundArg, FreeArg>(t, func, arg);
2667 }
2668 
2669 /**
2670  * DEPRECATED: use Callback::make_ref() instead.
2671  *
2672  * An alternative function to make Callback::CallbackArg objects,
2673  * which is for use where a target function receives an argument of
2674  * class type by value which is to be a bound argument, so the
2675  * compiler is not able to carry out copy elision when constructing
2676  * the callback object.
2677  * @exception std::bad_alloc It might throw std::bad_alloc if memory
2678  * is exhausted and the system throws in that case (this exception
2679  * will not be thrown if the library has been installed using the
2680  * \--with-glib-memory-slices-no-compat configuration option: instead
2681  * glib will terminate the program if it is unable to obtain memory
2682  * from the operating system). It will also throw if the copy
2683  * constructor of a bound argument throws and it is not a reference
2684  * argument.
2685  *
2686  * Since 1.2.8
2687  */
2688 template <class T, class BoundArg, class FreeArg>
2690  void (T::*func)(BoundArg, FreeArg),
2691  const BoundArg& arg) {
2692  return new CallbackArg1<T, BoundArg, FreeArg>(t, func, arg);
2693 }
2694 
2695 /**
2696  * An alternative function to make Callback::CallbackArg objects,
2697  * which is for use where a target function either receives a class
2698  * type bound argument by value, or receives a bound argument by
2699  * reference to const in a case where the generated CallbackArg object
2700  * is to store a copy of that argument instead of just keeping a
2701  * reference.
2702  * @exception std::bad_alloc It might throw std::bad_alloc if memory
2703  * is exhausted and the system throws in that case (this exception
2704  * will not be thrown if the library has been installed using the
2705  * \--with-glib-memory-slices-no-compat configuration option: instead
2706  * glib will terminate the program if it is unable to obtain memory
2707  * from the operating system). It will also throw if the copy
2708  * constructor of a bound argument throws.
2709  *
2710  * Since 1.2.13
2711  */
2712 template <class T, class BoundArg, class FreeArg>
2714  void (T::*func)(BoundArg, FreeArg),
2715  typename Cgu::Param<BoundArg>::ParamType arg) {
2716  return new CallbackArg1_<true, T, BoundArg, FreeArg>(t, func, arg);
2717 }
2718 
2719 #if defined(CGU_USE_TYPE_TUPLE_ARGS) || defined(DOXYGEN_PARSING)
2720 /**
2721  * A convenience function to make Callback::CallbackArg objects
2722  * @exception std::bad_alloc It might throw std::bad_alloc if memory
2723  * is exhausted and the system throws in that case. This exception
2724  * will not be thrown if the library has been installed using the
2725  * \--with-glib-memory-slices-no-compat configuration option (instead
2726  * glib will terminate the program if it is unable to obtain memory
2727  * from the operating system).
2728  *
2729  * Since 1.2.10
2730  */
2731 template <class T, class BoundArg, class FreeArg1, class FreeArg2>
2733  void (T::*func)(BoundArg, FreeArg1, FreeArg2),
2734  BoundArg arg) {
2735  return new CallbackArg1<T, BoundArg, TypeTuple<FreeArg1, FreeArg2> >(t, func, arg);
2736 }
2737 
2738 /**
2739  * DEPRECATED: use Callback::make_ref() instead.
2740  *
2741  * An alternative function to make Callback::CallbackArg objects,
2742  * which is for use where a target function receives an argument of
2743  * class type by value which is to be a bound argument, so the
2744  * compiler is not able to carry out copy elision when constructing
2745  * the callback object.
2746  * @exception std::bad_alloc It might throw std::bad_alloc if memory
2747  * is exhausted and the system throws in that case (this exception
2748  * will not be thrown if the library has been installed using the
2749  * \--with-glib-memory-slices-no-compat configuration option: instead
2750  * glib will terminate the program if it is unable to obtain memory
2751  * from the operating system). It will also throw if the copy
2752  * constructor of a bound argument throws and it is not a reference
2753  * argument.
2754  *
2755  * Since 1.2.10
2756  */
2757 template <class T, class BoundArg, class FreeArg1, class FreeArg2>
2759  void (T::*func)(BoundArg, FreeArg1, FreeArg2),
2760  const BoundArg& arg) {
2761  return new CallbackArg1<T, BoundArg, TypeTuple<FreeArg1, FreeArg2> >(t, func, arg);
2762 }
2763 
2764 /**
2765  * An alternative function to make Callback::CallbackArg objects,
2766  * which is for use where a target function either receives a class
2767  * type bound argument by value, or receives a bound argument by
2768  * reference to const in a case where the generated CallbackArg object
2769  * is to store a copy of that argument instead of just keeping a
2770  * reference.
2771  * @exception std::bad_alloc It might throw std::bad_alloc if memory
2772  * is exhausted and the system throws in that case (this exception
2773  * will not be thrown if the library has been installed using the
2774  * \--with-glib-memory-slices-no-compat configuration option: instead
2775  * glib will terminate the program if it is unable to obtain memory
2776  * from the operating system). It will also throw if the copy
2777  * constructor of a bound argument throws.
2778  *
2779  * Since 1.2.13
2780  */
2781 template <class T, class BoundArg, class FreeArg1, class FreeArg2>
2783  void (T::*func)(BoundArg, FreeArg1, FreeArg2),
2784  typename Cgu::Param<BoundArg>::ParamType arg) {
2786 }
2787 
2788 /**
2789  * A convenience function to make Callback::CallbackArg objects
2790  * @exception std::bad_alloc It might throw std::bad_alloc if memory
2791  * is exhausted and the system throws in that case. This exception
2792  * will not be thrown if the library has been installed using the
2793  * \--with-glib-memory-slices-no-compat configuration option (instead
2794  * glib will terminate the program if it is unable to obtain memory
2795  * from the operating system).
2796  *
2797  * Since 1.2.10
2798  */
2799 template <class T, class BoundArg, class FreeArg1, class FreeArg2, class FreeArg3>
2801  void (T::*func)(BoundArg, FreeArg1, FreeArg2, FreeArg3),
2802  BoundArg arg) {
2803  return new CallbackArg1<T, BoundArg, TypeTuple<FreeArg1, FreeArg2, FreeArg3> >(t, func, arg);
2804 }
2805 
2806 /**
2807  * DEPRECATED: use Callback::make_ref() instead.
2808  *
2809  * An alternative function to make Callback::CallbackArg objects,
2810  * which is for use where a target function receives an argument of
2811  * class type by value which is to be a bound argument, so the
2812  * compiler is not able to carry out copy elision when constructing
2813  * the callback object.
2814  * @exception std::bad_alloc It might throw std::bad_alloc if memory
2815  * is exhausted and the system throws in that case (this exception
2816  * will not be thrown if the library has been installed using the
2817  * \--with-glib-memory-slices-no-compat configuration option: instead
2818  * glib will terminate the program if it is unable to obtain memory
2819  * from the operating system). It will also throw if the copy
2820  * constructor of a bound argument throws and it is not a reference
2821  * argument.
2822  *
2823  * Since 1.2.10
2824  */
2825 template <class T, class BoundArg, class FreeArg1, class FreeArg2, class FreeArg3>
2827  void (T::*func)(BoundArg, FreeArg1, FreeArg2, FreeArg3),
2828  const BoundArg& arg) {
2829  return new CallbackArg1<T, BoundArg, TypeTuple<FreeArg1, FreeArg2, FreeArg3> >(t, func, arg);
2830 }
2831 #endif // CGU_USE_TYPE_TUPLE_ARGS
2832 
2833 /**
2834  * An alternative function to make Callback::CallbackArg objects,
2835  * which is for use where a target function either receives a class
2836  * type bound argument by value, or receives a bound argument by
2837  * reference to const in a case where the generated CallbackArg object
2838  * is to store a copy of that argument instead of just keeping a
2839  * reference.
2840  * @exception std::bad_alloc It might throw std::bad_alloc if memory
2841  * is exhausted and the system throws in that case (this exception
2842  * will not be thrown if the library has been installed using the
2843  * \--with-glib-memory-slices-no-compat configuration option: instead
2844  * glib will terminate the program if it is unable to obtain memory
2845  * from the operating system). It will also throw if the copy
2846  * constructor of a bound argument throws.
2847  *
2848  * Since 1.2.13
2849  */
2850 
2851 template <class T, class BoundArg, class FreeArg1, class FreeArg2, class FreeArg3>
2853  void (T::*func)(BoundArg, FreeArg1, FreeArg2, FreeArg3),
2854  typename Cgu::Param<BoundArg>::ParamType arg) {
2856 }
2857 
2858 /**
2859  * A convenience function to make Callback::CallbackArg objects
2860  * @exception std::bad_alloc It might throw std::bad_alloc if memory
2861  * is exhausted and the system throws in that case (this exception
2862  * will not be thrown if the library has been installed using the
2863  * \--with-glib-memory-slices-no-compat configuration option: instead
2864  * glib will terminate the program if it is unable to obtain memory
2865  * from the operating system). It will also throw if the copy
2866  * constructor of a bound argument throws and it is not a reference
2867  * argument.
2868  */
2869 template <class T, class BoundArg1, class BoundArg2>
2871  void (T::*func)(BoundArg1, BoundArg2),
2872  BoundArg1 arg1,
2873  BoundArg2 arg2) {
2874  return new Callback2<T, BoundArg1, BoundArg2>(t, func, arg1, arg2);
2875 }
2876 
2877 /**
2878  * DEPRECATED: use Callback::make_ref() instead.
2879  *
2880  * An alternative function to make Callback::CallbackArg objects,
2881  * which is for use where a target function receives an argument of
2882  * class type by value which is to be a bound argument, so the
2883  * compiler is not able to carry out copy elision when constructing
2884  * the callback object.
2885  * @exception std::bad_alloc It might throw std::bad_alloc if memory
2886  * is exhausted and the system throws in that case (this exception
2887  * will not be thrown if the library has been installed using the
2888  * \--with-glib-memory-slices-no-compat configuration option: instead
2889  * glib will terminate the program if it is unable to obtain memory
2890  * from the operating system). It will also throw if the copy
2891  * constructor of a bound argument throws and it is not a reference
2892  * argument.
2893  *
2894  * Since 1.2.8
2895  */
2896 template <class T, class BoundArg1, class BoundArg2>
2898  void (T::*func)(BoundArg1, BoundArg2),
2899  const BoundArg1& arg1,
2900  const BoundArg2& arg2) {
2901  return new Callback2<T, BoundArg1, BoundArg2>(t, func, arg1, arg2);
2902 }
2903 
2904 /**
2905  * An alternative function to make Callback::CallbackArg objects,
2906  * which is for use where a target function either receives a class
2907  * type bound argument by value, or receives a bound argument by
2908  * reference to const in a case where the generated CallbackArg object
2909  * is to store a copy of that argument instead of just keeping a
2910  * reference.
2911  * @exception std::bad_alloc It might throw std::bad_alloc if memory
2912  * is exhausted and the system throws in that case (this exception
2913  * will not be thrown if the library has been installed using the
2914  * \--with-glib-memory-slices-no-compat configuration option: instead
2915  * glib will terminate the program if it is unable to obtain memory
2916  * from the operating system). It will also throw if the copy
2917  * constructor of a bound argument throws.
2918  *
2919  * Since 1.2.13
2920  */
2921 template <class T, class BoundArg1, class BoundArg2>
2923  void (T::*func)(BoundArg1, BoundArg2),
2924  typename Cgu::Param<BoundArg1>::ParamType arg1,
2925  typename Cgu::Param<BoundArg2>::ParamType arg2) {
2926  return new Callback2_<true, T, BoundArg1, BoundArg2>(t, func, arg1, arg2);
2927 }
2928 
2929 
2930 /**
2931  * A convenience function to make Callback::CallbackArg objects
2932  * @exception std::bad_alloc It might throw std::bad_alloc if memory
2933  * is exhausted and the system throws in that case (this exception
2934  * will not be thrown if the library has been installed using the
2935  * \--with-glib-memory-slices-no-compat configuration option: instead
2936  * glib will terminate the program if it is unable to obtain memory
2937  * from the operating system). It will also throw if the copy
2938  * constructor of a bound argument throws and it is not a reference
2939  * argument.
2940  */
2941 template <class T, class BoundArg1, class BoundArg2, class FreeArg>
2943  void (T::*func)(BoundArg1, BoundArg2, FreeArg),
2944  BoundArg1 arg1,
2945  BoundArg2 arg2) {
2946  return new CallbackArg2<T, BoundArg1, BoundArg2, FreeArg>(t, func, arg1, arg2);
2947 }
2948 
2949 /**
2950  * DEPRECATED: use Callback::make_ref() instead.
2951  *
2952  * An alternative function to make Callback::CallbackArg objects,
2953  * which is for use where a target function receives an argument of
2954  * class type by value which is to be a bound argument, so the
2955  * compiler is not able to carry out copy elision when constructing
2956  * the callback object.
2957  * @exception std::bad_alloc It might throw std::bad_alloc if memory
2958  * is exhausted and the system throws in that case (this exception
2959  * will not be thrown if the library has been installed using the
2960  * \--with-glib-memory-slices-no-compat configuration option: instead
2961  * glib will terminate the program if it is unable to obtain memory
2962  * from the operating system). It will also throw if the copy
2963  * constructor of a bound argument throws and it is not a reference
2964  * argument.
2965  *
2966  * Since 1.2.8
2967  */
2968 template <class T, class BoundArg1, class BoundArg2, class FreeArg>
2970  void (T::*func)(BoundArg1, BoundArg2, FreeArg),
2971  const BoundArg1& arg1,
2972  const BoundArg2& arg2) {
2973  return new CallbackArg2<T, BoundArg1, BoundArg2, FreeArg>(t, func, arg1, arg2);
2974 }
2975 
2976 /**
2977  * An alternative function to make Callback::CallbackArg objects,
2978  * which is for use where a target function either receives a class
2979  * type bound argument by value, or receives a bound argument by
2980  * reference to const in a case where the generated CallbackArg object
2981  * is to store a copy of that argument instead of just keeping a
2982  * reference.
2983  * @exception std::bad_alloc It might throw std::bad_alloc if memory
2984  * is exhausted and the system throws in that case (this exception
2985  * will not be thrown if the library has been installed using the
2986  * \--with-glib-memory-slices-no-compat configuration option: instead
2987  * glib will terminate the program if it is unable to obtain memory
2988  * from the operating system). It will also throw if the copy
2989  * constructor of a bound argument throws.
2990  *
2991  * Since 1.2.13
2992  */
2993 template <class T, class BoundArg1, class BoundArg2, class FreeArg>
2995  void (T::*func)(BoundArg1, BoundArg2, FreeArg),
2996  typename Cgu::Param<BoundArg1>::ParamType arg1,
2997  typename Cgu::Param<BoundArg2>::ParamType arg2) {
2998  return new CallbackArg2_<true, T, BoundArg1, BoundArg2, FreeArg>(t, func, arg1, arg2);
2999 }
3000 
3001 #if defined(CGU_USE_TYPE_TUPLE_ARGS) || defined(DOXYGEN_PARSING)
3002 /**
3003  * A convenience function to make Callback::CallbackArg objects
3004  * @exception std::bad_alloc It might throw std::bad_alloc if memory
3005  * is exhausted and the system throws in that case (this exception
3006  * will not be thrown if the library has been installed using the
3007  * \--with-glib-memory-slices-no-compat configuration option: instead
3008  * glib will terminate the program if it is unable to obtain memory
3009  * from the operating system). It will also throw if the copy
3010  * constructor of a bound argument throws and it is not a reference
3011  * argument.
3012  *
3013  * Since 1.2.10
3014  */
3015 template <class T, class BoundArg1, class BoundArg2, class FreeArg1, class FreeArg2>
3017  void (T::*func)(BoundArg1, BoundArg2, FreeArg1, FreeArg2),
3018  BoundArg1 arg1,
3019  BoundArg2 arg2) {
3020  return new CallbackArg2<T, BoundArg1, BoundArg2, TypeTuple<FreeArg1, FreeArg2> >(t, func, arg1, arg2);
3021 }
3022 
3023 /**
3024  * DEPRECATED: use Callback::make_ref() instead.
3025  *
3026  * An alternative function to make Callback::CallbackArg objects,
3027  * which is for use where a target function receives an argument of
3028  * class type by value which is to be a bound argument, so the
3029  * compiler is not able to carry out copy elision when constructing
3030  * the callback object.
3031  * @exception std::bad_alloc It might throw std::bad_alloc if memory
3032  * is exhausted and the system throws in that case (this exception
3033  * will not be thrown if the library has been installed using the
3034  * \--with-glib-memory-slices-no-compat configuration option: instead
3035  * glib will terminate the program if it is unable to obtain memory
3036  * from the operating system). It will also throw if the copy
3037  * constructor of a bound argument throws and it is not a reference
3038  * argument.
3039  *
3040  * Since 1.2.10
3041  */
3042 template <class T, class BoundArg1, class BoundArg2, class FreeArg1, class FreeArg2>
3044  void (T::*func)(BoundArg1, BoundArg2, FreeArg1, FreeArg2),
3045  const BoundArg1& arg1,
3046  const BoundArg2& arg2) {
3047  return new CallbackArg2<T, BoundArg1, BoundArg2, TypeTuple<FreeArg1, FreeArg2> >(t, func, arg1, arg2);
3048 }
3049 
3050 /**
3051  * An alternative function to make Callback::CallbackArg objects,
3052  * which is for use where a target function either receives a class
3053  * type bound argument by value, or receives a bound argument by
3054  * reference to const in a case where the generated CallbackArg object
3055  * is to store a copy of that argument instead of just keeping a
3056  * reference.
3057  * @exception std::bad_alloc It might throw std::bad_alloc if memory
3058  * is exhausted and the system throws in that case (this exception
3059  * will not be thrown if the library has been installed using the
3060  * \--with-glib-memory-slices-no-compat configuration option: instead
3061  * glib will terminate the program if it is unable to obtain memory
3062  * from the operating system). It will also throw if the copy
3063  * constructor of a bound argument throws.
3064  *
3065  * Since 1.2.13
3066  */
3067 template <class T, class BoundArg1, class BoundArg2, class FreeArg1, class FreeArg2>
3069  void (T::*func)(BoundArg1, BoundArg2, FreeArg1, FreeArg2),
3070  typename Cgu::Param<BoundArg1>::ParamType arg1,
3071  typename Cgu::Param<BoundArg2>::ParamType arg2) {
3073 }
3074 
3075 /**
3076  * A convenience function to make Callback::CallbackArg objects
3077  * @exception std::bad_alloc It might throw std::bad_alloc if memory
3078  * is exhausted and the system throws in that case (this exception
3079  * will not be thrown if the library has been installed using the
3080  * \--with-glib-memory-slices-no-compat configuration option: instead
3081  * glib will terminate the program if it is unable to obtain memory
3082  * from the operating system). It will also throw if the copy
3083  * constructor of a bound argument throws and it is not a reference
3084  * argument.
3085  *
3086  * Since 1.2.10
3087  */
3088 template <class T, class BoundArg1, class BoundArg2, class FreeArg1, class FreeArg2, class FreeArg3>
3090  void (T::*func)(BoundArg1, BoundArg2, FreeArg1, FreeArg2, FreeArg3),
3091  BoundArg1 arg1,
3092  BoundArg2 arg2) {
3093  return new CallbackArg2<T, BoundArg1, BoundArg2, TypeTuple<FreeArg1, FreeArg2, FreeArg3> >(t, func, arg1, arg2);
3094 }
3095 
3096 /**
3097  * DEPRECATED: use Callback::make_ref() instead.
3098  *
3099  * An alternative function to make Callback::CallbackArg objects,
3100  * which is for use where a target function receives an argument of
3101  * class type by value which is to be a bound argument, so the
3102  * compiler is not able to carry out copy elision when constructing
3103  * the callback object.
3104  * @exception std::bad_alloc It might throw std::bad_alloc if memory
3105  * is exhausted and the system throws in that case (this exception
3106  * will not be thrown if the library has been installed using the
3107  * \--with-glib-memory-slices-no-compat configuration option: instead
3108  * glib will terminate the program if it is unable to obtain memory
3109  * from the operating system). It will also throw if the copy
3110  * constructor of a bound argument throws and it is not a reference
3111  * argument.
3112  *
3113  * Since 1.2.10
3114  */
3115 template <class T, class BoundArg1, class BoundArg2, class FreeArg1, class FreeArg2, class FreeArg3>
3117  void (T::*func)(BoundArg1, BoundArg2, FreeArg1, FreeArg2, FreeArg3),
3118  const BoundArg1& arg1,
3119  const BoundArg2& arg2) {
3120  return new CallbackArg2<T, BoundArg1, BoundArg2, TypeTuple<FreeArg1, FreeArg2, FreeArg3> >(t, func, arg1, arg2);
3121 }
3122 
3123 /**
3124  * An alternative function to make Callback::CallbackArg objects,
3125  * which is for use where a target function either receives a class
3126  * type bound argument by value, or receives a bound argument by
3127  * reference to const in a case where the generated CallbackArg object
3128  * is to store a copy of that argument instead of just keeping a
3129  * reference.
3130  * @exception std::bad_alloc It might throw std::bad_alloc if memory
3131  * is exhausted and the system throws in that case (this exception
3132  * will not be thrown if the library has been installed using the
3133  * \--with-glib-memory-slices-no-compat configuration option: instead
3134  * glib will terminate the program if it is unable to obtain memory
3135  * from the operating system). It will also throw if the copy
3136  * constructor of a bound argument throws.
3137  *
3138  * Since 1.2.13
3139  */
3140 template <class T, class BoundArg1, class BoundArg2, class FreeArg1, class FreeArg2, class FreeArg3>
3142  void (T::*func)(BoundArg1, BoundArg2, FreeArg1, FreeArg2, FreeArg3),
3143  typename Cgu::Param<BoundArg1>::ParamType arg1,
3144  typename Cgu::Param<BoundArg2>::ParamType arg2) {
3146 }
3147 #endif // CGU_USE_TYPE_TUPLE_ARGS
3148 
3149 /* const versions, for binding to const methods */
3150 
3151 /**
3152  * A convenience function to make Callback::CallbackArg objects
3153  * @exception std::bad_alloc It might throw std::bad_alloc if memory
3154  * is exhausted and the system throws in that case. This exception
3155  * will not be thrown if the library has been installed using the
3156  * \--with-glib-memory-slices-no-compat configuration option (instead
3157  * glib will terminate the program if it is unable to obtain memory
3158  * from the operating system).
3159  */
3160 template <class T>
3161 Callback* make(const T& t,
3162  void (T::*func)() const) {
3163  return new Callback0_const<T>(t, func);
3164 }
3165 
3166 /**
3167  * DEPRECATED.
3168  *
3169  * Since this function constructs a callback which does not take a
3170  * bound argument, it is a synonym for make() (the two are identical).
3171  * @exception std::bad_alloc It might throw std::bad_alloc if memory
3172  * is exhausted and the system throws in that case. This exception
3173  * will not be thrown if the library has been installed using the
3174  * \--with-glib-memory-slices-no-compat configuration option (instead
3175  * glib will terminate the program if it is unable to obtain memory
3176  * from the operating system).
3177  *
3178  * Since 1.2.8
3179  */
3180 template <class T>
3181 Callback* make_val(const T& t,
3182  void (T::*func)() const) {
3183  return new Callback0_const<T>(t, func);
3184 }
3185 
3186 /**
3187  * Since this function constructs a callback which does not take a
3188  * bound argument, it is a synonym for make() (the two are identical).
3189  * @exception std::bad_alloc It might throw std::bad_alloc if memory
3190  * is exhausted and the system throws in that case. This exception
3191  * will not be thrown if the library has been installed using the
3192  * \--with-glib-memory-slices-no-compat configuration option (instead
3193  * glib will terminate the program if it is unable to obtain memory
3194  * from the operating system).
3195  *
3196  * Since 1.2.13
3197  */
3198 template <class T>
3199 Callback* make_ref(const T& t,
3200  void (T::*func)() const) {
3201  return new Callback0_const<T>(t, func);
3202 }
3203 
3204 /**
3205  * A convenience function to make Callback::CallbackArg objects
3206  * @exception std::bad_alloc It might throw std::bad_alloc if memory
3207  * is exhausted and the system throws in that case. This exception
3208  * will not be thrown if the library has been installed using the
3209  * \--with-glib-memory-slices-no-compat configuration option (instead
3210  * glib will terminate the program if it is unable to obtain memory
3211  * from the operating system).
3212  */
3213 template <class T, class FreeArg>
3215  void (T::*func)(FreeArg) const) {
3216  return new CallbackArg0_const<T, FreeArg>(t, func);
3217 }
3218 
3219 /**
3220  * DEPRECATED.
3221  *
3222  * Since this function constructs a callback which does not take a
3223  * bound argument, it is a synonym for make() (the two are identical).
3224  * @exception std::bad_alloc It might throw std::bad_alloc if memory
3225  * is exhausted and the system throws in that case. This exception
3226  * will not be thrown if the library has been installed using the
3227  * \--with-glib-memory-slices-no-compat configuration option (instead
3228  * glib will terminate the program if it is unable to obtain memory
3229  * from the operating system).
3230  *
3231  * Since 1.2.8
3232  */
3233 template <class T, class FreeArg>
3235  void (T::*func)(FreeArg) const) {
3236  return new CallbackArg0_const<T, FreeArg>(t, func);
3237 }
3238 
3239 /**
3240  * Since this function constructs a callback which does not take a
3241  * bound argument, it is a synonym for make() (the two are identical).
3242  * @exception std::bad_alloc It might throw std::bad_alloc if memory
3243  * is exhausted and the system throws in that case. This exception
3244  * will not be thrown if the library has been installed using the
3245  * \--with-glib-memory-slices-no-compat configuration option (instead
3246  * glib will terminate the program if it is unable to obtain memory
3247  * from the operating system).
3248  *
3249  * Since 1.2.13
3250  */
3251 template <class T, class FreeArg>
3253  void (T::*func)(FreeArg) const) {
3254  return new CallbackArg0_const<T, FreeArg>(t, func);
3255 }
3256 
3257 #if defined(CGU_USE_TYPE_TUPLE_ARGS) || defined(DOXYGEN_PARSING)
3258 /**
3259  * A convenience function to make Callback::CallbackArg objects
3260  * @exception std::bad_alloc It might throw std::bad_alloc if memory
3261  * is exhausted and the system throws in that case. This exception
3262  * will not be thrown if the library has been installed using the
3263  * \--with-glib-memory-slices-no-compat configuration option (instead
3264  * glib will terminate the program if it is unable to obtain memory
3265  * from the operating system).
3266  *
3267  * Since 1.2.10
3268  */
3269 template <class T, class FreeArg1, class FreeArg2>
3271  void (T::*func)(FreeArg1, FreeArg2) const) {
3273 }
3274 
3275 /**
3276  * DEPRECATED.
3277  *
3278  * Since this function constructs a callback which does not take a
3279  * bound argument, it is a synonym for make() (the two are identical).
3280  * @exception std::bad_alloc It might throw std::bad_alloc if memory
3281  * is exhausted and the system throws in that case. This exception
3282  * will not be thrown if the library has been installed using the
3283  * \--with-glib-memory-slices-no-compat configuration option (instead
3284  * glib will terminate the program if it is unable to obtain memory
3285  * from the operating system).
3286  *
3287  * Since 1.2.10
3288  */
3289 template <class T, class FreeArg1, class FreeArg2>
3291  void (T::*func)(FreeArg1, FreeArg2) const) {
3293 }
3294 
3295 /**
3296  * Since this function constructs a callback which does not take a
3297  * bound argument, it is a synonym for make() (the two are identical).
3298  * @exception std::bad_alloc It might throw std::bad_alloc if memory
3299  * is exhausted and the system throws in that case. This exception
3300  * will not be thrown if the library has been installed using the
3301  * \--with-glib-memory-slices-no-compat configuration option (instead
3302  * glib will terminate the program if it is unable to obtain memory
3303  * from the operating system).
3304  *
3305  * Since 1.2.13
3306  */
3307 template <class T, class FreeArg1, class FreeArg2>
3309  void (T::*func)(FreeArg1, FreeArg2) const) {
3311 }
3312 
3313 /**
3314  * A convenience function to make Callback::CallbackArg objects
3315  * @exception std::bad_alloc It might throw std::bad_alloc if memory
3316  * is exhausted and the system throws in that case. This exception
3317  * will not be thrown if the library has been installed using the
3318  * \--with-glib-memory-slices-no-compat configuration option (instead
3319  * glib will terminate the program if it is unable to obtain memory
3320  * from the operating system).
3321  *
3322  * Since 1.2.10
3323  */
3324 template <class T, class FreeArg1, class FreeArg2, class FreeArg3>
3326  void (T::*func)(FreeArg1, FreeArg2, FreeArg3) const) {
3328 }
3329 
3330 /**
3331  * DEPRECATED.
3332  *
3333  * Since this function constructs a callback which does not take a
3334  * bound argument, it is a synonym for make() (the two are identical).
3335  * @exception std::bad_alloc It might throw std::bad_alloc if memory
3336  * is exhausted and the system throws in that case. This exception
3337  * will not be thrown if the library has been installed using the
3338  * \--with-glib-memory-slices-no-compat configuration option (instead
3339  * glib will terminate the program if it is unable to obtain memory
3340  * from the operating system).
3341  *
3342  * Since 1.2.10
3343  */
3344 template <class T, class FreeArg1, class FreeArg2, class FreeArg3>
3346  void (T::*func)(FreeArg1, FreeArg2, FreeArg3) const) {
3348 }
3349 
3350 /**
3351  * Since this function constructs a callback which does not take a
3352  * bound argument, it is a synonym for make() (the two are identical).
3353  * @exception std::bad_alloc It might throw std::bad_alloc if memory
3354  * is exhausted and the system throws in that case. This exception
3355  * will not be thrown if the library has been installed using the
3356  * \--with-glib-memory-slices-no-compat configuration option (instead
3357  * glib will terminate the program if it is unable to obtain memory
3358  * from the operating system).
3359  *
3360  * Since 1.2.13
3361  */
3362 template <class T, class FreeArg1, class FreeArg2, class FreeArg3>
3364  void (T::*func)(FreeArg1, FreeArg2, FreeArg3) const) {
3366 }
3367 #endif // CGU_USE_TYPE_TUPLE_ARGS
3368 
3369 /**
3370  * A convenience function to make Callback::CallbackArg objects
3371  * @exception std::bad_alloc It might throw std::bad_alloc if memory
3372  * is exhausted and the system throws in that case (this exception
3373  * will not be thrown if the library has been installed using the
3374  * \--with-glib-memory-slices-no-compat configuration option: instead
3375  * glib will terminate the program if it is unable to obtain memory
3376  * from the operating system). It will also throw if the copy
3377  * constructor of a bound argument throws and it is not a reference
3378  * argument.
3379  */
3380 template <class T, class BoundArg>
3381 Callback* make(const T& t,
3382  void (T::*func)(BoundArg) const,
3383  BoundArg arg) {
3384  return new Callback1_const<T, BoundArg>(t, func, arg);
3385 }
3386 
3387 /**
3388  * DEPRECATED: use Callback::make_ref() instead.
3389  *
3390  * An alternative function to make Callback::CallbackArg objects,
3391  * which is for use where a target function receives an argument of
3392  * class type by value which is to be a bound argument, so the
3393  * compiler is not able to carry out copy elision when constructing
3394  * the callback object.
3395  * @exception std::bad_alloc It might throw std::bad_alloc if memory
3396  * is exhausted and the system throws in that case (this exception
3397  * will not be thrown if the library has been installed using the
3398  * \--with-glib-memory-slices-no-compat configuration option: instead
3399  * glib will terminate the program if it is unable to obtain memory
3400  * from the operating system). It will also throw if the copy
3401  * constructor of a bound argument throws and it is not a reference
3402  * argument.
3403  *
3404  * Since 1.2.8
3405  */
3406 template <class T, class BoundArg>
3407 Callback* make_val(const T& t,
3408  void (T::*func)(BoundArg) const,
3409  const BoundArg& arg) {
3410  return new Callback1_const<T, BoundArg>(t, func, arg);
3411 }
3412 
3413 /**
3414  * An alternative function to make Callback::CallbackArg objects,
3415  * which is for use where a target function either receives a class
3416  * type bound argument by value, or receives a bound argument by
3417  * reference to const in a case where the generated CallbackArg object
3418  * is to store a copy of that argument instead of just keeping a
3419  * reference.
3420  * @exception std::bad_alloc It might throw std::bad_alloc if memory
3421  * is exhausted and the system throws in that case (this exception
3422  * will not be thrown if the library has been installed using the
3423  * \--with-glib-memory-slices-no-compat configuration option: instead
3424  * glib will terminate the program if it is unable to obtain memory
3425  * from the operating system). It will also throw if the copy
3426  * constructor of a bound argument throws.
3427  *
3428  * Since 1.2.13
3429  */
3430 template <class T, class BoundArg>
3431 Callback* make_ref(const T& t,
3432  void (T::*func)(BoundArg) const,
3433  typename Cgu::Param<BoundArg>::ParamType arg) {
3434  return new Callback1_const_<true, T, BoundArg>(t, func, arg);
3435 }
3436 
3437 /**
3438  * A convenience function to make Callback::CallbackArg objects
3439  * @exception std::bad_alloc It might throw std::bad_alloc if memory
3440  * is exhausted and the system throws in that case (this exception
3441  * will not be thrown if the library has been installed using the
3442  * \--with-glib-memory-slices-no-compat configuration option: instead
3443  * glib will terminate the program if it is unable to obtain memory
3444  * from the operating system). It will also throw if the copy
3445  * constructor of a bound argument throws and it is not a reference
3446  * argument.
3447  */
3448 template <class T, class BoundArg, class FreeArg>
3450  void (T::*func)(BoundArg, FreeArg) const,
3451  BoundArg arg) {
3452  return new CallbackArg1_const<T, BoundArg, FreeArg>(t, func, arg);
3453 }
3454 
3455 /**
3456  * DEPRECATED: use Callback::make_ref() instead.
3457  *
3458  * An alternative function to make Callback::CallbackArg objects,
3459  * which is for use where a target function receives an argument of
3460  * class type by value which is to be a bound argument, so the
3461  * compiler is not able to carry out copy elision when constructing
3462  * the callback object.
3463  * @exception std::bad_alloc It might throw std::bad_alloc if memory
3464  * is exhausted and the system throws in that case (this exception
3465  * will not be thrown if the library has been installed using the
3466  * \--with-glib-memory-slices-no-compat configuration option: instead
3467  * glib will terminate the program if it is unable to obtain memory
3468  * from the operating system). It will also throw if the copy
3469  * constructor of a bound argument throws and it is not a reference
3470  * argument.
3471  *
3472  * Since 1.2.8
3473  */
3474 template <class T, class BoundArg, class FreeArg>
3476  void (T::*func)(BoundArg, FreeArg) const,
3477  const BoundArg& arg) {
3478  return new CallbackArg1_const<T, BoundArg, FreeArg>(t, func, arg);
3479 }
3480 
3481 /**
3482  * An alternative function to make Callback::CallbackArg objects,
3483  * which is for use where a target function either receives a class
3484  * type bound argument by value, or receives a bound argument by
3485  * reference to const in a case where the generated CallbackArg object
3486  * is to store a copy of that argument instead of just keeping a
3487  * reference.
3488  * @exception std::bad_alloc It might throw std::bad_alloc if memory
3489  * is exhausted and the system throws in that case (this exception
3490  * will not be thrown if the library has been installed using the
3491  * \--with-glib-memory-slices-no-compat configuration option: instead
3492  * glib will terminate the program if it is unable to obtain memory
3493  * from the operating system). It will also throw if the copy
3494  * constructor of a bound argument throws.
3495  *
3496  * Since 1.2.13
3497  */
3498 template <class T, class BoundArg, class FreeArg>
3500  void (T::*func)(BoundArg, FreeArg) const,
3501  typename Cgu::Param<BoundArg>::ParamType arg) {
3502  return new CallbackArg1_const_<true, T, BoundArg, FreeArg>(t, func, arg);
3503 }
3504 
3505 #if defined(CGU_USE_TYPE_TUPLE_ARGS) || defined(DOXYGEN_PARSING)
3506 /**
3507  * A convenience function to make Callback::CallbackArg objects
3508  * @exception std::bad_alloc It might throw std::bad_alloc if memory
3509  * is exhausted and the system throws in that case. This exception
3510  * will not be thrown if the library has been installed using the
3511  * \--with-glib-memory-slices-no-compat configuration option (instead
3512  * glib will terminate the program if it is unable to obtain memory
3513  * from the operating system).
3514  *
3515  * Since 1.2.10
3516  */
3517 template <class T, class BoundArg, class FreeArg1, class FreeArg2>
3519  void (T::*func)(BoundArg, FreeArg1, FreeArg2) const,
3520  BoundArg arg) {
3521  return new CallbackArg1_const<T, BoundArg, TypeTuple<FreeArg1, FreeArg2> >(t, func, arg);
3522 }
3523 
3524 /**
3525  * DEPRECATED: use Callback::make_ref() instead.
3526  *
3527  * An alternative function to make Callback::CallbackArg objects,
3528  * which is for use where a target function receives an argument of
3529  * class type by value which is to be a bound argument, so the
3530  * compiler is not able to carry out copy elision when constructing
3531  * the callback object.
3532  * @exception std::bad_alloc It might throw std::bad_alloc if memory
3533  * is exhausted and the system throws in that case (this exception
3534  * will not be thrown if the library has been installed using the
3535  * \--with-glib-memory-slices-no-compat configuration option: instead
3536  * glib will terminate the program if it is unable to obtain memory
3537  * from the operating system). It will also throw if the copy
3538  * constructor of a bound argument throws and it is not a reference
3539  * argument.
3540  *
3541  * Since 1.2.10
3542  */
3543 template <class T, class BoundArg, class FreeArg1, class FreeArg2>
3545  void (T::*func)(BoundArg, FreeArg1, FreeArg2) const,
3546  const BoundArg& arg) {
3547  return new CallbackArg1_const<T, BoundArg, TypeTuple<FreeArg1, FreeArg2> >(t, func, arg);
3548 }
3549 
3550 /**
3551  * An alternative function to make Callback::CallbackArg objects,
3552  * which is for use where a target function either receives a class
3553  * type bound argument by value, or receives a bound argument by
3554  * reference to const in a case where the generated CallbackArg object
3555  * is to store a copy of that argument instead of just keeping a
3556  * reference.
3557  * @exception std::bad_alloc It might throw std::bad_alloc if memory
3558  * is exhausted and the system throws in that case (this exception
3559  * will not be thrown if the library has been installed using the
3560  * \--with-glib-memory-slices-no-compat configuration option: instead
3561  * glib will terminate the program if it is unable to obtain memory
3562  * from the operating system). It will also throw if the copy
3563  * constructor of a bound argument throws.
3564  *
3565  * Since 1.2.13
3566  */
3567 template <class T, class BoundArg, class FreeArg1, class FreeArg2>
3569  void (T::*func)(BoundArg, FreeArg1, FreeArg2) const,
3570  typename Cgu::Param<BoundArg>::ParamType arg) {
3572 }
3573 
3574 /**
3575  * A convenience function to make Callback::CallbackArg objects
3576  * @exception std::bad_alloc It might throw std::bad_alloc if memory
3577  * is exhausted and the system throws in that case. This exception
3578  * will not be thrown if the library has been installed using the
3579  * \--with-glib-memory-slices-no-compat configuration option (instead
3580  * glib will terminate the program if it is unable to obtain memory
3581  * from the operating system).
3582  *
3583  * Since 1.2.10
3584  */
3585 template <class T, class BoundArg, class FreeArg1, class FreeArg2, class FreeArg3>
3587  void (T::*func)(BoundArg, FreeArg1, FreeArg2, FreeArg3) const,
3588  BoundArg arg) {
3589  return new CallbackArg1_const<T, BoundArg, TypeTuple<FreeArg1, FreeArg2, FreeArg3> >(t, func, arg);
3590 }
3591 
3592 /**
3593  * DEPRECATED: use Callback::make_ref() instead.
3594  *
3595  * An alternative function to make Callback::CallbackArg objects,
3596  * which is for use where a target function receives an argument of
3597  * class type by value which is to be a bound argument, so the
3598  * compiler is not able to carry out copy elision when constructing
3599  * the callback object.
3600  * @exception std::bad_alloc It might throw std::bad_alloc if memory
3601  * is exhausted and the system throws in that case (this exception
3602  * will not be thrown if the library has been installed using the
3603  * \--with-glib-memory-slices-no-compat configuration option: instead
3604  * glib will terminate the program if it is unable to obtain memory
3605  * from the operating system). It will also throw if the copy
3606  * constructor of a bound argument throws and it is not a reference
3607  * argument.
3608  *
3609  * Since 1.2.10
3610  */
3611 template <class T, class BoundArg, class FreeArg1, class FreeArg2, class FreeArg3>
3613  void (T::*func)(BoundArg, FreeArg1, FreeArg2, FreeArg3) const,
3614  const BoundArg& arg) {
3615  return new CallbackArg1_const<T, BoundArg, TypeTuple<FreeArg1, FreeArg2, FreeArg3> >(t, func, arg);
3616 }
3617 
3618 /**
3619  * An alternative function to make Callback::CallbackArg objects,
3620  * which is for use where a target function either receives a class
3621  * type bound argument by value, or receives a bound argument by
3622  * reference to const in a case where the generated CallbackArg object
3623  * is to store a copy of that argument instead of just keeping a
3624  * reference.
3625  * @exception std::bad_alloc It might throw std::bad_alloc if memory
3626  * is exhausted and the system throws in that case (this exception
3627  * will not be thrown if the library has been installed using the
3628  * \--with-glib-memory-slices-no-compat configuration option: instead
3629  * glib will terminate the program if it is unable to obtain memory
3630  * from the operating system). It will also throw if the copy
3631  * constructor of a bound argument throws.
3632  *
3633  * Since 1.2.13
3634  */
3635 template <class T, class BoundArg, class FreeArg1, class FreeArg2, class FreeArg3>
3637  void (T::*func)(BoundArg, FreeArg1, FreeArg2, FreeArg3) const,
3638  typename Cgu::Param<BoundArg>::ParamType arg) {
3640 }
3641 #endif // CGU_USE_TYPE_TUPLE_ARGS
3642 
3643 /**
3644  * A convenience function to make Callback::CallbackArg objects
3645  * @exception std::bad_alloc It might throw std::bad_alloc if memory
3646  * is exhausted and the system throws in that case (this exception
3647  * will not be thrown if the library has been installed using the
3648  * \--with-glib-memory-slices-no-compat configuration option: instead
3649  * glib will terminate the program if it is unable to obtain memory
3650  * from the operating system). It will also throw if the copy
3651  * constructor of a bound argument throws and it is not a reference
3652  * argument.
3653  */
3654 template <class T, class BoundArg1, class BoundArg2>
3655 Callback* make(const T& t,
3656  void (T::*func)(BoundArg1, BoundArg2) const,
3657  BoundArg1 arg1,
3658  BoundArg2 arg2) {
3659  return new Callback2_const<T, BoundArg1, BoundArg2>(t, func, arg1, arg2);
3660 }
3661 
3662 /**
3663  * DEPRECATED: use Callback::make_ref() instead.
3664  *
3665  * An alternative function to make Callback::CallbackArg objects,
3666  * which is for use where a target function receives an argument of
3667  * class type by value which is to be a bound argument, so the
3668  * compiler is not able to carry out copy elision when constructing
3669  * the callback object.
3670  * @exception std::bad_alloc It might throw std::bad_alloc if memory
3671  * is exhausted and the system throws in that case (this exception
3672  * will not be thrown if the library has been installed using the
3673  * \--with-glib-memory-slices-no-compat configuration option: instead
3674  * glib will terminate the program if it is unable to obtain memory
3675  * from the operating system). It will also throw if the copy
3676  * constructor of a bound argument throws and it is not a reference
3677  * argument.
3678  *
3679  * Since 1.2.8
3680  */
3681 template <class T, class BoundArg1, class BoundArg2>
3682 Callback* make_val(const T& t,
3683  void (T::*func)(BoundArg1, BoundArg2) const,
3684  const BoundArg1& arg1,
3685  const BoundArg2& arg2) {
3686  return new Callback2_const<T, BoundArg1, BoundArg2>(t, func, arg1, arg2);
3687 }
3688 
3689 /**
3690  * An alternative function to make Callback::CallbackArg objects,
3691  * which is for use where a target function either receives a class
3692  * type bound argument by value, or receives a bound argument by
3693  * reference to const in a case where the generated CallbackArg object
3694  * is to store a copy of that argument instead of just keeping a
3695  * reference.
3696  * @exception std::bad_alloc It might throw std::bad_alloc if memory
3697  * is exhausted and the system throws in that case (this exception
3698  * will not be thrown if the library has been installed using the
3699  * \--with-glib-memory-slices-no-compat configuration option: instead
3700  * glib will terminate the program if it is unable to obtain memory
3701  * from the operating system). It will also throw if the copy
3702  * constructor of a bound argument throws.
3703  *
3704  * Since 1.2.13
3705  */
3706 template <class T, class BoundArg1, class BoundArg2>
3707 Callback* make_ref(const T& t,
3708  void (T::*func)(BoundArg1, BoundArg2) const,
3709  typename Cgu::Param<BoundArg1>::ParamType arg1,
3710  typename Cgu::Param<BoundArg2>::ParamType arg2) {
3711  return new Callback2_const_<true, T, BoundArg1, BoundArg2>(t, func, arg1, arg2);
3712 }
3713 
3714 /**
3715  * A convenience function to make Callback::CallbackArg objects
3716  * @exception std::bad_alloc It might throw std::bad_alloc if memory
3717  * is exhausted and the system throws in that case (this exception
3718  * will not be thrown if the library has been installed using the
3719  * \--with-glib-memory-slices-no-compat configuration option: instead
3720  * glib will terminate the program if it is unable to obtain memory
3721  * from the operating system). It will also throw if the copy
3722  * constructor of a bound argument throws and it is not a reference
3723  * argument.
3724  */
3725 template <class T, class BoundArg1, class BoundArg2, class FreeArg>
3727  void (T::*func)(BoundArg1, BoundArg2, FreeArg) const,
3728  BoundArg1 arg1,
3729  BoundArg2 arg2) {
3730  return new CallbackArg2_const<T, BoundArg1, BoundArg2, FreeArg>(t, func, arg1, arg2);
3731 }
3732 
3733 /**
3734  * DEPRECATED: use Callback::make_ref() instead.
3735  *
3736  * An alternative function to make Callback::CallbackArg objects,
3737  * which is for use where a target function receives an argument of
3738  * class type by value which is to be a bound argument, so the
3739  * compiler is not able to carry out copy elision when constructing
3740  * the callback object.
3741  * @exception std::bad_alloc It might throw std::bad_alloc if memory
3742  * is exhausted and the system throws in that case (this exception
3743  * will not be thrown if the library has been installed using the
3744  * \--with-glib-memory-slices-no-compat configuration option: instead
3745  * glib will terminate the program if it is unable to obtain memory
3746  * from the operating system). It will also throw if the copy
3747  * constructor of a bound argument throws and it is not a reference
3748  * argument.
3749  *
3750  * Since 1.2.8
3751  */
3752 template <class T, class BoundArg1, class BoundArg2, class FreeArg>
3754  void (T::*func)(BoundArg1, BoundArg2, FreeArg) const,
3755  const BoundArg1& arg1,
3756  const BoundArg2& arg2) {
3757  return new CallbackArg2_const<T, BoundArg1, BoundArg2, FreeArg>(t, func, arg1, arg2);
3758 }
3759 
3760 /**
3761  * An alternative function to make Callback::CallbackArg objects,
3762  * which is for use where a target function either receives a class
3763  * type bound argument by value, or receives a bound argument by
3764  * reference to const in a case where the generated CallbackArg object
3765  * is to store a copy of that argument instead of just keeping a
3766  * reference.
3767  * @exception std::bad_alloc It might throw std::bad_alloc if memory
3768  * is exhausted and the system throws in that case (this exception
3769  * will not be thrown if the library has been installed using the
3770  * \--with-glib-memory-slices-no-compat configuration option: instead
3771  * glib will terminate the program if it is unable to obtain memory
3772  * from the operating system). It will also throw if the copy
3773  * constructor of a bound argument throws.
3774  *
3775  * Since 1.2.13
3776  */
3777 template <class T, class BoundArg1, class BoundArg2, class FreeArg>
3779  void (T::*func)(BoundArg1, BoundArg2, FreeArg) const,
3780  typename Cgu::Param<BoundArg1>::ParamType arg1,
3781  typename Cgu::Param<BoundArg2>::ParamType arg2) {
3782  return new CallbackArg2_const_<true, T, BoundArg1, BoundArg2, FreeArg>(t, func, arg1, arg2);
3783 }
3784 
3785 #if defined(CGU_USE_TYPE_TUPLE_ARGS) || defined(DOXYGEN_PARSING)
3786 /**
3787  * A convenience function to make Callback::CallbackArg objects
3788  * @exception std::bad_alloc It might throw std::bad_alloc if memory
3789  * is exhausted and the system throws in that case (this exception
3790  * will not be thrown if the library has been installed using the
3791  * \--with-glib-memory-slices-no-compat configuration option: instead
3792  * glib will terminate the program if it is unable to obtain memory
3793  * from the operating system). It will also throw if the copy
3794  * constructor of a bound argument throws and it is not a reference
3795  * argument.
3796  *
3797  * Since 1.2.10
3798  */
3799 template <class T, class BoundArg1, class BoundArg2, class FreeArg1, class FreeArg2>
3801  void (T::*func)(BoundArg1, BoundArg2, FreeArg1, FreeArg2) const,
3802  BoundArg1 arg1,
3803  BoundArg2 arg2) {
3804  return new CallbackArg2_const<T, BoundArg1, BoundArg2, TypeTuple<FreeArg1, FreeArg2> >(t, func, arg1, arg2);
3805 }
3806 
3807 /**
3808  * DEPRECATED: use Callback::make_ref() instead.
3809  *
3810  * An alternative function to make Callback::CallbackArg objects,
3811  * which is for use where a target function receives an argument of
3812  * class type by value which is to be a bound argument, so the
3813  * compiler is not able to carry out copy elision when constructing
3814  * the callback object.
3815  * @exception std::bad_alloc It might throw std::bad_alloc if memory
3816  * is exhausted and the system throws in that case (this exception
3817  * will not be thrown if the library has been installed using the
3818  * \--with-glib-memory-slices-no-compat configuration option: instead
3819  * glib will terminate the program if it is unable to obtain memory
3820  * from the operating system). It will also throw if the copy
3821  * constructor of a bound argument throws and it is not a reference
3822  * argument.
3823  *
3824  * Since 1.2.10
3825  */
3826 template <class T, class BoundArg1, class BoundArg2, class FreeArg1, class FreeArg2>
3828  void (T::*func)(BoundArg1, BoundArg2, FreeArg1, FreeArg2) const,
3829  const BoundArg1& arg1,
3830  const BoundArg2& arg2) {
3831  return new CallbackArg2_const<T, BoundArg1, BoundArg2, TypeTuple<FreeArg1, FreeArg2> >(t, func, arg1, arg2);
3832 }
3833 
3834 /**
3835  * An alternative function to make Callback::CallbackArg objects,
3836  * which is for use where a target function either receives a class
3837  * type bound argument by value, or receives a bound argument by
3838  * reference to const in a case where the generated CallbackArg object
3839  * is to store a copy of that argument instead of just keeping a
3840  * reference.
3841  * @exception std::bad_alloc It might throw std::bad_alloc if memory
3842  * is exhausted and the system throws in that case (this exception
3843  * will not be thrown if the library has been installed using the
3844  * \--with-glib-memory-slices-no-compat configuration option: instead
3845  * glib will terminate the program if it is unable to obtain memory
3846  * from the operating system). It will also throw if the copy
3847  * constructor of a bound argument throws.
3848  *
3849  * Since 1.2.13
3850  */
3851 template <class T, class BoundArg1, class BoundArg2, class FreeArg1, class FreeArg2>
3853  void (T::*func)(BoundArg1, BoundArg2, FreeArg1, FreeArg2) const,
3854  typename Cgu::Param<BoundArg1>::ParamType arg1,
3855  typename Cgu::Param<BoundArg2>::ParamType arg2) {
3857 }
3858 
3859 /**
3860  * A convenience function to make Callback::CallbackArg objects
3861  * @exception std::bad_alloc It might throw std::bad_alloc if memory
3862  * is exhausted and the system throws in that case (this exception
3863  * will not be thrown if the library has been installed using the
3864  * \--with-glib-memory-slices-no-compat configuration option: instead
3865  * glib will terminate the program if it is unable to obtain memory
3866  * from the operating system). It will also throw if the copy
3867  * constructor of a bound argument throws and it is not a reference
3868  * argument.
3869  *
3870  * Since 1.2.10
3871  */
3872 template <class T, class BoundArg1, class BoundArg2, class FreeArg1, class FreeArg2, class FreeArg3>
3874  void (T::*func)(BoundArg1, BoundArg2, FreeArg1, FreeArg2, FreeArg3) const,
3875  BoundArg1 arg1,
3876  BoundArg2 arg2) {
3877  return new CallbackArg2_const<T, BoundArg1, BoundArg2, TypeTuple<FreeArg1, FreeArg2, FreeArg3> >(t, func, arg1, arg2);
3878 }
3879 
3880 /**
3881  * DEPRECATED: use Callback::make_ref() instead.
3882  *
3883  * An alternative function to make Callback::CallbackArg objects,
3884  * which is for use where a target function receives an argument of
3885  * class type by value which is to be a bound argument, so the
3886  * compiler is not able to carry out copy elision when constructing
3887  * the callback object.
3888  * @exception std::bad_alloc It might throw std::bad_alloc if memory
3889  * is exhausted and the system throws in that case (this exception
3890  * will not be thrown if the library has been installed using the
3891  * \--with-glib-memory-slices-no-compat configuration option: instead
3892  * glib will terminate the program if it is unable to obtain memory
3893  * from the operating system). It will also throw if the copy
3894  * constructor of a bound argument throws and it is not a reference
3895  * argument.
3896  *
3897  * Since 1.2.10
3898  */
3899 template <class T, class BoundArg1, class BoundArg2, class FreeArg1, class FreeArg2, class FreeArg3>
3901  void (T::*func)(BoundArg1, BoundArg2, FreeArg1, FreeArg2, FreeArg3) const,
3902  const BoundArg1& arg1,
3903  const BoundArg2& arg2) {
3904  return new CallbackArg2_const<T, BoundArg1, BoundArg2, TypeTuple<FreeArg1, FreeArg2, FreeArg3> >(t, func, arg1, arg2);
3905 }
3906 
3907 /**
3908  * An alternative function to make Callback::CallbackArg objects,
3909  * which is for use where a target function either receives a class
3910  * type bound argument by value, or receives a bound argument by
3911  * reference to const in a case where the generated CallbackArg object
3912  * is to store a copy of that argument instead of just keeping a
3913  * reference.
3914  * @exception std::bad_alloc It might throw std::bad_alloc if memory
3915  * is exhausted and the system throws in that case (this exception
3916  * will not be thrown if the library has been installed using the
3917  * \--with-glib-memory-slices-no-compat configuration option: instead
3918  * glib will terminate the program if it is unable to obtain memory
3919  * from the operating system). It will also throw if the copy
3920  * constructor of a bound argument throws.
3921  *
3922  * Since 1.2.13
3923  */
3924 template <class T, class BoundArg1, class BoundArg2, class FreeArg1, class FreeArg2, class FreeArg3>
3926  void (T::*func)(BoundArg1, BoundArg2, FreeArg1, FreeArg2, FreeArg3) const,
3927  typename Cgu::Param<BoundArg1>::ParamType arg1,
3928  typename Cgu::Param<BoundArg2>::ParamType arg2) {
3930 }
3931 #endif // CGU_USE_TYPE_TUPLE_ARGS
3932 
3933 /* for static class methods and non-class functions */
3934 
3935 /**
3936  * A convenience function to make Callback::CallbackArg objects
3937  * @exception std::bad_alloc It might throw std::bad_alloc if memory
3938  * is exhausted and the system throws in that case. This exception
3939  * will not be thrown if the library has been installed using the
3940  * \--with-glib-memory-slices-no-compat configuration option (instead
3941  * glib will terminate the program if it is unable to obtain memory
3942  * from the operating system).
3943  */
3944 inline Callback* make(void (*func)()) {
3945  return new Callback0_static(func);
3946 }
3947 
3948 /**
3949  * DEPRECATED.
3950  *
3951  * Since this function constructs a callback which does not take a
3952  * bound argument, it is a synonym for make() (the two are identical).
3953  * @exception std::bad_alloc It might throw std::bad_alloc if memory
3954  * is exhausted and the system throws in that case. This exception
3955  * will not be thrown if the library has been installed using the
3956  * \--with-glib-memory-slices-no-compat configuration option (instead
3957  * glib will terminate the program if it is unable to obtain memory
3958  * from the operating system).
3959  *
3960  * Since 1.2.8
3961  */
3962 inline Callback* make_val(void (*func)()) {
3963  return new Callback0_static(func);
3964 }
3965 
3966 /**
3967  * Since this function constructs a callback which does not take a
3968  * bound argument, it is a synonym for make() (the two are identical).
3969  * @exception std::bad_alloc It might throw std::bad_alloc if memory
3970  * is exhausted and the system throws in that case. This exception
3971  * will not be thrown if the library has been installed using the
3972  * \--with-glib-memory-slices-no-compat configuration option (instead
3973  * glib will terminate the program if it is unable to obtain memory
3974  * from the operating system).
3975  *
3976  * Since 1.2.13
3977  */
3978 inline Callback* make_ref(void (*func)()) {
3979  return new Callback0_static(func);
3980 }
3981 
3982 /**
3983  * A convenience function to make Callback::CallbackArg objects
3984  * @exception std::bad_alloc It might throw std::bad_alloc if memory
3985  * is exhausted and the system throws in that case. This exception
3986  * will not be thrown if the library has been installed using the
3987  * \--with-glib-memory-slices-no-compat configuration option (instead
3988  * glib will terminate the program if it is unable to obtain memory
3989  * from the operating system).
3990  */
3991 template <class FreeArg>
3992 CallbackArg<FreeArg>* make(void (*func)(FreeArg)) {
3993  return new CallbackArg0_static<FreeArg>(func);
3994 }
3995 
3996 /**
3997  * DEPRECATED.
3998  *
3999  * Since this function constructs a callback which does not take a
4000  * bound argument, it is a synonym for make() (the two are identical).
4001  * @exception std::bad_alloc It might throw std::bad_alloc if memory
4002  * is exhausted and the system throws in that case. This exception
4003  * will not be thrown if the library has been installed using the
4004  * \--with-glib-memory-slices-no-compat configuration option (instead
4005  * glib will terminate the program if it is unable to obtain memory
4006  * from the operating system).
4007  *
4008  * Since 1.2.8
4009  */
4010 template <class FreeArg>
4011 CallbackArg<FreeArg>* make_val(void (*func)(FreeArg)) {
4012  return new CallbackArg0_static<FreeArg>(func);
4013 }
4014 
4015 /**
4016  * Since this function constructs a callback which does not take a
4017  * bound argument, it is a synonym for make() (the two are identical).
4018  * @exception std::bad_alloc It might throw std::bad_alloc if memory
4019  * is exhausted and the system throws in that case. This exception
4020  * will not be thrown if the library has been installed using the
4021  * \--with-glib-memory-slices-no-compat configuration option (instead
4022  * glib will terminate the program if it is unable to obtain memory
4023  * from the operating system).
4024  *
4025  * Since 1.2.13
4026  */
4027 template <class FreeArg>
4028 CallbackArg<FreeArg>* make_ref(void (*func)(FreeArg)) {
4029  return new CallbackArg0_static<FreeArg>(func);
4030 }
4031 
4032 #if defined(CGU_USE_TYPE_TUPLE_ARGS) || defined(DOXYGEN_PARSING)
4033 /**
4034  * A convenience function to make Callback::CallbackArg objects
4035  * @exception std::bad_alloc It might throw std::bad_alloc if memory
4036  * is exhausted and the system throws in that case. This exception
4037  * will not be thrown if the library has been installed using the
4038  * \--with-glib-memory-slices-no-compat configuration option (instead
4039  * glib will terminate the program if it is unable to obtain memory
4040  * from the operating system).
4041  *
4042  * Since 1.2.10
4043  */
4044 template <class FreeArg1, class FreeArg2>
4045 CallbackArg<TypeTuple<FreeArg1, FreeArg2> >* make(void (*func)(FreeArg1, FreeArg2)) {
4047 }
4048 
4049 /**
4050  * DEPRECATED.
4051  *
4052  * Since this function constructs a callback which does not take a
4053  * bound argument, it is a synonym for make() (the two are identical).
4054  * @exception std::bad_alloc It might throw std::bad_alloc if memory
4055  * is exhausted and the system throws in that case. This exception
4056  * will not be thrown if the library has been installed using the
4057  * \--with-glib-memory-slices-no-compat configuration option (instead
4058  * glib will terminate the program if it is unable to obtain memory
4059  * from the operating system).
4060  *
4061  * Since 1.2.10
4062  */
4063 template <class FreeArg1, class FreeArg2>
4064 CallbackArg<TypeTuple<FreeArg1, FreeArg2> >* make_val(void (*func)(FreeArg1, FreeArg2)) {
4066 }
4067 
4068 /**
4069  * Since this function constructs a callback which does not take a
4070  * bound argument, it is a synonym for make() (the two are identical).
4071  * @exception std::bad_alloc It might throw std::bad_alloc if memory
4072  * is exhausted and the system throws in that case. This exception
4073  * will not be thrown if the library has been installed using the
4074  * \--with-glib-memory-slices-no-compat configuration option (instead
4075  * glib will terminate the program if it is unable to obtain memory
4076  * from the operating system).
4077  *
4078  * Since 1.2.13
4079  */
4080 template <class FreeArg1, class FreeArg2>
4081 CallbackArg<TypeTuple<FreeArg1, FreeArg2> >* make_ref(void (*func)(FreeArg1, FreeArg2)) {
4083 }
4084 
4085 /**
4086  * A convenience function to make Callback::CallbackArg objects
4087  * @exception std::bad_alloc It might throw std::bad_alloc if memory
4088  * is exhausted and the system throws in that case. This exception
4089  * will not be thrown if the library has been installed using the
4090  * \--with-glib-memory-slices-no-compat configuration option (instead
4091  * glib will terminate the program if it is unable to obtain memory
4092  * from the operating system).
4093  *
4094  * Since 1.2.10
4095  */
4096 template <class FreeArg1, class FreeArg2, class FreeArg3>
4097  CallbackArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> >* make(void (*func)(FreeArg1, FreeArg2, FreeArg3)) {
4099 }
4100 
4101 /**
4102  * DEPRECATED.
4103  *
4104  * Since this function constructs a callback which does not take a
4105  * bound argument, it is a synonym for make() (the two are identical).
4106  * @exception std::bad_alloc It might throw std::bad_alloc if memory
4107  * is exhausted and the system throws in that case. This exception
4108  * will not be thrown if the library has been installed using the
4109  * \--with-glib-memory-slices-no-compat configuration option (instead
4110  * glib will terminate the program if it is unable to obtain memory
4111  * from the operating system).
4112  *
4113  * Since 1.2.10
4114  */
4115 template <class FreeArg1, class FreeArg2, class FreeArg3>
4116  CallbackArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> >* make_val(void (*func)(FreeArg1, FreeArg2, FreeArg3)) {
4118 }
4119 
4120 /**
4121  * Since this function constructs a callback which does not take a
4122  * bound argument, it is a synonym for make() (the two are identical).
4123  * @exception std::bad_alloc It might throw std::bad_alloc if memory
4124  * is exhausted and the system throws in that case. This exception
4125  * will not be thrown if the library has been installed using the
4126  * \--with-glib-memory-slices-no-compat configuration option (instead
4127  * glib will terminate the program if it is unable to obtain memory
4128  * from the operating system).
4129  *
4130  * Since 1.2.13
4131  */
4132 template <class FreeArg1, class FreeArg2, class FreeArg3>
4133  CallbackArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> >* make_ref(void (*func)(FreeArg1, FreeArg2, FreeArg3)) {
4135 }
4136 #endif // CGU_USE_TYPE_TUPLE_ARGS
4137 
4138 /**
4139  * A convenience function to make Callback::CallbackArg objects
4140  * @exception std::bad_alloc It might throw std::bad_alloc if memory
4141  * is exhausted and the system throws in that case (this exception
4142  * will not be thrown if the library has been installed using the
4143  * \--with-glib-memory-slices-no-compat configuration option: instead
4144  * glib will terminate the program if it is unable to obtain memory
4145  * from the operating system). It will also throw if the copy
4146  * constructor of a bound argument throws and it is not a reference
4147  * argument.
4148  */
4149 template <class BoundArg>
4150 Callback* make(void (*func)(BoundArg),
4151  BoundArg arg) {
4152  return new Callback1_static<BoundArg>(func, arg);
4153 }
4154 
4155 /**
4156  * DEPRECATED: use Callback::make_ref() instead.
4157  *
4158  * An alternative function to make Callback::CallbackArg objects,
4159  * which is for use where a target function receives an argument of
4160  * class type by value which is to be a bound argument, so the
4161  * compiler is not able to carry out copy elision when constructing
4162  * the callback object.
4163  * @exception std::bad_alloc It might throw std::bad_alloc if memory
4164  * is exhausted and the system throws in that case (this exception
4165  * will not be thrown if the library has been installed using the
4166  * \--with-glib-memory-slices-no-compat configuration option: instead
4167  * glib will terminate the program if it is unable to obtain memory
4168  * from the operating system). It will also throw if the copy
4169  * constructor of a bound argument throws and it is not a reference
4170  * argument.
4171  *
4172  * Since 1.2.8
4173  */
4174 template <class BoundArg>
4175 Callback* make_val(void (*func)(BoundArg),
4176  const BoundArg& arg) {
4177  return new Callback1_static<BoundArg>(func, arg);
4178 }
4179 
4180 /**
4181  * An alternative function to make Callback::CallbackArg objects,
4182  * which is for use where a target function either receives a class
4183  * type bound argument by value, or receives a bound argument by
4184  * reference to const in a case where the generated CallbackArg object
4185  * is to store a copy of that argument instead of just keeping a
4186  * reference.
4187  * @exception std::bad_alloc It might throw std::bad_alloc if memory
4188  * is exhausted and the system throws in that case (this exception
4189  * will not be thrown if the library has been installed using the
4190  * \--with-glib-memory-slices-no-compat configuration option: instead
4191  * glib will terminate the program if it is unable to obtain memory
4192  * from the operating system). It will also throw if the copy
4193  * constructor of a bound argument throws.
4194  *
4195  * Since 1.2.13
4196  */
4197 template <class BoundArg>
4198 Callback* make_ref(void (*func)(BoundArg),
4199  typename Cgu::Param<BoundArg>::ParamType arg) {
4200  return new Callback1_static_<true, BoundArg>(func, arg);
4201 }
4202 
4203 /**
4204  * A convenience function to make Callback::CallbackArg objects
4205  * @exception std::bad_alloc It might throw std::bad_alloc if memory
4206  * is exhausted and the system throws in that case (this exception
4207  * will not be thrown if the library has been installed using the
4208  * \--with-glib-memory-slices-no-compat configuration option: instead
4209  * glib will terminate the program if it is unable to obtain memory
4210  * from the operating system). It will also throw if the copy
4211  * constructor of a bound argument throws and it is not a reference
4212  * argument.
4213  */
4214 template <class BoundArg, class FreeArg>
4215 CallbackArg<FreeArg>* make(void (*func)(BoundArg, FreeArg),
4216  BoundArg arg) {
4217  return new CallbackArg1_static<BoundArg, FreeArg>(func, arg);
4218 }
4219 
4220 /**
4221  * DEPRECATED: use Callback::make_ref() instead.
4222  *
4223  * An alternative function to make Callback::CallbackArg objects,
4224  * which is for use where a target function receives an argument of
4225  * class type by value which is to be a bound argument, so the
4226  * compiler is not able to carry out copy elision when constructing
4227  * the callback object.
4228  * @exception std::bad_alloc It might throw std::bad_alloc if memory
4229  * is exhausted and the system throws in that case (this exception
4230  * will not be thrown if the library has been installed using the
4231  * \--with-glib-memory-slices-no-compat configuration option: instead
4232  * glib will terminate the program if it is unable to obtain memory
4233  * from the operating system). It will also throw if the copy
4234  * constructor of a bound argument throws and it is not a reference
4235  * argument.
4236  *
4237  * Since 1.2.8
4238  */
4239 template <class BoundArg, class FreeArg>
4240 CallbackArg<FreeArg>* make_val(void (*func)(BoundArg, FreeArg),
4241  const BoundArg& arg) {
4242  return new CallbackArg1_static<BoundArg, FreeArg>(func, arg);
4243 }
4244 
4245 /**
4246  * An alternative function to make Callback::CallbackArg objects,
4247  * which is for use where a target function either receives a class
4248  * type bound argument by value, or receives a bound argument by
4249  * reference to const in a case where the generated CallbackArg object
4250  * is to store a copy of that argument instead of just keeping a
4251  * reference.
4252  * @exception std::bad_alloc It might throw std::bad_alloc if memory
4253  * is exhausted and the system throws in that case (this exception
4254  * will not be thrown if the library has been installed using the
4255  * \--with-glib-memory-slices-no-compat configuration option: instead
4256  * glib will terminate the program if it is unable to obtain memory
4257  * from the operating system). It will also throw if the copy
4258  * constructor of a bound argument throws.
4259  *
4260  * Since 1.2.13
4261  */
4262 template <class BoundArg, class FreeArg>
4263 CallbackArg<FreeArg>* make_ref(void (*func)(BoundArg, FreeArg),
4264  typename Cgu::Param<BoundArg>::ParamType arg) {
4265  return new CallbackArg1_static_<true, BoundArg, FreeArg>(func, arg);
4266 }
4267 
4268 #if defined(CGU_USE_TYPE_TUPLE_ARGS) || defined(DOXYGEN_PARSING)
4269 /**
4270  * A convenience function to make Callback::CallbackArg objects
4271  * @exception std::bad_alloc It might throw std::bad_alloc if memory
4272  * is exhausted and the system throws in that case. This exception
4273  * will not be thrown if the library has been installed using the
4274  * \--with-glib-memory-slices-no-compat configuration option (instead
4275  * glib will terminate the program if it is unable to obtain memory
4276  * from the operating system).
4277  *
4278  * Since 1.2.10
4279  */
4280 template <class BoundArg, class FreeArg1, class FreeArg2>
4281 CallbackArg<TypeTuple<FreeArg1, FreeArg2> >* make(void (*func)(BoundArg, FreeArg1, FreeArg2),
4282  BoundArg arg) {
4283  return new CallbackArg1_static<BoundArg, TypeTuple<FreeArg1, FreeArg2> >(func, arg);
4284 }
4285 
4286 /**
4287  * DEPRECATED: use Callback::make_ref() instead.
4288  *
4289  * An alternative function to make Callback::CallbackArg objects,
4290  * which is for use where a target function receives an argument of
4291  * class type by value which is to be a bound argument, so the
4292  * compiler is not able to carry out copy elision when constructing
4293  * the callback object.
4294  * @exception std::bad_alloc It might throw std::bad_alloc if memory
4295  * is exhausted and the system throws in that case. This exception
4296  * will not be thrown if the library has been installed using the
4297  * \--with-glib-memory-slices-no-compat configuration option (instead
4298  * glib will terminate the program if it is unable to obtain memory
4299  * from the operating system).
4300  *
4301  * Since 1.2.10
4302  */
4303 template <class BoundArg, class FreeArg1, class FreeArg2>
4304 CallbackArg<TypeTuple<FreeArg1, FreeArg2> >* make_val(void (*func)(BoundArg, FreeArg1, FreeArg2),
4305  const BoundArg& arg) {
4306  return new CallbackArg1_static<BoundArg, TypeTuple<FreeArg1, FreeArg2> >(func, arg);
4307 }
4308 
4309 /**
4310  * An alternative function to make Callback::CallbackArg objects,
4311  * which is for use where a target function either receives a class
4312  * type bound argument by value, or receives a bound argument by
4313  * reference to const in a case where the generated CallbackArg object
4314  * is to store a copy of that argument instead of just keeping a
4315  * reference.
4316  * @exception std::bad_alloc It might throw std::bad_alloc if memory
4317  * is exhausted and the system throws in that case (this exception
4318  * will not be thrown if the library has been installed using the
4319  * \--with-glib-memory-slices-no-compat configuration option: instead
4320  * glib will terminate the program if it is unable to obtain memory
4321  * from the operating system). It will also throw if the copy
4322  * constructor of a bound argument throws.
4323  *
4324  * Since 1.2.13
4325  */
4326 template <class BoundArg, class FreeArg1, class FreeArg2>
4327 CallbackArg<TypeTuple<FreeArg1, FreeArg2> >* make_ref(void (*func)(BoundArg, FreeArg1, FreeArg2),
4328  typename Cgu::Param<BoundArg>::ParamType arg) {
4330 }
4331 
4332 /**
4333  * A convenience function to make Callback::CallbackArg objects
4334  * @exception std::bad_alloc It might throw std::bad_alloc if memory
4335  * is exhausted and the system throws in that case. This exception
4336  * will not be thrown if the library has been installed using the
4337  * \--with-glib-memory-slices-no-compat configuration option (instead
4338  * glib will terminate the program if it is unable to obtain memory
4339  * from the operating system).
4340  *
4341  * Since 1.2.10
4342  */
4343 template <class BoundArg, class FreeArg1, class FreeArg2, class FreeArg3>
4344 CallbackArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> >* make(void (*func)(BoundArg, FreeArg1, FreeArg2, FreeArg3),
4345  BoundArg arg) {
4346  return new CallbackArg1_static<BoundArg, TypeTuple<FreeArg1, FreeArg2, FreeArg3> >(func, arg);
4347 }
4348 
4349 /**
4350  * DEPRECATED: use Callback::make_ref() instead.
4351  *
4352  * An alternative function to make Callback::CallbackArg objects,
4353  * which is for use where a target function receives an argument of
4354  * class type by value which is to be a bound argument, so the
4355  * compiler is not able to carry out copy elision when constructing
4356  * the callback object.
4357  * @exception std::bad_alloc It might throw std::bad_alloc if memory
4358  * is exhausted and the system throws in that case. This exception
4359  * will not be thrown if the library has been installed using the
4360  * \--with-glib-memory-slices-no-compat configuration option (instead
4361  * glib will terminate the program if it is unable to obtain memory
4362  * from the operating system).
4363  *
4364  * Since 1.2.10
4365  */
4366 template <class BoundArg, class FreeArg1, class FreeArg2, class FreeArg3>
4367 CallbackArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> >* make_val(void (*func)(BoundArg, FreeArg1, FreeArg2, FreeArg3),
4368  const BoundArg& arg) {
4369  return new CallbackArg1_static<BoundArg, TypeTuple<FreeArg1, FreeArg2, FreeArg3> >(func, arg);
4370 }
4371 
4372 /**
4373  * An alternative function to make Callback::CallbackArg objects,
4374  * which is for use where a target function either receives a class
4375  * type bound argument by value, or receives a bound argument by
4376  * reference to const in a case where the generated CallbackArg object
4377  * is to store a copy of that argument instead of just keeping a
4378  * reference.
4379  * @exception std::bad_alloc It might throw std::bad_alloc if memory
4380  * is exhausted and the system throws in that case (this exception
4381  * will not be thrown if the library has been installed using the
4382  * \--with-glib-memory-slices-no-compat configuration option: instead
4383  * glib will terminate the program if it is unable to obtain memory
4384  * from the operating system). It will also throw if the copy
4385  * constructor of a bound argument throws.
4386  *
4387  * Since 1.2.13
4388  */
4389 template <class BoundArg, class FreeArg1, class FreeArg2, class FreeArg3>
4390 CallbackArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> >* make_ref(void (*func)(BoundArg, FreeArg1, FreeArg2, FreeArg3),
4391  typename Cgu::Param<BoundArg>::ParamType arg) {
4393 }
4394 #endif // CGU_USE_TYPE_TUPLE_ARGS
4395 
4396 /**
4397  * A convenience function to make Callback::CallbackArg objects
4398  * @exception std::bad_alloc It might throw std::bad_alloc if memory
4399  * is exhausted and the system throws in that case (this exception
4400  * will not be thrown if the library has been installed using the
4401  * \--with-glib-memory-slices-no-compat configuration option: instead
4402  * glib will terminate the program if it is unable to obtain memory
4403  * from the operating system). It will also throw if the copy
4404  * constructor of a bound argument throws and it is not a reference
4405  * argument.
4406  */
4407 template <class BoundArg1, class BoundArg2>
4408 Callback* make(void (*func)(BoundArg1, BoundArg2),
4409  BoundArg1 arg1,
4410  BoundArg2 arg2) {
4411  return new Callback2_static<BoundArg1, BoundArg2>(func, arg1, arg2);
4412 }
4413 
4414 /**
4415  * DEPRECATED: use Callback::make_ref() instead.
4416  *
4417  * An alternative function to make Callback::CallbackArg objects,
4418  * which is for use where a target function receives an argument of
4419  * class type by value which is to be a bound argument, so the
4420  * compiler is not able to carry out copy elision when constructing
4421  * the callback object.
4422  * @exception std::bad_alloc It might throw std::bad_alloc if memory
4423  * is exhausted and the system throws in that case (this exception
4424  * will not be thrown if the library has been installed using the
4425  * \--with-glib-memory-slices-no-compat configuration option: instead
4426  * glib will terminate the program if it is unable to obtain memory
4427  * from the operating system). It will also throw if the copy
4428  * constructor of a bound argument throws and it is not a reference
4429  * argument.
4430  *
4431  * Since 1.2.8
4432  */
4433 template <class BoundArg1, class BoundArg2>
4434 Callback* make_val(void (*func)(BoundArg1, BoundArg2),
4435  const BoundArg1& arg1,
4436  const BoundArg2& arg2) {
4437  return new Callback2_static<BoundArg1, BoundArg2>(func, arg1, arg2);
4438 }
4439 
4440 /**
4441  * An alternative function to make Callback::CallbackArg objects,
4442  * which is for use where a target function either receives a class
4443  * type bound argument by value, or receives a bound argument by
4444  * reference to const in a case where the generated CallbackArg object
4445  * is to store a copy of that argument instead of just keeping a
4446  * reference.
4447  * @exception std::bad_alloc It might throw std::bad_alloc if memory
4448  * is exhausted and the system throws in that case (this exception
4449  * will not be thrown if the library has been installed using the
4450  * \--with-glib-memory-slices-no-compat configuration option: instead
4451  * glib will terminate the program if it is unable to obtain memory
4452  * from the operating system). It will also throw if the copy
4453  * constructor of a bound argument throws.
4454  *
4455  * Since 1.2.13
4456  */
4457 template <class BoundArg1, class BoundArg2>
4458 Callback* make_ref(void (*func)(BoundArg1, BoundArg2),
4459  typename Cgu::Param<BoundArg1>::ParamType arg1,
4460  typename Cgu::Param<BoundArg2>::ParamType arg2) {
4461  return new Callback2_static_<true, BoundArg1, BoundArg2>(func, arg1, arg2);
4462 }
4463 
4464 /**
4465  * A convenience function to make Callback::CallbackArg objects
4466  * @exception std::bad_alloc It might throw std::bad_alloc if memory
4467  * is exhausted and the system throws in that case (this exception
4468  * will not be thrown if the library has been installed using the
4469  * \--with-glib-memory-slices-no-compat configuration option: instead
4470  * glib will terminate the program if it is unable to obtain memory
4471  * from the operating system). It will also throw if the copy
4472  * constructor of a bound argument throws and it is not a reference
4473  * argument.
4474  */
4475 template <class BoundArg1, class BoundArg2, class FreeArg>
4476 CallbackArg<FreeArg>* make(void (*func)(BoundArg1, BoundArg2, FreeArg),
4477  BoundArg1 arg1,
4478  BoundArg2 arg2) {
4479  return new CallbackArg2_static<BoundArg1, BoundArg2, FreeArg>(func, arg1, arg2);
4480 }
4481 
4482 /**
4483  * DEPRECATED: use Callback::make_ref() instead.
4484  *
4485  * An alternative function to make Callback::CallbackArg objects,
4486  * which is for use where a target function receives an argument of
4487  * class type by value which is to be a bound argument, so the
4488  * compiler is not able to carry out copy elision when constructing
4489  * the callback object.
4490  * @exception std::bad_alloc It might throw std::bad_alloc if memory
4491  * is exhausted and the system throws in that case (this exception
4492  * will not be thrown if the library has been installed using the
4493  * \--with-glib-memory-slices-no-compat configuration option: instead
4494  * glib will terminate the program if it is unable to obtain memory
4495  * from the operating system). It will also throw if the copy
4496  * constructor of a bound argument throws and it is not a reference
4497  * argument.
4498  *
4499  * Since 1.2.8
4500  */
4501 template <class BoundArg1, class BoundArg2, class FreeArg>
4502 CallbackArg<FreeArg>* make_val(void (*func)(BoundArg1, BoundArg2, FreeArg),
4503  const BoundArg1& arg1,
4504  const BoundArg2& arg2) {
4505  return new CallbackArg2_static<BoundArg1, BoundArg2, FreeArg>(func, arg1, arg2);
4506 }
4507 
4508 /**
4509  * An alternative function to make Callback::CallbackArg objects,
4510  * which is for use where a target function either receives a class
4511  * type bound argument by value, or receives a bound argument by
4512  * reference to const in a case where the generated CallbackArg object
4513  * is to store a copy of that argument instead of just keeping a
4514  * reference.
4515  * @exception std::bad_alloc It might throw std::bad_alloc if memory
4516  * is exhausted and the system throws in that case (this exception
4517  * will not be thrown if the library has been installed using the
4518  * \--with-glib-memory-slices-no-compat configuration option: instead
4519  * glib will terminate the program if it is unable to obtain memory
4520  * from the operating system). It will also throw if the copy
4521  * constructor of a bound argument throws.
4522  *
4523  * Since 1.2.13
4524  */
4525 template <class BoundArg1, class BoundArg2, class FreeArg>
4526 CallbackArg<FreeArg>* make_ref(void (*func)(BoundArg1, BoundArg2, FreeArg),
4527  typename Cgu::Param<BoundArg1>::ParamType arg1,
4528  typename Cgu::Param<BoundArg2>::ParamType arg2) {
4529  return new CallbackArg2_static_<true, BoundArg1, BoundArg2, FreeArg>(func, arg1, arg2);
4530 }
4531 
4532 #if defined(CGU_USE_TYPE_TUPLE_ARGS) || defined(DOXYGEN_PARSING)
4533 /**
4534  * A convenience function to make Callback::CallbackArg objects
4535  * @exception std::bad_alloc It might throw std::bad_alloc if memory
4536  * is exhausted and the system throws in that case (this exception
4537  * will not be thrown if the library has been installed using the
4538  * \--with-glib-memory-slices-no-compat configuration option: instead
4539  * glib will terminate the program if it is unable to obtain memory
4540  * from the operating system). It will also throw if the copy
4541  * constructor of a bound argument throws and it is not a reference
4542  * argument.
4543  */
4544 template <class BoundArg1, class BoundArg2, class FreeArg1, class FreeArg2>
4545 CallbackArg<TypeTuple<FreeArg1, FreeArg2> >* make(void (*func)(BoundArg1, BoundArg2, FreeArg1, FreeArg2),
4546  BoundArg1 arg1,
4547  BoundArg2 arg2) {
4548  return new CallbackArg2_static<BoundArg1, BoundArg2, TypeTuple<FreeArg1, FreeArg2> >(func, arg1, arg2);
4549 }
4550 
4551 /**
4552  * DEPRECATED: use Callback::make_ref() instead.
4553  *
4554  * An alternative function to make Callback::CallbackArg objects,
4555  * which is for use where a target function receives an argument of
4556  * class type by value which is to be a bound argument, so the
4557  * compiler is not able to carry out copy elision when constructing
4558  * the callback object.
4559  * @exception std::bad_alloc It might throw std::bad_alloc if memory
4560  * is exhausted and the system throws in that case. This exception
4561  * will not be thrown if the library has been installed using the
4562  * \--with-glib-memory-slices-no-compat configuration option (instead
4563  * glib will terminate the program if it is unable to obtain memory
4564  * from the operating system).
4565  *
4566  * Since 1.2.10
4567  */
4568 template <class BoundArg1, class BoundArg2, class FreeArg1, class FreeArg2>
4569 CallbackArg<TypeTuple<FreeArg1, FreeArg2> >* make_val(void (*func)(BoundArg1, BoundArg2, FreeArg1, FreeArg2),
4570  const BoundArg1& arg1,
4571  const BoundArg2& arg2) {
4572  return new CallbackArg2_static<BoundArg1, BoundArg2, TypeTuple<FreeArg1, FreeArg2> >(func, arg1, arg2);
4573 }
4574 
4575 /**
4576  * An alternative function to make Callback::CallbackArg objects,
4577  * which is for use where a target function either receives a class
4578  * type bound argument by value, or receives a bound argument by
4579  * reference to const in a case where the generated CallbackArg object
4580  * is to store a copy of that argument instead of just keeping a
4581  * reference.
4582  * @exception std::bad_alloc It might throw std::bad_alloc if memory
4583  * is exhausted and the system throws in that case (this exception
4584  * will not be thrown if the library has been installed using the
4585  * \--with-glib-memory-slices-no-compat configuration option: instead
4586  * glib will terminate the program if it is unable to obtain memory
4587  * from the operating system). It will also throw if the copy
4588  * constructor of a bound argument throws.
4589  *
4590  * Since 1.2.13
4591  */
4592 template <class BoundArg1, class BoundArg2, class FreeArg1, class FreeArg2>
4593 CallbackArg<TypeTuple<FreeArg1, FreeArg2> >* make_ref(void (*func)(BoundArg1, BoundArg2, FreeArg1, FreeArg2),
4594  typename Cgu::Param<BoundArg1>::ParamType arg1,
4595  typename Cgu::Param<BoundArg2>::ParamType arg2) {
4597 }
4598 
4599 /**
4600  * A convenience function to make Callback::CallbackArg objects
4601  * @exception std::bad_alloc It might throw std::bad_alloc if memory
4602  * is exhausted and the system throws in that case (this exception
4603  * will not be thrown if the library has been installed using the
4604  * \--with-glib-memory-slices-no-compat configuration option: instead
4605  * glib will terminate the program if it is unable to obtain memory
4606  * from the operating system). It will also throw if the copy
4607  * constructor of a bound argument throws and it is not a reference
4608  * argument.
4609  *
4610  * Since 1.2.10
4611  */
4612 template <class BoundArg1, class BoundArg2, class FreeArg1, class FreeArg2, class FreeArg3>
4613 CallbackArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> >* make(void (*func)(BoundArg1, BoundArg2, FreeArg1, FreeArg2, FreeArg3),
4614  BoundArg1 arg1,
4615  BoundArg2 arg2) {
4616  return new CallbackArg2_static<BoundArg1, BoundArg2, TypeTuple<FreeArg1, FreeArg2, FreeArg3> >(func, arg1, arg2);
4617 }
4618 
4619 /**
4620  * DEPRECATED: use Callback::make_ref() instead.
4621  *
4622  * An alternative function to make Callback::CallbackArg objects,
4623  * which is for use where a target function receives an argument of
4624  * class type by value which is to be a bound argument, so the
4625  * compiler is not able to carry out copy elision when constructing
4626  * the callback object.
4627  * @exception std::bad_alloc It might throw std::bad_alloc if memory
4628  * is exhausted and the system throws in that case (this exception
4629  * will not be thrown if the library has been installed using the
4630  * \--with-glib-memory-slices-no-compat configuration option: instead
4631  * glib will terminate the program if it is unable to obtain memory
4632  * from the operating system). It will also throw if the copy
4633  * constructor of a bound argument throws and it is not a reference
4634  * argument.
4635  *
4636  * Since 1.2.10
4637  */
4638 template <class BoundArg1, class BoundArg2, class FreeArg1, class FreeArg2, class FreeArg3>
4639 CallbackArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> >* make_val(void (*func)(BoundArg1, BoundArg2, FreeArg1, FreeArg2, FreeArg3),
4640  const BoundArg1& arg1,
4641  const BoundArg2& arg2) {
4642  return new CallbackArg2_static<BoundArg1, BoundArg2, TypeTuple<FreeArg1, FreeArg2, FreeArg3> >(func, arg1, arg2);
4643 }
4644 
4645 /**
4646  * An alternative function to make Callback::CallbackArg objects,
4647  * which is for use where a target function either receives a class
4648  * type bound argument by value, or receives a bound argument by
4649  * reference to const in a case where the generated CallbackArg object
4650  * is to store a copy of that argument instead of just keeping a
4651  * reference.
4652  * @exception std::bad_alloc It might throw std::bad_alloc if memory
4653  * is exhausted and the system throws in that case (this exception
4654  * will not be thrown if the library has been installed using the
4655  * \--with-glib-memory-slices-no-compat configuration option: instead
4656  * glib will terminate the program if it is unable to obtain memory
4657  * from the operating system). It will also throw if the copy
4658  * constructor of a bound argument throws.
4659  *
4660  * Since 1.2.13
4661  */
4662 template <class BoundArg1, class BoundArg2, class FreeArg1, class FreeArg2, class FreeArg3>
4663 CallbackArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> >* make_ref(void (*func)(BoundArg1, BoundArg2, FreeArg1, FreeArg2, FreeArg3),
4664  typename Cgu::Param<BoundArg1>::ParamType arg1,
4665  typename Cgu::Param<BoundArg2>::ParamType arg2) {
4667 }
4668 #endif // CGU_USE_TYPE_TUPLE_ARGS
4669 
4670 } // namespace Callback
4671 
4672 class Releaser;
4673 
4674 namespace Callback {
4675 
4676 /**
4677  * Posts a callback for execution by a glib main loop. It is
4678  * thread-safe provided that (if glib < 2.32 is used) g_thread_init()
4679  * has been called. glib >= 2.32 does not require g_thread_init() to
4680  * be called. This function will not throw.
4681  * @param cb The callback object. Ownership is taken of this object,
4682  * and it will be deleted when it has been finished with.
4683  * @param priority The priority to be given to the callback in the
4684  * main loop. In ascending order of priorities, priorities are
4685  * G_PRIORITY_LOW, G_PRIORITY_DEFAULT_IDLE, G_PRIORITY_HIGH_IDLE,
4686  * G_PRIORITY_DEFAULT and G_PRIORITY_HIGH. The default is
4687  * G_PRIORITY_DEFAULT_IDLE. This determines the order in which the
4688  * callback will appear in the event list in the main loop, not the
4689  * priority which the OS will adopt
4690  * @param context The glib main loop context in which the callback is
4691  * to be executed (the default of NULL will cause the callback to be
4692  * executed in the main program loop, and this is usually what is
4693  * wanted).
4694  * @note 1. Cancellation of the receiving thread is blocked when the
4695  * callback executes.
4696  * @note 2. If the callback throws an exception, the exception will be
4697  * consumed to protect the main loop and a g_critical() warning will
4698  * be issued.
4699  *
4700  * Since 0.9.2 choice of main context available.
4701  */
4702 void post(const Callback* cb, gint priority = G_PRIORITY_DEFAULT_IDLE,
4703  GMainContext* context = 0);
4704 
4705 /**
4706  * Posts a callback for execution by a glib main loop. It is
4707  * thread-safe provided that (if glib < 2.32 is used) g_thread_init()
4708  * has been called. glib >= 2.32 does not require g_thread_init() to
4709  * be called. This function will not throw.
4710  * @param cb The callback object. Ownership is taken of this object,
4711  * and it will be deleted when it has been finished with.
4712  * @param r A Releaser object for automatic disconnection of the
4713  * callback before it executes in the main loop (mainly relevant if
4714  * the callback represents a non-static member function of an object
4715  * which may be destroyed before the callback executes).
4716  * @param priority The priority to be given to the callback in the
4717  * main loop. In ascending order of priorities, priorities are
4718  * G_PRIORITY_LOW, G_PRIORITY_DEFAULT_IDLE, G_PRIORITY_HIGH_IDLE,
4719  * G_PRIORITY_DEFAULT and G_PRIORITY_HIGH. The default is
4720  * G_PRIORITY_DEFAULT_IDLE. This determines the order in which the
4721  * callback will appear in the event list in the main loop, not the
4722  * priority which the OS will adopt.
4723  * @param context The glib main loop context in which the callback is
4724  * to be executed (the default of NULL will cause the callback to be
4725  * executed in the main program loop, and this is usually what is
4726  * wanted).
4727  * @exception std::bad_alloc This function might throw std::bad_alloc
4728  * if memory is exhausted and the system throws in that case. If it
4729  * does so, the Callback object will be disposed of.
4730  * @exception Cgu::Thread::MutexError This function might throw
4731  * Cgu:Thread::MutexError if initialisation of the mutex in a
4732  * SafeEmitterArg object constructed by this function fails. If it
4733  * does so, the Callback object will be disposed of. (It is often not
4734  * worth checking for this exception, as it means either memory is
4735  * exhausted or pthread has run out of other resources to create new
4736  * mutexes.)
4737  * @note 1. Cancellation of the receiving thread is blocked when the
4738  * callback executes.
4739  * @note 2. If the callback throws an exception, the exception will be
4740  * consumed to protect the main loop and a g_critical() warning will
4741  * be issued.
4742  * @note 3. By virtue of the Releaser object, it is in theory possible
4743  * (if memory is exhausted and the system throws in that case) that an
4744  * internal SafeEmitterArg object will throw std::bad_alloc when
4745  * emitting/executing the callback in the glib main loop, with the
4746  * result that the relevant callback will not execute (instead the
4747  * exception will be consumed and a g_critical() warning will be
4748  * issued). This is rarely of any relevance because glib will abort
4749  * the program if it is itself unable to obtain memory from the
4750  * operating system. However, where it is relevant, design the
4751  * program so that it is not necessary to provide a releaser object.
4752  *
4753  * Since 0.9.2 choice of main context available.
4754  */
4755 void post(const Callback* cb, Releaser& r,
4756  gint priority = G_PRIORITY_DEFAULT_IDLE, GMainContext* context = 0);
4757 
4758 } // namespace Callback
4759 
4760 } // namespace Cgu
4761 
4762 #endif
Cgu::Callback::CallbackArg0_const::CallbackArg0_const
CallbackArg0_const(const T &obj_, MemFunc func_)
Definition: callback.h:1762
Cgu::Param
Struct for automatic typing of parameter arguments for template functions.
Definition: param.h:79
Cgu::Callback::Callback1_static_::dispatch
void dispatch() const
Definition: callback.h:2021
Cgu::Callback::CallbackArg0::MemFunc
void(T::* MemFunc)(FreeArg)
Definition: callback.h:1538
Cgu::Callback::Callback
CallbackArg< void > Callback
Definition: callback.h:904
Cgu::Callback::CallbackArg1_static_::CallbackArg1_static_
CallbackArg1_static_(Func func_, typename Cgu::Param< BoundArg >::ParamType arg_)
Definition: callback.h:2036
Cgu::Callback::Callback2_::Callback2_
Callback2_(T &obj_, MemFunc func_, typename Cgu::Param< BoundArg1 >::ParamType arg1_, typename Cgu::Param< BoundArg2 >::ParamType arg2_)
Definition: callback.h:1668
Cgu::Callback::CallbackArg
The callback interface class.
Definition: callback.h:904
Cgu::Callback::CallbackArg1_::CallbackArg1_
CallbackArg1_(T &obj_, MemFunc func_, typename Cgu::Param< BoundArg >::ParamType arg_)
Definition: callback.h:1612
Cgu::Callback::Callback0::dispatch
void dispatch() const
Definition: callback.h:1531
Cgu
Definition: application.h:45
Cgu::Callback::CallbackArg0::dispatch
void dispatch(typename Cgu::Param< FreeArg >::ParamType free_arg) const
Definition: callback.h:1543
Cgu::Callback::Functor
FunctorArg< void > Functor
Definition: callback.h:1078
Cgu::Callback::Callback2_::MemFunc
void(T::* MemFunc)(BoundArg1, BoundArg2)
Definition: callback.h:1660
Cgu::Callback::CallbackArg0_static::dispatch
void dispatch(typename Cgu::Param< FreeArg >::ParamType free_arg) const
Definition: callback.h:1972
Cgu::Callback::Callback2_const_::Callback2_const_
Callback2_const_(const T &obj_, MemFunc func_, typename Cgu::Param< BoundArg1 >::ParamType arg1_, typename Cgu::Param< BoundArg2 >::ParamType arg2_)
Definition: callback.h:1884
Cgu::Callback::operator<
bool operator<(const FunctorArg< T > &f1, const FunctorArg< T > &f2)
Definition: callback.h:1122
Cgu::Callback::Callback2_const_::dispatch
void dispatch() const
Definition: callback.h:1883
Cgu::Callback::FunctorArg::FunctorArg
FunctorArg(const CallbackArg< FreeArg > *cb)
Definition: callback.h:1273
Cgu::Callback::CallbackArg1_const_::MemFunc
void(T::* MemFunc)(BoundArg, FreeArg) const
Definition: callback.h:1819
Cgu::Callback::CallbackArg2_static_::dispatch
void dispatch(typename Cgu::Param< FreeArg >::ParamType free_arg) const
Definition: callback.h:2099
Cgu::Callback::CallbackArg1_static_::Func
void(* Func)(BoundArg, FreeArg)
Definition: callback.h:2028
Cgu::Callback::CallbackArg::~CallbackArg
virtual ~CallbackArg()
Definition: callback.h:991
Cgu::Callback::CallbackArg0_static::Func
void(* Func)(FreeArg)
Definition: callback.h:1968
shared_ptr.h
Cgu::Callback::Callback1_static_
Definition: callback.h:2014
Cgu::Callback::Callback0::MemFunc
void(T::* MemFunc)()
Definition: callback.h:1526
Cgu::Callback::Callback0_const
Definition: callback.h:1740
Cgu::Callback::CallbackArg1_const_
Definition: callback.h:1817
Cgu::Callback::operator!=
bool operator!=(const FunctorArg< T > &f1, const FunctorArg< T > &f2)
Definition: callback.h:1104
Cgu::Callback::Callback0_static::dispatch
void dispatch() const
Definition: callback.h:1961
Cgu::Callback::CallbackArg1_const_::dispatch
void dispatch(typename Cgu::Param< FreeArg >::ParamType free_arg) const
Definition: callback.h:1825
Cgu::Callback::CallbackArg2_const_
Definition: callback.h:1890
Cgu::Callback::Callback1_static_::Func
void(* Func)(BoundArg)
Definition: callback.h:2016
Cgu::Callback::CallbackArg0_const::dispatch
void dispatch(typename Cgu::Param< FreeArg >::ParamType free_arg) const
Definition: callback.h:1759
Cgu::Callback::Callback0_static::Func
void(* Func)()
Definition: callback.h:1957
Cgu::Callback::CallbackArg1_static_
Definition: callback.h:2026
Cgu::Callback::make_ref
Callback * make_ref(T &t, void(T::*func)())
Definition: callback.h:2414
Cgu::Callback::CallbackArg0_const
Definition: callback.h:1752
Cgu::Callback::make_val
Callback * make_val(T &t, void(T::*func)())
Definition: callback.h:2396
Cgu::Callback::CallbackArg2_static_::CallbackArg2_static_
CallbackArg2_static_(Func func_, typename Cgu::Param< BoundArg1 >::ParamType arg1_, typename Cgu::Param< BoundArg2 >::ParamType arg2_)
Definition: callback.h:2102
Cgu::Callback::Callback1_::Callback1_
Callback1_(T &obj_, MemFunc func_, typename Cgu::Param< BoundArg >::ParamType arg_)
Definition: callback.h:1596
Cgu::Callback::make
Callback * make(T &t, void(T::*func)())
Definition: callback.h:2376
Cgu::Callback::Callback0_const::dispatch
void dispatch() const
Definition: callback.h:1747
Cgu::Callback::Callback0_static::Callback0_static
Callback0_static(Func func_)
Definition: callback.h:1962
Cgu::Callback::Callback1_::MemFunc
void(T::* MemFunc)(BoundArg)
Definition: callback.h:1589
Cgu::Callback::Callback2_static_
Definition: callback.h:2077
Cgu::Callback::CallbackArg0_const::MemFunc
void(T::* MemFunc)(FreeArg) const
Definition: callback.h:1754
Cgu::Callback::CallbackArg0::CallbackArg0
CallbackArg0(T &obj_, MemFunc func_)
Definition: callback.h:1546
Cgu::RemoveRefCond
Struct which will conditionally convert a reference type to a value type.
Definition: param.h:106
Cgu::Callback::Callback1_::dispatch
void dispatch() const
Definition: callback.h:1595
Cgu::Callback::CallbackArg::CallbackArg
CallbackArg()
Definition: callback.h:985
Cgu::SharedPtr
This is a smart pointer for managing the lifetime of objects allocated on freestore.
Definition: shared_ptr.h:166
Cgu::Callback::FunctorArg::FunctorArg
FunctorArg()
Definition: callback.h:1286
Cgu::Callback::SafeFunctor
SafeFunctorArg< void > SafeFunctor
Definition: callback.h:1080
Cgu::SharedPtr::get
T * get() const
Definition: shared_ptr.h:409
Cgu::Callback::CallbackArg2_static_
Definition: callback.h:2091
param.h
Cgu::Callback::CallbackArg2_const_::MemFunc
void(T::* MemFunc)(BoundArg1, BoundArg2, FreeArg) const
Definition: callback.h:1892
Cgu::Callback::CallbackArg2_const_::CallbackArg2_const_
CallbackArg2_const_(const T &obj_, MemFunc func_, typename Cgu::Param< BoundArg1 >::ParamType arg1_, typename Cgu::Param< BoundArg2 >::ParamType arg2_)
Definition: callback.h:1902
Cgu::Callback::Callback2_static_::Func
void(* Func)(BoundArg1, BoundArg2)
Definition: callback.h:2079
Cgu::Callback::Callback0_const::Callback0_const
Callback0_const(const T &obj_, MemFunc func_)
Definition: callback.h:1748
Cgu::Callback::CallbackArg2_::MemFunc
void(T::* MemFunc)(BoundArg1, BoundArg2, FreeArg)
Definition: callback.h:1676
Cgu::Callback::Callback1_const_
Definition: callback.h:1803
Cgu::Callback::CallbackArg2_const_::dispatch
void dispatch(typename Cgu::Param< FreeArg >::ParamType free_arg) const
Definition: callback.h:1899
Cgu::Callback::Callback0_static
Definition: callback.h:1955
Cgu::Callback::SafeFunctorArg
Functor class holding a Callback::CallbackArg object, with thread-safe reference count.
Definition: callback.h:1078
Cgu::Callback::CallbackArg0
Definition: callback.h:1536
Cgu::Callback::Callback2_const_
Definition: callback.h:1874
Cgu::Callback::CallbackArg2_static_::Func
void(* Func)(BoundArg1, BoundArg2, FreeArg)
Definition: callback.h:2093
Cgu::Callback::CallbackArg1_static_::dispatch
void dispatch(typename Cgu::Param< FreeArg >::ParamType free_arg) const
Definition: callback.h:2033
Cgu::Callback::Callback0_const::MemFunc
void(T::* MemFunc)() const
Definition: callback.h:1742
Cgu::Callback::CallbackArg0_static::CallbackArg0_static
CallbackArg0_static(Func func_)
Definition: callback.h:1975
CGU_GLIB_MEMORY_SLICES_FUNCS
#define CGU_GLIB_MEMORY_SLICES_FUNCS
Definition: cgu_config.h:84
Cgu::Callback::SafeFunctorArg::SafeFunctorArg
SafeFunctorArg(const CallbackArg< FreeArg > *cb)
Definition: callback.h:1431
Cgu::Callback::CallbackArg1_::MemFunc
void(T::* MemFunc)(BoundArg, FreeArg)
Definition: callback.h:1603
Cgu::Callback::Callback1_const_::Callback1_const_
Callback1_const_(const T &obj_, MemFunc func_, typename Cgu::Param< BoundArg >::ParamType arg_)
Definition: callback.h:1812
Cgu::Callback::Callback1_const_::dispatch
void dispatch() const
Definition: callback.h:1811
Cgu::SharedLockPtr
This is a smart pointer for managing the lifetime of objects allocated on freestore,...
Definition: shared_ptr.h:513
Cgu::Callback::Callback1_const_::MemFunc
void(T::* MemFunc)(BoundArg) const
Definition: callback.h:1805
Cgu::Callback::CallbackArg1_::dispatch
void dispatch(typename Cgu::Param< FreeArg >::ParamType free_arg) const
Definition: callback.h:1609
Cgu::Callback::CallbackArg2_::CallbackArg2_
CallbackArg2_(T &obj_, MemFunc func_, typename Cgu::Param< BoundArg1 >::ParamType arg1_, typename Cgu::Param< BoundArg2 >::ParamType arg2_)
Definition: callback.h:1686
Cgu::TypeTuple
Struct type to provide unbound arguments for Callback::CallbackArg objects.
Definition: param.h:155
Cgu::Callback::Callback1_static_::Callback1_static_
Callback1_static_(Func func_, typename Cgu::Param< BoundArg >::ParamType arg_)
Definition: callback.h:2022
Cgu::Callback::FunctorArg
Functor class holding a Callback::CallbackArg object.
Definition: callback.h:1077
Cgu::Callback::Callback2_const_::MemFunc
void(T::* MemFunc)(BoundArg1, BoundArg2) const
Definition: callback.h:1876
Cgu::Callback::SafeFunctorArg::SafeFunctorArg
SafeFunctorArg(const SafeFunctorArg &f)
Definition: callback.h:1437
Cgu::Callback::CallbackArg2_::dispatch
void dispatch(typename Cgu::Param< FreeArg >::ParamType free_arg) const
Definition: callback.h:1683
Cgu::Callback::CallbackArg2_
Definition: callback.h:1674
Cgu::Callback::CallbackArg1_
Definition: callback.h:1601
Cgu::Callback::SafeFunctorArg::SafeFunctorArg
SafeFunctorArg()
Definition: callback.h:1449
Cgu::Callback::Callback0
Definition: callback.h:1524
Cgu::Callback::CallbackArg1_const_::CallbackArg1_const_
CallbackArg1_const_(const T &obj_, MemFunc func_, typename Cgu::Param< BoundArg >::ParamType arg_)
Definition: callback.h:1828
Cgu::Callback::Callback2_::dispatch
void dispatch() const
Definition: callback.h:1667
Cgu::Callback::Callback2_static_::Callback2_static_
Callback2_static_(Func func_, typename Cgu::Param< BoundArg1 >::ParamType arg1_, typename Cgu::Param< BoundArg2 >::ParamType arg2_)
Definition: callback.h:2086
Cgu::Callback::CallbackArg0_static
Definition: callback.h:1966
Cgu::Callback::FunctorArg::operator()
void operator()(typename Cgu::Param< FreeArg >::ParamType arg) const
Definition: callback.h:1238
Cgu::Callback::Callback0::Callback0
Callback0(T &obj_, MemFunc func_)
Definition: callback.h:1532
Cgu::Callback::Callback2_
Definition: callback.h:1658
Cgu::Callback::Callback1_
Definition: callback.h:1587
Cgu::Callback::operator==
bool operator==(const FunctorArg< T > &f1, const FunctorArg< T > &f2)
Definition: callback.h:1092
Cgu::Callback::FunctorArg::FunctorArg
FunctorArg(const FunctorArg &f)
Definition: callback.h:1279
cgu_config.h
Cgu::Callback::post
void post(const Callback *cb, gint priority=G_PRIORITY_DEFAULT_IDLE, GMainContext *context=0)
Cgu::Callback::CallbackArg::dispatch
virtual void dispatch(typename Cgu::Param< FreeArg >::ParamType arg) const =0
Cgu::Callback::SafeFunctorArg::operator()
void operator()(typename Cgu::Param< FreeArg >::ParamType arg) const
Definition: callback.h:1396
Cgu::Callback::Callback2_static_::dispatch
void dispatch() const
Definition: callback.h:2085