Dynamic Libraries & Interface
Reason
The initial thought was on how to isolate the main application from hardware drivers back in (1997).
This in order to not have to rebuild the application for different used hardware.
The main problem was that Windows dynamic libraries (DL's) from hardware suppliers did not load when
the hardware was not installed and the application was recompiled for each hardware configuration.
Solution
Researching the problem I found out that linking C-style functions from a runtime loaded dynamic library was available but made it complicated for development in C++ where a derived class was created from a pure virtual class calling the C-style functions.
The actual solution was to create a pure virtual class used as an interface located in its own DL. The interface class had a static part where implementation DL's could register a callback function for creating an implementation by name.
The library dependency like this below where the interface library is statically linked to the application and also to the implementation DL loaded at runtime.
Implementation
It took some iterations in time to get it right using now modern C++ templates.
The latest implementation for an interface class consists of a declaration en definition macro located in the TClassRegistration template header file.
Two macro's for the interface class:
* SF_DECL_IFACE(...): Declares an interface class which adds static members to the class like here.
* SF_IMPL_IFACE(...): Defines/implements the static class members declared by macro SF_DECL_IFACE like here.
Two macro's for the implementation of the class in a DL:
* SF_REG_CLASS(...): Registers an interface implementation using a name and description like here.
* SF_DL_INFORMATION(...): Due to the lack of resource on Linux it serves a name and description of the DL interface implementation like here.
With this inplace the application can instantiate a class from a loaded module.
Application Configuration
The configuration dialog in the application looks like this where the information from the macro SF_DL_INFORMATION
is visualized in order to delect the wanted module for the application configuration.
