Interface to provide applications with objects from plugins. More...
#include <Provider.hpp>
Public Member Functions | |
virtual | ~Provider () |
Destructor. More... | |
virtual unsigned int | getVersion () const =0 |
Get provider version. More... | |
bool | isCompatible (const Host &host) const |
Check compatibility with host. More... | |
Friends | |
class | Host |
Interface to provide applications with objects from plugins.
The plugin specific implementations are unknown at the host side, only their shared interfaces are known. Then, host app needs a generic way of create interface objects. That's what provider classes are for. It is the factory design pattern (http://www.oodesign.com/factory-pattern.html)
Shared interfaces define their provider types (by inheriting from pluma::Provider). Hosts then use those tipes to get objects from the plugins. Plugins derive the shared interface providers so that they can provide host with specific implementations of the shared interface. Those specific providers are given to the host through a connect function.
Example: A host app uses objects of type Device. A certain plugin defines a Keyboard, witch is a Device. The Host will use DeviceProviders to create objects of type Device. The plugin will provide host specifically with a KeyboardProvider. Other plugins may provide host with other derived DeviceProvider types.
Device hpp (shared):
Device cpp (shared):
Keyboard code on the plugin side:
plugin connector:
Host application code:
Definition at line 42 of file Provider.hpp.
|
virtual |
Destructor.
Definition at line 36 of file Provider.cpp.
|
pure virtual |
Get provider version.
bool pluma::Provider::isCompatible | ( | const Host & | host | ) | const |
Check compatibility with host.
The same provider may be compiled with different versions on host side and on plugins side. This function checks if a plugin provider is compatible with the current version of the same provider type on the host side.
host | Host, proxy of host application. |
Definition at line 42 of file Provider.cpp.