Hello Frank,

>>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.

You are right, single event object parameters are more common in our
API.  forEach() is most flexible (and fits my needs concerning the
slideshow listeners), but is more verbose to code, e.g. the listener
type cannot be deduced.
I have no current need for a notify() (or notifyEach()?), but vote +1.

regards,
-Daniel

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

Reply via email to