[Kde-pim] [RFC] Contact specific Akonadi API

Volker Krause vkrause at kde.org
Mon Aug 10 12:16:11 BST 2009


On Monday 10 August 2009 10:11:58 robert at narnia.homeunix.com wrote:
> > I am still not convinced that this is a suffiently big gain.
> >
> > job->payload<Addressee>();
> >
> > is not significantly more difficult then
> >
> > job->addressee();
> >
> > Templated getters are quite common in C++ APIs, including Qt (e.g.
> > QVariant::value())
>
> I had to use these kinds of getters in a kpilot patch recently (the
> hasPayload and payload methods) and I feel like they are particularly
> prone to programming errors.  For instance, if you put use the wrong class
> in for the hasPayload template, the method fails silently and doesn't
> generate any kind of compile time (or runtime) warning.  I'm not saying
> that we shouldn't use them.  Just that, if we do, we should take some
> precautions.

Not sure what you mean by "wrong class", but hasPayload() will return false if 
you put in a class that's not compatible with the actual payload type, I 
don't see a silent failure here.

The payload code basically distinguishes between 3 sets of types:
- types that cannot be a payload type (pointers for example), it wont even 
compile for those
- types that can be a payload (copyable value-type basically) but are 
incompatible with the actual payload type will return false for hasPayload() 
and throw an exception when used with payload()
- types that can be casted to and from the actualy payload type will return 
true for hasPayload() and the correctly casted value for payload()

regards
Volker
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-pim/attachments/20090810/c14ea417/attachment.sig>
-------------- next part --------------
_______________________________________________
KDE PIM mailing list kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/


More information about the kde-pim mailing list