Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
# xplugin

[![ci](https://github.com/QuantStack/xplugin/actions/workflows/ci.yaml/badge.svg)](https://github.com/QuantStack/xplugin/actions/workflows/ci.yaml)

Generic plugin framework in C++.

## Features

- [x] Generic plugin framework
- [x] Abitrary abstract base classes can be used as plugin interface
- [x] Arbitrary abstract base classes can be used as plugin interface
- [x] Customizable with custom plugin factories (see examples)
- [x] Works on Linux, Mac and Windows and emscripten
- [x] Works on linux, mac, windows and emscripten

## Usage

## Example 1

All plugins are derived from a a base class, in the first example `MyPluginBase`.
All plugins are derived from a base class, in the first example `MyPluginBase`.
All concrete plugins are derived from `MyPluginBase` and implement the pure virtual function (in this example it is only the `do_something()` function).
Furthermore, for this example, we assume that all concrete plugins have an empty constructor.
(see example 2 for a more complex example)
Expand Down Expand Up @@ -114,7 +117,7 @@ int main(int argc, char** argv)

We again define a plugin interface `MyOtherPluginBase` and a concrete plugin implementations `MyOtherPluginA` and `MyOtherPluginB`.
The difference to the first example is that the concrete plugins have a constructor with arguments.
But both plugins have the same constructor signature. (see example 3 for a more complex example)
But both plugins have the same constructor signature.

`my_other_plugin_base.hpp`:
```cpp
Expand Down
12 changes: 2 additions & 10 deletions docs/conf.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ project = 'xplugin'
copyright = '2023, Dr. Thorsten Beier and Johan Mabille'
author = 'Dr. Thorsten Beier and Johan Mabille'



# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

Expand All @@ -28,13 +26,9 @@ extensions = [
'breathe'
]



templates_path = ['_templates']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', 'breathe/*']



# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

Expand All @@ -59,13 +53,11 @@ html_theme_options = {
'titles_only': False
}
# html_logo = ''
# github_url = ''
#html_baseurl = 'baZINGA'

github_url = 'https://github.com/QuantStack/xplugin'
# html_baseurl = ''

html_static_path = []


# -- Breathe configuration -------------------------------------------------
from pathlib import Path
CMAKE_CURRENT_BINARY_DIR = Path("@CMAKE_CURRENT_BINARY_DIR@")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#pragma once
#ifndef CUSTOM_FACTORY_WITH_METADATA_PLUGIN_BASE_HPP
#define CUSTOM_FACTORY_WITH_METADATA_PLUGIN_BASE_HPP

#include <string>

class PluginBase
Expand All @@ -24,3 +26,5 @@ class PluginFactoryBase
virtual std::string description() const = 0;
virtual std::string version() const = 0;
};

#endif // CUSTOM_FACTORY_WITH_METADATA_PLUGIN_BASE_HPP
8 changes: 2 additions & 6 deletions include/xplugin/xfactory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ class xfactory_base
{
public:
using base_type = BASE_TYPE;
virtual ~xfactory_base()
{
}
virtual ~xfactory_base() = default;
virtual std::unique_ptr<base_type> create(ARGS...) = 0;
};

Expand All @@ -41,9 +39,7 @@ class xfactory : public xfactory_base<BASE_TYPE, ARGS...>
using concrete_type = CONCRETE_TYPE;
using base_type = BASE_TYPE;
using factory_base_type = xfactory_base<BASE_TYPE, ARGS...>;
virtual ~xfactory()
{
}
virtual ~xfactory() = default;
std::unique_ptr<base_type> create(ARGS... args) override;
};

Expand Down
1 change: 0 additions & 1 deletion include/xplugin/xshared_library.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* *
* The full license is in the file LICENSE, distributed with this software. *
****************************************************************************/
#pragma once
#ifndef XPLUGIN_XSHARED_LIBRARY_HPP
#define XPLUGIN_XSHARED_LIBRARY_HPP

Expand Down