View Full Version : Plugins

24th March 2006, 19:02
I've never made any application with plugins before, but I might need to soon. A way to add functionality to a program that is already compiled. Like the extensions of firefox, for example (but not nessesarily in the exact same way).

What is the best / most frequently used way to do this? What sort of file will the plugin be? How does the application communicate with it? What sort of techniques are used? Doesn't have to be QT, so I post it here.


25th March 2006, 00:10
There is no one simple answer for your question. You can have binary plugins which are implemented as shared objects and loaded into the main app using APIs like dlopen() and dlsym() or QLibrary. You can have scripting plugins, where plugins are text scripts (for example in perl, python, QSA or whatever other language you find convinient) which are interpreted by some interpreter embedded into the main application.

It all depends what should those plugins do...

25th March 2006, 10:06
Yes. Of course. I'm interested in the binary ones, since most of what I need would be way too difficult (if not impossible) for scripting plugins. A simple example of what I need:

There is a complex datastructure in the application. Each member has an acceptVisitor() function, so the visitor pattern can be applied. The new plugin will need:

* A new visitor (a subclass of an already existing Visitor class in the app) to traverse the datastructure.

* A new toolbar button to let it do its work.

* Access to an existing class which uses the singleton pattern, in which the visitor will change data.

How would I go about that? An online tutorial or something would be great.

25th March 2006, 12:37
You might try the C++ dlopen mini-HowTo (http://www.isotton.com/howtos/C++-dlopen-mini-HOWTO/C++-dlopen-mini-HOWTO.html).