Synopsis:
Plugins are code components that a host application loads and uses to enhance its default functionality. Plugins implement a plugin interface and object factory and are built as shared libraries. The application host loads the plugin, activates it using the object factory, and uses its services.
Host/Plugin Requirements:
In order to implement a host and plugin:- The host declares a plugin interface defining functions it knows how to call and an object factory to create instances of the plugin class(es).
- Optionally, the host provides a registration interfact (implemented by the host) that allows multiple plugins to register with the host for activation and use.
- If the host provides a registration interface, then the plugin interface must contain a function for the host to pass a pointer to its registration interface to the plugin to use for registration.
- The plugin component implements the interface declared by the host.
- The plugin is built as a shared library to that it can be loaded when the host starts or later when the host needs its services.
Interface and Object Factory Example Code:
- Widget Interface and Object Factory Widget Factory code
- Supporting multiple interfaces - class Diagram, vsd, Multiple interfaces code example
Plugin Sample Code:
Shared Library References:
- Shared library tutorial
- Building shared libraries
- Dynamically loading shared libraries
- More Dynamically loading
- Simple tutorial on the basics
- Setting shared library search path
- shared library search paths
Plugin Architecture References:
-
Plugin Architecture - stackoverflow
-
Plugin Architecture - Cygon's Blog
-
Plugins - Mac Developer Library
-
Plug-in (computing) - Wikipedia
-
Building Your Own Plugin Framework: Part 1 - Dr.Dobb's
- Plugin System - alternative to GetProcAddress and interfaces - CodeProject
- Widget Interface and Object Factory - class Diagram, vsd, Widget Factory Code