32 lines
843 B
C++
32 lines
843 B
C++
#pragma once
|
|
|
|
#include "python_md/md_provider.h"
|
|
#include "python_md/md_sink.h"
|
|
|
|
#include <pybind11/pybind11.h>
|
|
|
|
namespace bts::md::py_interop {
|
|
|
|
/**
|
|
* An implementation of `bts::md::py_interop::MdProvider` that binds to a python object at runtime.
|
|
*
|
|
* @note The python object must derive from 'python_md_module.MdProvider', and define methods:
|
|
* 1. 'start(md_sink: python_md_module.MdSink)'
|
|
* 2. 'stop'
|
|
* @note 'python_md_module' is a python module defined by us in c++ (see 'py_module.cpp').
|
|
*/
|
|
class PyMdProvider : public MdProvider {
|
|
public:
|
|
using MdProvider::MdProvider;
|
|
|
|
~PyMdProvider() override;
|
|
|
|
void start(MdSink *sink) override {
|
|
PYBIND11_OVERLOAD_PURE(void, MdProvider, start, sink);
|
|
}
|
|
|
|
void stop() override { PYBIND11_OVERLOAD_PURE(void, MdProvider, stop); }
|
|
};
|
|
|
|
} // namespace bts::md::py_interop
|