PDA

View Full Version : Plugin Interfaces



Paul Drummond
27th February 2006, 11:55
Hi, I am writing a MapViewer application which will support plugins. I am currently trying to define an interface for my plug-ins but I keep asking myself the same question: Why don't I just had one method, initialize() which takes a MainWindow* pointer then all plug-ins become "general" and can connect to any signal they want to?

Due to Qt's excellent signal/slot mechanism this seems like the way to go - why limit your plug-ins to a specific interface? Am I missing something obvious here?

orb9
27th February 2006, 14:37
Due to Qt's excellent signal/slot mechanism this seems like the way to go - why limit your plug-ins to a specific interface? Am I missing something obvious here?
One of the advantages of plugins is the possibility for third party to add functionality to an app. Consider an image filter-plugin: Which method is used to set the input image, which one for getting the output image? Specifiying the interface solves this problem.

In fact, the interface thing has nothing to do with plugins. In case of the image filter it's the same for a non-plugin approach. You could write a new class for every image filter, but this won't be useable - instead you make a Filter interface (or a baseclass).