SkillAgentSearch skills...

PluginFramework

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

Install / Use

/learn @kilpatds/PluginFramework
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

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 <code>PLUGIN()</code> and <code>PLUGIN_DEFS()</code> 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;
    }
View on GitHub
GitHub Stars6
CategoryDevelopment
Updated2y ago
Forks4

Languages

C++

Security Score

55/100

Audited on Oct 2, 2023

No findings