RFC: a replacement for KPluginLoader

Aaron J. Seigo aseigo at kde.org
Mon Apr 29 20:19:58 UTC 2013


hi..

currently libplasma uses the KDE plugin loading mechanisms *extensively*. they have also been 
marked as deprecated. the goal for frameworks, as i undestand it, is to move to a QPluginLoader.

QPluginLoader has a major limitation, however: it only returns a single instance of a class from 
the loaded library. one. ever. only. :)

obviously, applications such as Plasma Desktop need to load the same plugin many times, as 
needed. the solution is obvious: create a factory class that returns new instances of the class(es) 
inside of the library.

during our weekly plasma-workspaces meeting this topic came up and i suggested an approach 
(which I've also discussed with Thiago in passing) which i plan to implement at least for plasma-
workspace as a short-term solution to get away from the KDE plugin loading.

i will introduce a new macro (so that it remains source compatible, at least for libplasma) that 
creates a QObject subclass which itself provides a factory method to create new instances of the 
class(es) in the library.

i would also like to fold in version compatibility checks. the resulting API of the generated object 
will look something like:

template<class T> T *create(QObject *parent = 0) const;
bool isVersionCompatible(quint32 minVersion, quint32 maxVersion);

the version check method will help remove some boilerplate code from the library.

create will be used similarly to how it KPluginLoader is now: create<Foo>()

the QVariantList parameter will be removed as it seems to serve little real world purpose with 
how we design APIs now.

thoughts, before i go write some code?

-- 
Aaron J. Seigo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20130429/67feda88/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20130429/67feda88/attachment-0001.sig>


More information about the Kde-frameworks-devel mailing list