X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Utils%2Fmembind.hh;h=62f68c1377d629433e9135fabd271645cd88ce5e;hb=9a988902090d28007578e93bffd809f6bd913155;hp=e624e761ad3a4dbd6226f9c7fe9b7ee2c2997e15;hpb=c52cd7d87dbb525c1267aad27391b8b7365dbb57;p=senf.git diff --git a/Utils/membind.hh b/Utils/membind.hh index e624e76..62f68c1 100644 --- a/Utils/membind.hh +++ b/Utils/membind.hh @@ -1,6 +1,6 @@ // $Id$ // -// Copyright (C) 2006 +// Copyright (C) 2006 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) // Kompetenzzentrum fuer Satelitenkommunikation (SatCom) // Stefan Bund @@ -20,6 +20,32 @@ // Free Software Foundation, Inc., // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +/** \file + \brief membind public header */ + +/** \defgroup membind Bound Member Functions + + The membind() family of function templates simplifies the creation + of simple bound member function pointers: + + \code + struct Foo { + int test(int x); + }; + + Foo * foo = ...; + boost::function f = senf::membind(&Foo::test,foo); + int rv = f(1); // Calls foo->test(1) + \endcode + + \idea Make the \a ob argument type an additional P template + parameter (using call_traits for the exact arg type? Probably + we'll get deduction problems then) . The only operation this + object must support is ob->*fn. This would allow the use of + smart pointers. We should keep the T & version to still support + ob.*fn use. + */ + #ifndef HH_membind_ #define HH_membind_ 1 @@ -29,8 +55,7 @@ ///////////////////////////////hh.p//////////////////////////////////////// -namespace satcom { -namespace lib { +namespace senf { #define scOBTYPE T * #include "Utils/impl/membind.hh" @@ -40,7 +65,29 @@ namespace lib { #include "Utils/impl/membind.hh" #undef scOBTYPE -}} +#ifdef DOXYGEN + + /// \addtogroup membind + /// @{ + + /** \brief Build bound member function object + + membind() supports up to 9 function parameters (represented as + \a Args here). The \a ob argument can be either a pointer or a + reference to \a T + \param[in] fn member function pointer + \param[in] ob object instance to bind this pointer to + \returns Boost.Function object representing a bound call of \a + fn on \a ob + */ + template + boost::function membind(R (T::* fn)( Args ), T * ob); + + /// @} + +#endif + +} ///////////////////////////////hh.e//////////////////////////////////////// //#include "membind.cci" @@ -51,4 +98,8 @@ namespace lib { // Local Variables: // mode: c++ +// fill-column: 100 +// c-file-style: "senf" +// indent-tabs-mode: nil +// ispell-local-dictionary: "american" // End: