On Friday 20 March 2009 15:50:23 Andre Moreira Magalhaes wrote: > 3 - Naming: > As you can see typing QExplicitlySharedDataPointer all over the place is > not something really nice, and we may want to move to another class > later, a lightweight version or something else, so the ideal is to have > our own class that for now inherits QExplicitlySharedDataPointer, and if > we want to change it later we just change this class. > Note that typedef is not an option here, as you can't typedef template > (just template specializations) and can't forward declare typedef, which > we would need. > > So I propose to have a template class SharedPtr that inherits > QExplicitlySharedDataPointer, and a class named SharedData that is a > typedef for QSharedData (in case we want to change to use another class > in the future, we don't need to change all classes). We may want to make > SharedData call deleteLater on ref==0 instead of delete for example.
Having a class that inherits QExplicitlySharedDataPointer doesn't really
future proof you, since any replacement must implement the exact same api. I
suppose if you privately inherit you could maybe get away with it, might be a
good idea to get rid of detach() anyways.
> So the usage would be:
>
> public Account : SharedData
> {
> public:
> ...
> static SharedPtr<Account> create();
> ...
> };
Regardless I think even if you have a SharedPtr, you should typedef
SharedPtr<Account> into AccountPtr because its annoying to use templates in
the code all the time. :)
> I wrote a experimental branch to ilustrate what it's explained above
> http://git.collabora.co.uk/?p=user/andrunko/telepathy-qt4.git;a=shortlog;h=
>refs/heads/shared
>
> Opinions, suggestions?
Well you know I think its a good idea. :)
Ian
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ telepathy mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/telepathy
