Plugin architecture question
-
I am developing qt application that requires many API's that are only accessible through the C++ APIs, but the application UI is all with QML. So I am developing plugins to bring those API's to my QML code. I am noticing now that some plugins are becoming too large. For example we have a plugin that deals with communication protocol, but there are several issues around the communication such as error handling, handling communication for a particular hardware such as a joystick or a PLC. I think I should keep the plugins small and focused, but since so many plugins depend on the communication layer, I seem to have to put them in one plugin.
My question is, can I create a plugin just for handling communication protocol and then reuse that plugin from other plugins in my application? If so, could you explain briefly how this can be achieved?
-
@Aras said in Plugin architecture question:
My question is, can I create a plugin just for handling communication protocol and then reuse that plugin from other plugins in my application? If so, could you explain briefly how this can be achieved?
If you mean can a plugin load other plugins, then yes. The procedure is exactly the same as you do it in the application. You provide the interface headers, load the plugins with
QPluginLoader
and then use them. There's nothing special about it. If you mean something else, please elaborate on what you mean by "reuse". -
Hi,
To add to @kshegunov, it seems that you should split the communication part in a dynamic library and link your plugins against it, no ?
-
@kshegunov yes that is exactly what I was wondering. I was not sure if plugins can be loaded into other C++ plugins or not. I will give this a shot.
@SGaist good point about creating a library. I think isolating the communication API into a dynamic library would be an even better solution as you suggested. I will have to do some refactoring.
Thank you both for sharing the quick and helpful response!