pid-modules  0.3.0
Overview

pid-modules provides utility libraries for easier DLL management and plugins systems creation

Quick Examples

The two functional libraries are:

  • dll, a simple library for easy runtime modules management (loading, suing symbol) in a PID environment. Its main purpose is to avoid boring with operating system specific primitives and to automate DLL location resolution.
#include <pid/dll.h> //use the DLL API
...
pid::DLLLoader dll("my-package","my-module");//load a module
auto func = dll.symbol<void()>("register_pid_plugin_extensions");//use one of its symbols
func();
  • plugins, used to ease the implementation of runtime plugin systems for your applications. Its main purpose is to automate the management of extension points definition and automate extensions binding into an application.
  • Declare an extension point:
    #include <pid/plugins.h>
    ...
    class Vehicle{//declare an interface
    public:
    virtual bool fly() const = 0;
    };
    PID_EXTENSION_POINT(vehicle::Vehicle, 1, 0)
  • Define a plugin that provides an extension to this extension point:
    #include <pid/plugins.h>
    #include <vehicle.h>
    class Plane : public Vehicle{
    public:
    virtual bool fly() const override{
    return true;
    }
    };
    pid_plugins().add_extension<Vehicle,Plane>();//Plane is an extension for Vehicle
    }
  • Use the plugin in an application to contribute to the extension point:
    ...
    pid_plugins().add_extension_point<Vehicle>();
    pid_plugins().load("some_package", "a_plugin");
    auto all_ext = pid_plugins().extensions<Vehicle>();//search for extensions
    for (auto & ext: all_ext) {
    auto v = ext->create();
    v->fly();//polymorphic call from Vehicle static type
    }

The license that applies to the whole package content is CeCILL-C. Please look at the license.txt file at the root of this repository for more details.

About authors

pid-modules has been developed by following authors:

  • Robin Passama (CNRS/LIRMM)

Please contact Robin Passama (robin.nosp@m..pas.nosp@m.sama@.nosp@m.lirm.nosp@m.m.fr) - CNRS/LIRMM for more information or questions.

PID_PLUGIN_DEPENDENCIES
#define PID_PLUGIN_DEPENDENCIES
accessing the list of dependencies of the currrent plugin beging defined
Definition: plugin_definition.h:61
pid::plugins::PluginsManager::add_extension
bool add_extension()
define an extension for a given extension point of an application
Definition: manager.h:169
pid_plugins
PID_MODULES_PLUGINS_EXPORT pid::plugins::PluginsManager & pid_plugins()
get access to the plugins management system
plugins.h
global header for the plugins library
PID_PLUGIN_DEFINITION
#define PID_PLUGIN_DEFINITION()
defining the current plugin contributions
Definition: plugin_definition.h:80
PID_EXTENSION_POINT
#define PID_EXTENSION_POINT(extension_point_type, major, minor)
declaring an extension point with its current version
Definition: plugin_definition.h:45
pid::plugins::PluginsManager::load
bool load(std::string_view package, std::string_view plugin, std::string_view version="")
load a plugin in process memory
pid::plugins::PluginsManager::extensions
std::vector< std::shared_ptr< Extension > > extensions(std::string_view package, std::string_view plugin) const
get all extensions provided by a plugin
dll.h
global header for the dll library