So we've built a plugin system. We have an abstract base class filled with pure virtual function definitions, and several derived classes that flesh out these functions and get built as shared objects. All of this works extremely well, and was simple to implement.
However, we would now like to extend this framework by inserting a Java-style "adapter class" between the abstract base class and its derivatives, so users who don't need to implement the entire interface can fall back on the default behavior defined in the adapter. Although I'm not a big fan of adapter classes, this has the benefit of somewhat insulating the end user from changes to the interface, since additions to the interface will not require the user to modify and recompile their plugin code.
Unfortunately, this doesn't seem to work with the plugin framework provided by Qt. We derive the adapter class from the base class, then derive the actual "working" class from the adapter, but at runtime the plugin loader doesn't recognize the library as a valid plugin, and returns 0. Note that we cannot include the Q_EXPORT_PLUGIN2 anywhere but in the "working" plugin. It cannot be included in the adapter class, because it can only occur once in any given library. But it seems that the loader won't recognize the plugin as valid unless it inherits directly from the abstract base class. Going through an intermediate class breaks whatever paradigm is being used, and results in runtime failure to load the library.
Any thoughts on how to accomplish this, or on whether it is even possible under the Qt plugin framework?
Bookmarks