DCOPRef and dynamic stubs ( 3.1? )

Simon Hausmann hausmann at kde.org
Mon Sep 9 13:34:22 BST 2002


On Mon, Sep 09, 2002 at 02:15:19PM +0200, Matthias Ettrich wrote:
> On Monday 09 September 2002 13:51, Simon Hausmann wrote:
> [snip]
> >
> > int foo = DCOPRef( "kdesktop" ).method( "int fooForBar" ).arg( blah ).arg(
> > url, "KURL" ).call();
> >
> > Not as beautiful as one call, but general and easy to extend for
> > custom types :-)
> 
> True.  In my system (if KURL was unknown), we'd have to type
> 
>    int foo = DCOPRef( "kdesktop" ).call( "fooForBar(int,KURL)", blah, url );
> 
> Hey, what about another template DCOPArg which allows you to specify a type? 
> Then we could do
> 
>   int foo = DCOPRef( "kdesktop" ).call( "fooForBar", 
> 			blah, 
> 			DCOPArg( url, "KURL" );

Good idea. But in the call template method, how do you distinguish
between a normal argument and the special DCOPArg?

Ah, the call() implementation could call something like

template <class T>
void addArgument( const T &arg )
{
    addArgumentInternal( arg, dcopType( arg ) );
}

template <>
void addArgument( const DCOPArg &customArg )
{
    addArgumentInternal( customArg.data, customArg.type );
}

for each argument.

Another thought coming to my mind is to take your idea of the
beautiful send( "setFoo", bar, blubb ); syntax and make the
implementation call the arg().arg() approach. That makes the common
case easy while providing flexibility for custom types with the
arg() approach. Hm, not sure if having two APIs for the same thing
is a good a idea though.

Simon




More information about the kde-core-devel mailing list