GithubHelp home page GithubHelp logo

mjopenglsdl / pluginframework Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kilpatds/pluginframework

0.0 1.0 0.0 18 KB

A simple C++ framework for Plugins (interface + factory) loadable from shared libraries

License: Other

CMake 9.22% C++ 90.78%

pluginframework's Introduction

PluginFramework

A simple C++ framework for Plugins (interface + factory) loadable from shared libraries

Usage

Define your interface....

class someInterface {
  public:
    virtual blah iface(blah) = 0;
    virtual ~someInterface() {};
    someInterface(someArgs) {};
};

Define implementations of that interface.

In that, use the PLUGIN() and PLUGIN_DEFS() macros. PLUGIN declares the class (inheriting from the interface via some other internal stuff). PLUGIN_DEFS declares/defines some magic registration objects (and a factory)

#include <Plugin>
#include <someInterface>

PLUGIN(someInteface, someImplementationName) {
  public:
    virtual blah iface(blah) { ... };
    ~someImplementation() {...};
    someImplementation(someargs) { ... };
};
PLUGIN_DEFS(someInterface, someImplementation);
  1. Write a consumer. Somewhere in the global scope in the actual process you'll need to use PLUGIN_BASE()
#include <Plugin>
PLUGIN_BASE()

    ...
    try {
        someInterface *i = Plugin<someInterface,someargs>::getPlugin(
            "name", args...);
    } catch (std::runtime_error &e) {
	cerr << "Failed to load plugin: " << e.what() << endl;
    }

pluginframework's People

Contributors

kilpatds avatar mjopenglsdl avatar

Watchers

 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.