Hello everyone,
I guess this subject was already discuseed few times in this Forum but still I would like to hear some more oppinions: I am developing an application which main task is to receive data through the SerialPort (using a SerialLibrary) and to process and display these ddata in the GUI. This application should have also an API which supports plugins - dll files that are loaded dynamicali during runtime.
The application API should be an interface for the plugins and it would have two main tasks: 1. Load the plugin dlls upon execution and initialize their functions from the DLL (with the help of LoadLibrary and GetProcAddress). 2. Offer an interface for the plugins to access the main application resources with other words, share some of the main application objects: SerialLibrary function, some GUI resources (ListBoxes, Menus), some processing functions etc.
The project is developed in Visual C++, with MFC support.
My question is: My main issue is according to the API development. How to create this API as an interface in the main application so that the plugin DLL's can use resources from the application. I have searched through the internet and have found several solution but I don't know which is the best:
1. create a class with virtual functions that will work like an interface, the header file of this class will be included to the plugin project; the virtual class would be inherited and created in the main project and it's pointer would be given to the plugin.
2. All functions that the application would like to share with the plugins to put in an DLL. This DLL would be linked to all the plugins and also to the main application.
3. The plugins would be defined as COM objects
4. Create a function table where resides all function addresses of the plugins and the shared main application functions and objects
I would be very gratefull for any suggestion. Thanks a lot, greetings
Attila
Visual C++16
|