22 #ifndef LUNCHBOX_PLUGIN_H 23 #define LUNCHBOX_PLUGIN_H 26 #include <servus/uint128_t.h> 36 using Constructor = std::function<T*(const typename T::InitDataT&)>;
42 using HandlesFunc = std::function<bool(const typename T::InitDataT&)>;
57 : _constructor(constructor)
59 , _description(description)
64 T*
construct(
const typename T::InitDataT& data)
const 66 return _constructor(data);
70 bool handles(
const typename T::InitDataT& data)
const 72 return _handles(data);
77 bool operator==(
const Plugin& rhs)
const 79 return &_constructor == &rhs._constructor &&
80 &_handles == &rhs._handles &&
81 _description() == rhs._description();
84 bool operator!=(
const Plugin& rhs)
const 86 return !(*
this == rhs);
T * construct(const typename T::InitDataT &data) const
Construct a new plugin instance.
std::function< std::string()> DescriptionFunc
The method to get the plugin's description.
Plugin(const Constructor &constructor, const HandlesFunc &handles_, const DescriptionFunc &description)
Construct a new Plugin.
std::function< T *(const typename T::InitDataT &)> Constructor
The constructor method for Plugin objects.
Abstraction layer and common utilities for multi-threaded programming.
std::string getDescription() const
std::function< bool(const typename T::InitDataT &)> HandlesFunc
The method to check if the plugin can handle a given initData.
bool handles(const typename T::InitDataT &data) const