diff options
author | Martin Schulze <mschulze@cvs.gnome.org> | 2004-04-12 21:53:37 +0000 |
---|---|---|
committer | Martin Schulze <mschulze@src.gnome.org> | 2004-04-12 21:53:37 +0000 |
commit | cbd1a9ecdbe124e10012aa6b614600f15b76934a (patch) | |
tree | b9ed18c14804da233fdb0e1c3ab80867a4550da7 | |
parent | b29c81927b2e49061245ea02e1325da818265caa (diff) | |
download | sigc++-libsigc++-2.0.0.tar.gz |
Bump version number to 2.0.0. Add ChangeLog summary for version 2.0.0.libsigc++-2.0.0
2004-04-06 Martin Schulze <mschulze@cvs.gnome.org>
* configure.ac: Bump version number to 2.0.0.
* NEWS: Add ChangeLog summary for version 2.0.0.
* TODO, AUTHORS: Bring up to date.
* sigc++-2.0.pc.in, Makefile.am: 1.9 -> 2.0
* Added more documentation.
-rw-r--r-- | AUTHORS | 6 | ||||
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | NEWS | 8 | ||||
-rw-r--r-- | TODO | 10 | ||||
-rw-r--r-- | configure.ac | 6 | ||||
-rw-r--r-- | sigc++-2.0.pc.in | 2 | ||||
-rw-r--r-- | sigc++/adaptors/lambda/macros/base.h.m4 | 22 | ||||
-rw-r--r-- | sigc++/adaptors/lambda/macros/group.h.m4 | 61 | ||||
-rw-r--r-- | sigc++/adaptors/macros/bind.h.m4 | 15 | ||||
-rw-r--r-- | sigc++/adaptors/macros/bind_return.h.m4 | 38 | ||||
-rw-r--r-- | sigc++/adaptors/macros/compose.h.m4 | 96 | ||||
-rw-r--r-- | sigc++/adaptors/macros/exception_catch.h.m4 | 71 | ||||
-rw-r--r-- | sigc++/adaptors/macros/hide.h.m4 | 10 | ||||
-rw-r--r-- | sigc++/adaptors/macros/retype.h.m4 | 85 | ||||
-rw-r--r-- | sigc++/adaptors/macros/retype_return.h.m4 | 45 | ||||
-rw-r--r-- | sigc++/connection.h | 15 | ||||
-rw-r--r-- | sigc++/functors/macros/functor_trait.h.m4 | 40 | ||||
-rw-r--r-- | sigc++/functors/slot_base.h | 31 | ||||
-rw-r--r-- | sigc++/macros/method_slot.h.m4 | 3 | ||||
-rw-r--r-- | sigc++/macros/object_slot.h.m4 | 5 | ||||
-rw-r--r-- | sigc++/macros/signal.h.m4 | 3 | ||||
-rw-r--r-- | sigc++/macros/slot.h.m4 | 8 | ||||
-rw-r--r-- | sigc++/reference_wrapper.h | 26 | ||||
-rw-r--r-- | sigc++/trackable.cc | 7 |
25 files changed, 548 insertions, 77 deletions
@@ -1 +1,5 @@ -Karl Einar Nelson <kenelson@ece.ucdavis.edu> +Martin Schulze <mschulze@cvs.gnome.org> +Murray Cumming <murrayc@murrayc.com> +Cedric Gustin <cedric.gustin@swing.be> (win32 support) +Andreas Rottmann <rottmann@users.sourceforge.net> (make system) +Karl Einar Nelson <kenelson@ece.ucdavis.edu> (initial version 1.9.4) @@ -1,3 +1,13 @@ +2.0.0: + +2004-04-06 Martin Schulze <mschulze@cvs.gnome.org> + + * configure.ac: Bump version number to 2.0.0. + * NEWS: Add ChangeLog summary for version 2.0.0. + * TODO, AUTHORS: Bring up to date. + * sigc++-2.0.pc.in, Makefile.am: 1.9 -> 2.0 + * Added more documentation. + 2004-04-10 Murray Cumming <murrayc@murrayc.com> * sigc++/connection.[h|cc]: Implement blocked() to avoid undefined diff --git a/Makefile.am b/Makefile.am index 928119b..78d4819 100644 --- a/Makefile.am +++ b/Makefile.am @@ -7,7 +7,7 @@ EXTRA_DIST = autogen.sh sigc++config.h.in SUBDIRS = sigc++ tests docs examples scripts DIST_SUBDIRS = $(SUBDIRS) MSVC_Net2003 -sigc_configdir = $(libdir)/sigc++-1.9/include +sigc_configdir = $(libdir)/sigc++-2.0/include sigc_config_DATA = sigc++config.h pkgconfigdir = $(libdir)/pkgconfig @@ -1,4 +1,4 @@ -*** libsigc++ 2.0 (unstable): +*** libsigc++ 2.0: libsigc++ implements a typesafe callback system for standard C++. It allows you to define signals and to connect those signals to any @@ -17,6 +17,12 @@ This version of libsigc++ needs GNU g++ 3.2 or higher to compile. *** ChangeLog summary: +2.0.0: + +* Implemented sigc::connection::blocked() (Murray Cumming). +* Added the scripts directory to the make dist target (Murray Cumming). +* Added more documentation (Martin Schulze). + 1.9.16: * Fixed compiler warning in sigc::connection (Alexander Nedotsukov, Murray Cumming). @@ -1,13 +1,9 @@ -Configure checks and Makefile issues: +Compatibility: -- Add header sigcconfig.h like we have in libsigc++-1.2 ? +- Fix compilation for SUN FORTE C++ 5.5. -- Add return codes to "make check" so that the user doesn't need to - analyze the code to see what the heck it is supposed to do to ensure - it passed. (Karl Nelson) -- Find out what compiler features apart from typeof() should be made optional. - Add configure checks. +Configure checks and Makefile issues: - When you use a single Makefile.am for several directories (in sigc++2, all under sigc++/ is ruled by a diff --git a/configure.ac b/configure.ac index 3ef22e4..333e3ee 100644 --- a/configure.ac +++ b/configure.ac @@ -9,9 +9,9 @@ AC_INIT(sigc++) dnl This version stuff is just for the packaging section of the tool. dnl thus make format_package-0.0.1.tar.gz -FP_MAJOR_VERSION=1 -FP_MINOR_VERSION=9 -FP_MICRO_VERSION=16 +FP_MAJOR_VERSION=2 +FP_MINOR_VERSION=0 +FP_MICRO_VERSION=0 FP_VERSION=$FP_MAJOR_VERSION.$FP_MINOR_VERSION.$FP_MICRO_VERSION dnl For automake. diff --git a/sigc++-2.0.pc.in b/sigc++-2.0.pc.in index 231b4b8..7c55753 100644 --- a/sigc++-2.0.pc.in +++ b/sigc++-2.0.pc.in @@ -7,4 +7,4 @@ Name: libsigc++ 2 Description: Typesafe signal and callback system for C++ Version: @VERSION@ Libs: -L${libdir} -lsigc-2.0 -Cflags: -I${includedir}/sigc++-2.0 -I${libdir}/sigc++-1.9/include +Cflags: -I${includedir}/sigc++-2.0 -I${libdir}/sigc++-2.0/include diff --git a/sigc++/adaptors/lambda/macros/base.h.m4 b/sigc++/adaptors/lambda/macros/base.h.m4 index f038f03..5197998 100644 --- a/sigc++/adaptors/lambda/macros/base.h.m4 +++ b/sigc++/adaptors/lambda/macros/base.h.m4 @@ -53,6 +53,28 @@ divert(0)dnl namespace sigc { +/** @defgroup lambdas Lambdas + * libsigc++ ships with basic lambda functionality and the sigc::group adaptor that uses lambdas to transform a functor's parameter list. + * + * The lambda selectors sigc::_1, sigc::_2, ..., sigc::_9 are used to select the + * first, second, ..., nineth argument from a list. + * + * @par Examples: + * @code + * std::cout << sigc::_1(10,20,30); // returns 10 + * std::cout << sigc::_2(10,20,30); // returns 20 + * ... + * @endcode + * + * Operators are defined so that lambda selectors can be used e.g. as placeholders in + * arithmetic expressions. + * + * @par Examples: + * @code + * std::cout << (sigc::_1 + 5)(3); // returns (3 + 5) + * std::cout << (sigc::_1 * sigc::_2)(7,10); // returns (7 * 10) + */ + // dummy structure to keep track of the where we are. struct lambda_base : public adaptor_base {}; diff --git a/sigc++/adaptors/lambda/macros/group.h.m4 b/sigc++/adaptors/lambda/macros/group.h.m4 index 1aa3069..7ff3d3e 100644 --- a/sigc++/adaptors/lambda/macros/group.h.m4 +++ b/sigc++/adaptors/lambda/macros/group.h.m4 @@ -101,6 +101,67 @@ divert(0)dnl __FIREWALL__ #include <sigc++/adaptors/lambda/base.h> +/** @defgroup group_ group() + * sigc::group() alters an arbitrary functor by rebuilding its arguments from one or more lambda expressions. + * For each parameter that should be passed to the wrapped functor one lambda expression + * has to be passed into group(). Lambda selectors can be used as placeholders for the + * arguments passed into the new functor. Arguments that don't have a placeholder in one + * of the lambda expressions are dropped. + * + * @par Examples: + * @code + * void foo(int, int); + * int bar(int); + * // argument binding ... + * sigc::group(&foo,10,sigc::_1)(20); //fixes the first argument and calls foo(10,20) + * sigc::group(&foo,sigc::_1,30)(40); //fixes the second argument and calls foo(40,30) + * // argument reordering ... + * sigc::group(&foo,sigc::_2,sigc::_1)(1,2); //calls foo(2,1) + * // argument hiding ... + * sigc::group(&foo,sigc::_1,sigc::_2)(1,2,3); //calls foo(1,2) + * // functor composition ... + * sigc::group(&foo,sigc::_1,sigc::group(&bar,sigc::_2))(1,2); //calls foo(1,bar(2)) + * // algebraic expressions ... + * sigc::group(&foo,sigc::_1*sigc::_2,sigc::_1/sigc::_2)(6,3); //calls foo(6*3,6/3) + * @endcode + * + * The functor sigc::group() returns can be passed into + * sigc::signal::connect() directly. + * + * @par Example: + * @code + * sigc::signal<void,int,int> some_signal; + * void foo(int); + * some_signal.connect(sigc::group(&foo,sigc::_2)); + * @endcode + * + * Like in sigc::bind() you can bind references to functors by passing the objects + * through the sigc::ref() helper function. + * + * @par Example: + * @code + * int some_int; + * sigc::signal<void> some_signal; + * void foo(int&); + * some_signal.connect(sigc::group(&foo,sigc::ref(some_int))); + * @endcode + * + * If you bind an object of a sigc::trackable derived type to a functor + * by reference, a slot assigned to the group adaptor is cleared automatically + * when the object goes out of scope. + * + * @par Example: + * @code + * struct bar : public sigc::trackable {} some_bar; + * sigc::signal<void> some_signal; + * void foo(bar&); + * some_signal.connect(sigc::group(&foo,sigc::ref(some_bar))); + * // disconnected automatically if some_bar goes out of scope + * @endcode + * + * @ingroup adaptors, lambdas + */ + namespace sigc { FOR(1,3,[[LAMBDA_GROUP(%1, CALL_SIZE)]]) diff --git a/sigc++/adaptors/macros/bind.h.m4 b/sigc++/adaptors/macros/bind.h.m4 index 470046e..549476d 100644 --- a/sigc++/adaptors/macros/bind.h.m4 +++ b/sigc++/adaptors/macros/bind.h.m4 @@ -200,7 +200,7 @@ __FIREWALL__ namespace sigc { -/** @defgroup bind bind() +/** @defgroup bind bind(), bind_return() * sigc::bind() alters an arbitrary functor by fixing arguments to certain values. * Up to CALL_SIZE arguments can be bound at a time. * For single argument binding overloads of sigc::bind() are provided that let you @@ -232,6 +232,15 @@ namespace sigc { * some_signal.connect(sigc::bind(&foo,1)); * @endcode * + * sigc::bind_return() alters an arbitrary functor by + * fixing its return value to a certain value. + * + * @par Example: + * @code + * void foo(); + * std::cout << sigc::bind_return(&foo, 5)(); // calls foo() and returns 5 + * @endcode + * * You can bind references to functors by passing the objects through * the sigc::ref() helper function. * @@ -266,7 +275,7 @@ namespace sigc { */ /** Adaptor that binds an argument to the wrapped functor. - * Use the convenience function bind() to create an instance of bind_functor. + * Use the convenience function sigc::bind() to create an instance of sigc::bind_functor. * * The following template arguments are used: * - @e I_location Zero-based position of the argument to fix (@p -1 for the last argument). @@ -302,7 +311,7 @@ FOR(1,CALL_SIZE,[[BIND_FUNCTOR_COUNT(%1)]])dnl * * @param _A_func Functor that should be wrapped. * @param _A_b1 Argument to bind to @e _A_func. - * @return Adaptor that executes _A_func with the bound argument on invokation. + * @return Adaptor that executes @e _A_func with the bound argument on invokation. * * @ingroup bind */ diff --git a/sigc++/adaptors/macros/bind_return.h.m4 b/sigc++/adaptors/macros/bind_return.h.m4 index 79f2eed..b5b010d 100644 --- a/sigc++/adaptors/macros/bind_return.h.m4 +++ b/sigc++/adaptors/macros/bind_return.h.m4 @@ -19,6 +19,11 @@ divert(-1) include(template.macros.m4) define([BIND_RETURN_OPERATOR],[dnl + /** Invokes the wrapped functor passing on the arguments.dnl +FOR(1, $1),[ + * @param _A_arg%1 Argument to be passed on to the functor.]) + * @return The fixed return value. + */ template <LOOP(class T_arg%1, $1)> inline T_return operator()(LOOP(T_arg%1 _A_a%1, $1)) { this->functor_.LIBSIGC_TEMPLATE_PREFIX SIGC_WORKAROUND_OPERATOR_PARENTHESES<LOOP(_P_(T_arg%1), $1)> @@ -39,6 +44,15 @@ __FIREWALL__ namespace sigc { +/** Adaptor that fixes the return value of the wrapped functor. + * Use the convenience function sigc::bind_return() to create an instance of sigc::bind_return_functor. + * + * The following template arguments are used: + * - @e T_return Type of the fixed return value. + * - @e T_functor Type of the functor to wrap. + * + * @ingroup bind + */ template <class T_return, class T_functor> struct bind_return_functor : public adapts<T_functor> { @@ -47,14 +61,22 @@ struct bind_return_functor : public adapts<T_functor> { typedef T_return type; }; typedef T_return result_type; + /** Invokes the wrapped functor dropping its return value. + * @return The fixed return value. + */ T_return operator()(); FOR(1,CALL_SIZE,[[BIND_RETURN_OPERATOR(%1)]])dnl - bind_return_functor() {} + + /** Constructs a bind_return_functor object that fixes the return value to @p _A_ret_value. + * @param _A_functor Functor to invoke from operator()(). + * @param _A_ret_value Value to return from operator()(). + */ bind_return_functor(_R_(T_functor) _A_functor, _R_(T_return) _A_ret_value) : adapts<T_functor>(_A_functor), ret_value_(_A_ret_value) {} + /// The fixed return value. T_return ret_value_; // public, so that visit_each() can access it }; @@ -63,6 +85,12 @@ T_return bind_return_functor<T_return, T_functor>::operator()() { this->functor_(); return ret_value_; } +/** Performs a functor on each of the targets of a functor. + * The function overload for sigc::bind_return_functor performs a functor on the + * functor and on the object instance stored in the sigc::bind_return_functor object. + * + * @ingroup bind + */ template <class T_action, class T_return, class T_functor> void visit_each(const T_action& _A_action, const bind_return_functor<T_return, T_functor>& _A_target) @@ -72,6 +100,14 @@ void visit_each(const T_action& _A_action, } +/** Creates an adaptor of type sigc::bind_return_functor which fixes the return value of the passed functor to the passed argument. + * + * @param _A_functor Functor that should be wrapped. + * @param _A_ret_value Argument to fix the return value of @e _A_functor to. + * @return Adaptor that executes @e _A_functor on invokation and returns @e _A_ret_value. + * + * @ingroup bind + */ template <class T_return, class T_functor> inline bind_return_functor<typename unwrap_reference<T_return>::type, T_functor> bind_return(const T_functor& _A_functor, T_return _A_ret_value) diff --git a/sigc++/adaptors/macros/compose.h.m4 b/sigc++/adaptors/macros/compose.h.m4 index 9a94363..a89764f 100644 --- a/sigc++/adaptors/macros/compose.h.m4 +++ b/sigc++/adaptors/macros/compose.h.m4 @@ -45,6 +45,46 @@ __FIREWALL__ namespace sigc { +/** @defgroup compose compose() + * sigc::compose() combines two or three arbitrary functors. + * On invokation parameters are passed on to one or two getter functor(s). + * The return value(s) are then passed on to the setter function. + * + * @par Examples: + * @code + * float square_root(float a) { return sqrtf(a); } + * float sum(float a, float b) { return a+b; } + * std::cout << sigc::compose(&square_root, &sum)(9, 16); // calls square_root(sum(3,6)) + * std::cout << sigc::compose(&sum, &square_root, &square_root)(9); // calls sum(square_root(9), square_root(9)) + * @endcode + * + * The functor sigc::compose() returns can be passed into + * sigc::signal::connect() directly. + * + * @par Example: + * @code + * sigc::signal<float,float,float> some_signal; + * some_signal.connect(sigc::compose(&square_root, &sum)); + * @endcode + * + * For a more powerful version of this functionality see the lambda + * library adaptor sigc::group() which can bind, hide and reorder + * arguments arbitrarily. Although sigc::group() is more flexible, + * sigc::bind() provides a means of binding parameters when then total + * number of parameters called is variable. + * + * @ingroup adaptors + */ + +/** Adaptor that combines two functors. + * Use the convenience function sigc::compose() to create an instance of sigc::compose1_functor. + * + * The following template arguments are used: + * - @e T_setter Type of the setter functor to wrap. + * - @e T_getter Type of the getter functor to wrap. + * + * @ingroup compose + */ template <class T_setter, class T_getter> struct compose1_functor : public adapts<T_setter> { @@ -61,11 +101,15 @@ struct compose1_functor : public adapts<T_setter> operator()(); FOR(1,CALL_SIZE,[[COMPOSE1_OPERATOR(%1)]])dnl - compose1_functor() {} + + /** Constructs a compose1_functor object that combines the passed functors. + * @param _A_setter Functor that receives the return values of the invokation of @e _A_getter1 and @e _A_getter2. + * @param _A_getter1 Functor to invoke from operator()(). + * @param _A_getter2 Functor to invoke from operator()(). + */ compose1_functor(const T_setter& _A_setter, const T_getter& _A_getter) : adapts<T_setter>(_A_setter), get_(_A_getter) {} - ~compose1_functor() {} T_getter get_; // public, so that visit_each() can access it }; @@ -75,6 +119,16 @@ typename compose1_functor<T_setter, T_getter>::result_type compose1_functor<T_setter, T_getter>::operator()() { return this->functor_(get_()); } +/** Adaptor that combines three functors. + * Use the convenience function sigc::compose() to create an instance of sigc::compose2_functor. + * + * The following template arguments are used: + * - @e T_setter Type of the setter functor to wrap. + * - @e T_getter1 Type of the first getter functor to wrap. + * - @e T_getter2 Type of the second getter functor to wrap. + * + * @ingroup compose + */ template <class T_setter, class T_getter1, class T_getter2> struct compose2_functor : public adapts<T_setter> { @@ -92,13 +146,17 @@ struct compose2_functor : public adapts<T_setter> operator()(); FOR(1,CALL_SIZE,[[COMPOSE2_OPERATOR(%1)]])dnl - compose2_functor() {} + + /** Constructs a compose2_functor object that combines the passed functors. + * @param _A_setter Functor that receives the return values of the invokation of @e _A_getter1 and @e _A_getter2. + * @param _A_getter1 Functor to invoke from operator()(). + * @param _A_getter2 Functor to invoke from operator()(). + */ compose2_functor(const T_setter& _A_setter, const T_getter1& _A_getter1, const T_getter2& _A_getter2) : adapts<T_setter>(_A_setter), get1_(_A_getter1), get2_(_A_getter2) {} - ~compose2_functor() {} T_getter1 get1_; // public, so that visit_each() can access it T_getter2 get2_; // public, so that visit_each() can access it @@ -110,7 +168,12 @@ compose2_functor<T_setter, T_getter1, T_getter2>::operator()() { return this->functor_(get1_(), get2_()); } -// declare how to access targets +/** Performs a functor on each of the targets of a functor. + * The function overload for sigc::compose1_functor performs a functor on the + * functors stored in the sigc::compose1_functor object. + * + * @ingroup compose + */ template <class T_action, class T_setter, class T_getter> void visit_each(const T_action& _A_action, const compose1_functor<T_setter, T_getter>& _A_target) @@ -119,6 +182,12 @@ void visit_each(const T_action& _A_action, visit_each(_A_action, _A_target.get_); } +/** Performs a functor on each of the targets of a functor. + * The function overload for sigc::compose2_functor performs a functor on the + * functors stored in the sigc::compose2_functor object. + * + * @ingroup compose + */ template <class T_action, class T_setter, class T_getter1, class T_getter2> void visit_each(const T_action& _A_action, const compose2_functor<T_setter, T_getter1, T_getter2>& _A_target) @@ -129,11 +198,28 @@ void visit_each(const T_action& _A_action, } +/** Creates an adaptor of type sigc::compose1_functor which combines two functors. + * + * @param _A_setter Functor that receives the return value of the invokation of @e _A_getter. + * @param _A_getter Functor to invoke from operator()(). + * @return Adaptor that executes @e _A_setter with the value returned from invokation of @e _A_getter. + * + * @ingroup compose + */ template <class T_setter, class T_getter> inline compose1_functor<T_setter, T_getter> compose(const T_setter& _A_setter, const T_getter& _A_getter) { return compose1_functor<T_setter, T_getter>(_A_setter, _A_getter); } +/** Creates an adaptor of type sigc::compose2_functor which combines three functors. + * + * @param _A_setter Functor that receives the return values of the invokation of @e _A_getter1 and @e _A_getter2. + * @param _A_getter1 Functor to invoke from operator()(). + * @param _A_getter2 Functor to invoke from operator()(). + * @return Adaptor that executes @e _A_setter with the values return from invokation of @e _A_getter1 and @e _A_getter2. + * + * @ingroup compose + */ template <class T_setter, class T_getter1, class T_getter2> inline compose2_functor<T_setter, T_getter1, T_getter2> compose(const T_setter& _A_setter, const T_getter1& _A_getter1, const T_getter2& _A_getter2) diff --git a/sigc++/adaptors/macros/exception_catch.h.m4 b/sigc++/adaptors/macros/exception_catch.h.m4 index 16273b7..15be7c8 100644 --- a/sigc++/adaptors/macros/exception_catch.h.m4 +++ b/sigc++/adaptors/macros/exception_catch.h.m4 @@ -35,41 +35,60 @@ define([EXCEPTION_CATCH_OPERATOR],[dnl ]) divert(0)dnl +__FIREWALL__ +#include <sigc++/adaptors/adaptor_trait.h> + +namespace sigc { + /* functor adaptor: exception_catch(functor, catcher) usage: - Allows the user to catch an exception thrown from within - a functor and direct it to a catcher functor. This catcher - can then rethrow the exception and catch it with the proper - type. Note that the catcher is expected to return the - same type as functor was expected to throw so that normal - flow can continue. Catchers can be cascaded to catch multiple - types because uncaught rethrown exceptions proceed to the - next catcher adaptor. - - struct my_catch - { - int operator()() - { - try { throw; } - catch (std::range_error e) // catch what types we know - { cerr << "caught "<< e.what() <<endl; } - return 1; - } - } - int foo(); // throws std::range_error - exception_catch(&foo, my_catch()) (); + Future directions: The catcher should be told what type of return it needs to return for multiple type functors, to do this the user will need to derive from catcher_base. */ -__FIREWALL__ -#include <sigc++/adaptors/adaptor_trait.h> - -namespace sigc { +/** @defgroup exception_catch exception_catch() + * sigc::exception_catch() catches an exception thrown from within + * the wrapped functor and directs it to a catcher functor. + * This catcher can then rethrow the exception and catch it with the proper type. + * + * Note that the catcher is expected to return the same type + * as the wrapped functor so that normal flow can continue. + * + * Catchers can be cascaded to catch multiple types because uncaught + * rethrown exceptions proceed to the next catcher adaptor. + * + * @par Examples: + * @code + * struct my_catch + * { + * int operator()() + * { + * try { throw; } + * catch (std::range_error e) // catch what types we know + * { std::cerr << "caught " << e.what() << std::endl; } + * return 1; + * } + * } + * int foo(); // throws std::range_error + * sigc::exception_catch(&foo, my_catch())(); + * @endcode + * + * The functor sigc::execption_catch() returns can be passed into + * sigc::signal::connect() directly. + * + * @par Example: + * @code + * sigc::signal<int> some_signal; + * some_signal.connect(sigc::exception_catch(&foo, my_catch)); + * @endcode + * + * @ingroup adaptors + */ template <class T_functor, class T_catcher, class T_return = typename adapts<T_functor>::result_type> struct exception_catch_functor : public adapts<T_functor> @@ -85,12 +104,10 @@ struct exception_catch_functor : public adapts<T_functor> operator()(); FOR(1,CALL_SIZE,[[EXCEPTION_CATCH_OPERATOR(%1)]])dnl - exception_catch_functor() {} exception_catch_functor(const T_functor& _A_func, const T_catcher& _A_catcher) : adapts<T_functor>(_A_func), catcher_(_A_catcher) {} - ~exception_catch_functor() {} protected: T_catcher catcher_; diff --git a/sigc++/adaptors/macros/hide.h.m4 b/sigc++/adaptors/macros/hide.h.m4 index 932ea68..71471bc 100644 --- a/sigc++/adaptors/macros/hide.h.m4 +++ b/sigc++/adaptors/macros/hide.h.m4 @@ -122,7 +122,7 @@ __FIREWALL__ namespace sigc { -/** @defgroup hide hide() +/** @defgroup hide hide(), hide_return() * sigc::hide() alters an arbitrary functor in that it adds a parameter * whose value is ignored on invocation of the returned functor. * Thus you can discard one or more of the arguments of a signal. @@ -170,7 +170,7 @@ namespace sigc { */ /** Adaptor that adds a dummy parameter to the wrapped functor. - * Use the convenience function sigc::hide() to create an instance of hide_functor. + * Use the convenience function sigc::hide() to create an instance of sigc::hide_functor. * * The following template arguments are used: * - @e I_location Zero-based position of the dummy parameter (@p -1 for the last parameter). @@ -186,7 +186,7 @@ FOR(-1,eval(CALL_SIZE-1),[[HIDE_FUNCTOR(%1)]])dnl /** Performs a functor on each of the targets of a functor. * The function overload for sigc::hide_functor performs a functor on the - * functor and on the object instances stored in the sigc::hide_functor object. + * functor stored in the sigc::hide_functor object. * * @ingroup hide */ @@ -203,7 +203,7 @@ void visit_each(const T_action& _A_action, * position of the dummy parameter in the returned functor (@p -1 stands for the last parameter). * * @param _A_func Functor that should be wrapped. - * @return Adaptor that executes _A_func ignoring the value of the dummy parameter. + * @return Adaptor that executes @e _A_func ignoring the value of the dummy parameter. * * @ingroup hide */ @@ -216,7 +216,7 @@ hide(const T_functor& _A_func) * This overload adds a dummy parameter at the back of the functor's parameter list. * * @param _A_func Functor that should be wrapped. - * @return Adaptor that executes _A_func ignoring the value of the last parameter. + * @return Adaptor that executes @e _A_func ignoring the value of the last parameter. * * @ingroup hide */ diff --git a/sigc++/adaptors/macros/retype.h.m4 b/sigc++/adaptors/macros/retype.h.m4 index d5b6708..3ef14d1 100644 --- a/sigc++/adaptors/macros/retype.h.m4 +++ b/sigc++/adaptors/macros/retype.h.m4 @@ -40,6 +40,14 @@ ifelse($1,0,[dnl ])dnl ]) define([RETYPE_POINTER_FUNCTOR],[dnl +/** Creates an adaptor of type sigc::retype_functor which performs C-style casts on the parameters passed on to the functor. + * This function template specialization works on sigc::pointer_functor. + * + * @param _A_functor Functor that should be wrapped. + * @return Adaptor that executes @e _A_functor performing C-style casts on the paramters passed on. + * + * @ingroup retype + */ template <LIST(LOOP(class T_arg%1, $1), class T_return)> inline retype_functor<LIST(pointer_functor$1<LIST(LOOP(T_arg%1, $1), T_return)>, LOOP(T_arg%1, $1)) > retype(const pointer_functor$1<LIST(LOOP(T_arg%1, $1), T_return)>& _A_functor) @@ -48,6 +56,14 @@ retype(const pointer_functor$1<LIST(LOOP(T_arg%1, $1), T_return)>& _A_functor) ]) define([RETYPE_MEM_FUNCTOR],[dnl +/** Creates an adaptor of type sigc::retype_functor which performs C-style casts on the parameters passed on to the functor. + * This function template specialization works on sigc::$2[]mem_functor. + * + * @param _A_functor Functor that should be wrapped. + * @return Adaptor that executes @e _A_functor performing C-style casts on the paramters passed on. + * + * @ingroup retype + */ template <LIST(class T_return, class T_obj, LOOP(class T_arg%1, $1))> inline retype_functor<LIST($2[]mem_functor$1<LIST(T_return, T_obj, LOOP(T_arg%1, $1))>, LOOP(T_arg%1, $1)) > retype(const $2[]mem_functor$1<LIST(T_return, T_obj, LOOP(T_arg%1, $1))>& _A_functor) @@ -65,6 +81,56 @@ __FIREWALL__ namespace sigc { +/** @defgroup retype retype(), retype_return() + * sigc::retype() alters a sigc::pointer_functor, a sigc::mem_functor or a sigc::slot + * in that it makes C-style casts to the functor's parameter types + * of all parameters passed through operator()(). + * + * Use this adaptor for inline conversion between numeric or other simple types. + * @par Example: + * @code + * void foo(int); + * sigc::retype(sigc::ptr_fun(&foo))(5.7F); // calls foo(5) + * @endcode + * + * The functor sigc::retype() returns can be passed into + * sigc::signal::connect() directly. + * + * @par Example: + * @code + * sigc::signal<void,float> some_signal; + * void foo(int); + * some_signal.connect(sigc::retype(sigc::ptr_fun(&foo))); + * @endcode + * + * This adaptor builds an exception in that it only works on sig::pointer_functor, + * sigc::mem_functor and sigc::slot because it needs sophisticated information about + * the parameter types that cannot be deduced from arbitrary functor types. + * + * sigc::retype_return() alters the return type of an arbitrary functor. + * Like in sigc::retype() a C-style cast is preformed. Usage sigc::retype_return() is + * not restricted to libsigc++ functor types but you need to + * specify the new return type as a template parameter. + * + * @par Example: + * @code + * float foo(); + * std::cout << sigc::retype_return<int>(&foo)(); // converts foo's return value to an integer + * @endcode + * + * @ingroup adaptors + */ + +/** Adaptor that performs C-style casts on the parameters passed on to the functor. + * Use the convenience function sigc::retype() to create an instance of retype_functor. + * + * The following template arguments are used: + * - @e T_functor Type of the functor to wrap.dnl +FOR(1, CALL_SIZE,[ + * - @e T_type%1 Type of @e T_functor's %1th argument.]) + * + * @ingroup retype + */ template <LIST(class T_functor, LOOP(class T_type%1=nil, CALL_SIZE))> struct retype_functor : public adapts<T_functor> @@ -78,7 +144,10 @@ struct retype_functor FOR(0,CALL_SIZE,[[RETYPE_OPERATOR(%1)]])dnl - retype_functor(typename type_trait<T_functor>::take _A_functor) + /** Constructs a retype_functor object that performs C-style casts on the parameters passed on to the functor. + * @param _A_functor Functor to invoke from operator()(). + */ + explicit retype_functor(typename type_trait<T_functor>::take _A_functor) : adapts<T_functor>(_A_functor) {} }; @@ -89,6 +158,12 @@ retype_functor<LIST(T_functor, LOOP(T_type%1, CALL_SIZE))>::operator()() { return this->functor_(); } +/** Performs a functor on each of the targets of a functor. + * The function overload for sigc::retype_functor performs a functor on the + * functor stored in the sigc::retype_functor object. + * + * @ingroup retype + */ template <LIST(class T_action, class T_functor, LOOP(class T_type%1, CALL_SIZE))> void visit_each(const T_action& _A_action, const retype_functor<LIST(T_functor, LOOP(T_type%1, CALL_SIZE))>& _A_target) @@ -97,6 +172,14 @@ void visit_each(const T_action& _A_action, } +/** Creates an adaptor of type sigc::retype_functor which performs C-style casts on the parameters passed on to the functor. + * This function template specialization works on sigc::slot. + * + * @param _A_functor Functor that should be wrapped. + * @return Adaptor that executes @e _A_functor performing C-style casts on the paramters passed on. + * + * @ingroup retype + */ template <LIST(class T_return, LOOP(class T_arg%1, CALL_SIZE))> inline retype_functor<LIST(slot<LIST(T_return, LOOP(T_arg%1, CALL_SIZE))>, LOOP(T_arg%1, CALL_SIZE)) > retype(const slot<LIST(T_return, LOOP(T_arg%1, CALL_SIZE))>& _A_functor) diff --git a/sigc++/adaptors/macros/retype_return.h.m4 b/sigc++/adaptors/macros/retype_return.h.m4 index 53857ff..9cb50a0 100644 --- a/sigc++/adaptors/macros/retype_return.h.m4 +++ b/sigc++/adaptors/macros/retype_return.h.m4 @@ -53,6 +53,15 @@ __FIREWALL__ namespace sigc { +/** Adaptor that perform a C-style cast on the return value of a functor. + * Use the convenience function sigc::retype_return() to create an instance of retype_return_functor. + * + * The following template arguments are used: + * - @e T_return Target type of the C-style cast. + * - @e T_functor Type of the functor to wrap. + * + * @ingroup retype + */ template <class T_return, class T_functor> struct retype_return_functor : public adapts<T_functor> { @@ -65,7 +74,11 @@ struct retype_return_functor : public adapts<T_functor> FOR(1,CALL_SIZE,[[RETYPE_RETURN_OPERATOR(%1)]])dnl retype_return_functor() {} - retype_return_functor(_R_(T_functor) _A_functor) + + /** Constructs a retype_return_functor object that perform a C-style cast on the return value of the passed functor. + * @param _A_functor Functor to invoke from operator()(). + */ + explicit retype_return_functor(_R_(T_functor) _A_functor) : adapts<T_functor>(_A_functor) {} }; @@ -75,7 +88,14 @@ T_return retype_return_functor<T_return, T_functor>::operator()() { return T_return(this->functor_()); } -// void specialization needed because of explicit cast to T_return +/** Adaptor that perform a C-style cast on the return value of a functor. + * This template specialization is for a void return. It drops the return value of the functor it invokes. + * Use the convenience function sigc::hide_return() to create an instance of sigc::retype_return_functor<void>. + * + * @ingroup retype + */ +/* The void specialization needed because of explicit cast to T_return. + */ template <class T_functor> struct retype_return_functor<void, T_functor> : public adapts<T_functor> { @@ -98,6 +118,12 @@ void retype_return_functor<void, T_functor>::operator()() { this->functor_(); } +/** Performs a functor on each of the targets of a functor. + * The function overload for sigc::retype_return_functor performs a functor on the + * functor stored in the sigc::retype_return_functor object. + * + * @ingroup retype + */ template <class T_action, class T_return, class T_functor> void visit_each(const T_action& _A_action, const retype_return_functor<T_return, T_functor>& _A_target) @@ -106,11 +132,26 @@ void visit_each(const T_action& _A_action, } +/** Creates an adaptor of type sigc::retype_return_functor which performs a C-style cast on the return value of the passed functor. + * The template argument @e T_return specifies the target type of the cast. + * + * @param _A_functor Functor that should be wrapped. + * @return Adaptor that executes @e _A_functor performing a C-style casts on the return value. + * + * @ingroup retype + */ template <class T_return, class T_functor> inline retype_return_functor<T_return, T_functor> retype_return(const T_functor& _A_functor) { return retype_return_functor<T_return, T_functor>(_A_functor); } +/** Creates an adaptor of type sigc::retype_return_functor which drops the return value of the passed functor. + * + * @param _A_functor Functor that should be wrapped. + * @return Adaptor that executes @e _A_functor dropping its return value. + * + * @ingroup hide + */ template <class T_functor> inline retype_return_functor<void, T_functor> hide_return(const T_functor& _A_functor) diff --git a/sigc++/connection.h b/sigc++/connection.h index 92d50a5..245e29e 100644 --- a/sigc++/connection.h +++ b/sigc++/connection.h @@ -129,6 +129,21 @@ private: namespace SigC { +/** Convinience class for safe disconnection. + * Iterators must not be used beyond the lifetime of the list + * they work on. A connection object can be created from a + * slot list iterator and may safely be used to disconnect + * the referred slot at any time (disconnect()). If the slot + * has already been destroyed, disconnect() does nothing. empty() or + * operator bool() can be used to test whether the connection is + * still active. The connection can be blocked (block(), unblock()). + * + * This is possible because the connection object gets notified + * when the referred slot dies (notify()). + * + * @deprecated Use sigc::connection instead. + * @ingroup compat + */ typedef ::sigc::connection Connection; } diff --git a/sigc++/functors/macros/functor_trait.h.m4 b/sigc++/functors/macros/functor_trait.h.m4 index 5285920..7aef76a 100644 --- a/sigc++/functors/macros/functor_trait.h.m4 +++ b/sigc++/functors/macros/functor_trait.h.m4 @@ -87,6 +87,25 @@ namespace sigc { struct nil; +/** @defgroup functors Functors + * Functors are copyable types that define operator()(). + * + * Types that define operator()() overloads with different return types are referred to + * as multi-type functors. Multi-type functors are only partly supported in libsigc++. + * + * Closures are functors that store all information needed to invoke a callback from operator()(). + * + * Adaptors are functors that alter the signature of a functor's operator()(). + * + * libsigc++ defines numerous functors, closures and adaptors. + * Since libsigc++ is a callback libaray, most functors are also closures. + * The documentation doesn't distinguish between functors and closures. + * + * The basic functor types libsigc++ provides are created with ptr_fun() and mem_fun() + * and can be converted into slots implicitly. + * The set of adaptors that ships with libsigc++ is documented in the equally named module. + */ + /** A hint to the compiler. * All functors which define @p result_type should publically inherit from this hint. * @@ -109,6 +128,14 @@ struct functor_trait<T_functor,true> typedef T_functor functor_type; }; +/** If you want to mix functors from a different library with libsigc++ and + * these functors define @p result_type simply use this macro inside namespace sigc like so: + * @code + * namespace sigc { SIGC_FUNCTORS_HAVE_RESULT_TYPE } + * @endcode + * + * @ingroup functors + */ #define SIGC_FUNCTORS_HAVE_RESULT_TYPE \ template <class T_functor> \ struct functor_trait<T_functor,false> \ @@ -117,6 +144,19 @@ struct functor_trait<T_functor,false> \ typedef T_functor functor_type; \ }; +/** If you want to mix functors from a different library with libsigc++ and + * these functors don't define @p result_type use this macro inside namespace sigc + * to expose the return type of the functors like so: + * @code + * namespace sigc { + * SIGC_FUNCTOR_TRAIT(first_functor_type, return_type_of_first_functor_type) + * SIGC_FUNCTOR_TRAIT(second_functor_type, return_type_of_second_functor_type) + * ... + * } + * @endcode + * + * @ingroup functors + */ #define SIGC_FUNCTOR_TRAIT(T_functor,T_return) \ template <> \ struct functor_trait<T_functor,false> \ diff --git a/sigc++/functors/slot_base.h b/sigc++/functors/slot_base.h index 5ac5b49..def2e56 100644 --- a/sigc++/functors/slot_base.h +++ b/sigc++/functors/slot_base.h @@ -157,6 +157,37 @@ struct slot_do_unbind } //namespace internal + +/** @defgroup slot Slots + * Slots are type-safe representations of callback methods and functions. + * A Slot can be constructed from any function, regardless of whether it is a global function, + * a member method, static, or virtual. + * + * Use the sigc::mem_fun() and sigc::ptr_fun() template functions to get a sigc::slot, like so: + * + * @code + * sigc::slot<void, int> sl = sigc::mem_fun(someobj,& SomeClass::somemethod); + * @endcode + * + * or + * + * @code + * sigc::slot<void, int> sl = sigc::ptr_fun(&somefunction); + * @endcode + * + * or + * + * @code + * m_Button.signal_clicked().connect( sigc::mem_fun(*this, &MyWindow::on_button_clicked) ); + * @endcode + * + * The compiler will complain if SomeClass::somemethod, etc. have the wrong signature. + * + * You can also pass slots as method parameters where you might normally pass a function pointer. + * + * @ingroup functors + */ + /** Base type for slots. * slot_base integrates most of the interface of the derived * sigc::slot templates. slots diff --git a/sigc++/macros/method_slot.h.m4 b/sigc++/macros/method_slot.h.m4 index 897abef..567cff1 100644 --- a/sigc++/macros/method_slot.h.m4 +++ b/sigc++/macros/method_slot.h.m4 @@ -20,12 +20,11 @@ include(template.macros.m4) define([SLOT_MEM_FUN],[dnl /** Creates a functor of type Sigc::Slot[]eval($1+1) that wraps a $4 method. - * This function is part of the compatibility module and therefore deprecated. - * Use sigc::mem_fun() instead. * * @param _A_func Pointer to method that should be wrapped. * @return Functor that executes _A_func on invokation. * + * @deprecated Use sigc::mem_fun() instead. * @ingroup compat */ template <LIST(class T_return, LOOP(class T_arg%1, $1), class T_obj)> diff --git a/sigc++/macros/object_slot.h.m4 b/sigc++/macros/object_slot.h.m4 index 32cf556..13a1e18 100644 --- a/sigc++/macros/object_slot.h.m4 +++ b/sigc++/macros/object_slot.h.m4 @@ -20,10 +20,7 @@ include(template.macros.m4) define([SLOT_MEM_FUN],[dnl /** Creates a functor of type SigC::Slot$1 that encapsulates a $4 method and an object instance. - * @e _A_obj must be of a type that inherits SigC::Object. - * - * This function is part of the compatibility module and therefore deprecated. - * Use sigc::mem_fun() instead. + * @e _A_obj must be of a type that inherits from SigC::Object. * * @param _A_obj Reference to object instance the functor should operate on. * @param _A_func Pointer to method that should be wrapped. diff --git a/sigc++/macros/signal.h.m4 b/sigc++/macros/signal.h.m4 index cd01098..c343fa1 100644 --- a/sigc++/macros/signal.h.m4 +++ b/sigc++/macros/signal.h.m4 @@ -406,9 +406,6 @@ FOR(1,$1,[ * - @e T_arg%1 Argument type used in the definition of emit().]) * - @e T_accumulator The accumulator type used for emission. The default @p nil means that no accumulator should be used. Signal emission returns the return value of the last slot invoked. * - * This class is part of the compatibility module and therefore deprecated. - * Use the unnumbered template sigc::signal instead. - * * @deprecated Use the unnumbered template sigc::signal instead. * @ingroup compat */ diff --git a/sigc++/macros/slot.h.m4 b/sigc++/macros/slot.h.m4 index 09336af..c8a02ff 100644 --- a/sigc++/macros/slot.h.m4 +++ b/sigc++/macros/slot.h.m4 @@ -43,9 +43,6 @@ FOR(1,$1,[ * s(19); * @endcode * - * This class is part of the compatibility module and therefore deprecated. - * Use the unnumbered template sigc::slot instead. - * * @deprecated Use the unnumbered template sigc::slot instead. * @ingroup compat */ @@ -84,9 +81,6 @@ public: define([SLOT_PTR_FUN],[dnl /** Creates a functor of type SigC::Slot$1 that wraps an existing non-member function. * - * This function is part of the compatibility module and therefore deprecated. - * Use sigc::ptr_fun() instead. - * * @param _A_func Pointer to function that should be wrapped. * @return Functor that executes _A_func on invokation. * @@ -121,7 +115,7 @@ FOR(0,CALL_SIZE,[[SLOT_N(%1)]]) * * This ugly hack avoids the error: */ -// #define slot(...) make_slot(__VA_ARGS__) +// #define slot(...) make_slot(__VA_ARGS__) /* only works for gcc */ #endif diff --git a/sigc++/reference_wrapper.h b/sigc++/reference_wrapper.h index f483eb5..436e02f 100644 --- a/sigc++/reference_wrapper.h +++ b/sigc++/reference_wrapper.h @@ -21,6 +21,9 @@ namespace sigc { +/** Reference wrapper. + * Use sigc::ref() to create a reference wrapper. + */ template <class T_type> struct reference_wrapper { @@ -33,6 +36,9 @@ struct reference_wrapper T_type& value_; }; +/** Const reference wrapper. + * Use sigc::ref() to create a const reference wrapper. + */ template <class T_type> struct const_reference_wrapper { @@ -45,10 +51,30 @@ struct const_reference_wrapper const T_type& value_; }; +/** Creates a reference wrapper. + * Passing an object throught sigc::ref() makes libsigc++ adaptors + * like, e.g., sigc::bind store references to the object instead of copies. + * If the object type inherits from sigc::trackable this will ensure + * automatic invalidation of the adaptors when the object is deleted + * or overwritten. + * + * @param v Reference to store. + * @return A reference wrapper. + */ template <class T_type> reference_wrapper<T_type> ref(T_type& v) { return reference_wrapper<T_type>(v); } +/** Creates a const reference wrapper. + * Passing an object throught sigc::ref() makes libsigc++ adaptors + * like, e.g., sigc::bind store references to the object instead of copies. + * If the object type inherits from sigc::trackable this will ensure + * automatic invalidation of the adaptors when the object is deleted + * or overwritten. + * + * @param v Reference to store. + * @return A reference wrapper. + */ template <class T_type> const_reference_wrapper<T_type> ref(const T_type& v) { return const_reference_wrapper<T_type>(v); } diff --git a/sigc++/trackable.cc b/sigc++/trackable.cc index 9b22854..0ac26fc 100644 --- a/sigc++/trackable.cc +++ b/sigc++/trackable.cc @@ -29,12 +29,13 @@ trackable::trackable() : callback_list_(0) {} -//TODO: Why doesn't this actually use src? murrayc. -trackable::trackable(const trackable& src) +/* Don't copy the notification list. + The objects watching src don't need to be notified when the new object dies. */ +trackable::trackable(const trackable& /*src*/) : callback_list_(0) {} -trackable& trackable::operator=(const trackable& src) +trackable& trackable::operator=(const trackable& /*src*/) { notify_callbacks(); return *this; |