X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Utils%2Fmembind.hh;h=c2baf8601d2ab02570d972d2e9414cec592ee0bd;hb=532240d72e09e19e57fac9bb55c2560b9c9e5b97;hp=bc9b30de4884571b7b8b5e79dd911e2daa6cc241;hpb=ac6a813d9d99f7add4e13aff7a4bcd314d5604a6;p=senf.git diff --git a/Utils/membind.hh b/Utils/membind.hh index bc9b30d..c2baf86 100644 --- a/Utils/membind.hh +++ b/Utils/membind.hh @@ -1,9 +1,9 @@ // $Id$ // -// Copyright (C) 2006 -// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) -// Kompetenzzentrum fuer Satelitenkommunikation (SatCom) -// Stefan Bund +// Copyright (C) 2006 +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY +// Stefan Bund // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -20,26 +20,75 @@ // Free Software Foundation, Inc., // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -#ifndef HH_membind_ -#define HH_membind_ 1 +/** \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 + + senf::membind() takes either a pointer or an object as second argument. When passing an object, + that object will be copied into the bound member function returned. + + \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_SENF_Utils_membind_ +#define HH_SENF_Utils_membind_ 1 // Custom includes #include #include +#include "../config.hh" ///////////////////////////////hh.p//////////////////////////////////////// namespace senf { - #define scOBTYPE T * -#include "Utils/impl/membind.hh" +#include "../Utils/impl/membind.hh" #undef scOBTYPE #define scOBTYPE T & -#include "Utils/impl/membind.hh" +#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//////////////////////////////////////// @@ -51,4 +100,10 @@ namespace senf { // Local Variables: // mode: c++ +// fill-column: 100 +// c-file-style: "senf" +// indent-tabs-mode: nil +// ispell-local-dictionary: "american" +// compile-command: "scons -u test" +// comment-column: 40 // End: