Giter Club home page Giter Club logo

plugin_cpp's Introduction

Plugins!

Build status

This example project explores how to develop a plugin system for a C++ application. It is based on the pugg plugin system.

Building

To build the project, you need to have CMake installed. Then, you can run the following commands:

mkdir build
ccmake -Bbuild -DCMAKE_BUILD_TYPE=Release
cmake --build build -t install

This creates three plugins in the form of executable files that also export symbols, so that they can be externally loaded by the main application. The plugins are named echo.plugin, twice.plugin, and echoj.plugin.

The latter plugin is a template for complete plugins, and it is pretty extensible. Indeed, it accepts a JSON object as settings, a JSON object as input, and produces a JSON object as output. The other two plugins are simple examples of how to implement a plugin.

Plugins are named Filters, for they are expected to act as filters, taking an input and producing an output. The plugins must be implemented as derived classes of the templated class Filter (see src/filter.hpp).

If needed, this project will be extended by adding base classes for other types of plugins, such as Sources (output only) and Sinks (input only).

Executing

The install step creates and populates the usr directory in the project root folder. You can run the executable that loads the plugin with the following command:

cd usr
bin/loaderj bin/echoj.plugin

Note that on MacOS only the echoj.plugin file is actually an executable file that exports symbols. It is not a shared library, but it is a plugin that can also be directly executed (using its internal main()) as:

bin/echoj.plugin

This is a very flexible way for implementing standalone apps that can also be used as plugins within the Miroscic framework of distributed agents.

On Windows and Linux, the plugin is a shared library that can only be loaded by the loader executable. Beside the plugin, an equivalent executable is also generated.

Plugin Versioning

The plugin system uses an internal version number Filter::version to check compatibility between the main application and the plugins. To invalidate a previously released plugin, simply imcrease the version number in the base class.

plugin_cpp's People

Contributors

pbosetti avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.