Hi Daniel,

> I have added the following template member function:
> 
> cppuhelper/interfacecontainer.h, class cppu::OInterfaceContainerHelper:
> + template <typename ListenerT, typename FuncT>
> + inline void forEach( FuncT const& func );

The main use case for this seems to be listener notification, and this
is great so far (and in fact already deprecates on of my helper classes
in comphelper ;).
However, the syntax for calling this function is somewhat ugly to write
and read:
  myContainer.forEach<awt::XPaintListener>(
    boost::bind( &awt::XPaintListener::windowPaint,
      _1, awt::PaintEvent(...) );

May I suggest to also add the following function:
  template< class ListenerT, class EventT >
  inline void notify(
    void ( SAL_CALL ListenerT::*NotificationMethod )( const EventT& ),
    const EventT& Event )

advantage: This would allow calls like
  myContainer.notify( &awt::XPaintListener::windowPaint,
    awt::PaintEvent(...) );
(no specification of template parameters, no boost binder involved)

disadvantage: The signature of the listener method has to match exactly,
but I'd say this is the case for nearly all of our listeners and their
methods.

Ciao
Frank

-- 
- Frank Schönheit, Software Engineer         [EMAIL PROTECTED] -
- Sun Microsystems                      http://www.sun.com/staroffice -
- OpenOffice.org Database                   http://dba.openoffice.org -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to