31#include <unordered_set>
34#include <pdi/pdi_fwd.h>
35#include <pdi/logger.h>
64#define PLUGIN_API_VERSION_MAJOR (0ul)
66#define PLUGIN_API_VERSION_MINOR (0ul)
68#define PLUGIN_API_VERSION_PATCH (1ul)
70#define PLUGIN_API_VERSION ((PLUGIN_API_VERSION_MAJOR << 24) + (PLUGIN_API_VERSION_MINOR << 16) + (PLUGIN_API_VERSION_PATCH << 8))
88struct has_dependencies {
90 static constexpr decltype(C::dependencies(), bool()) test(
int)
96 static constexpr bool test(...)
101 static constexpr bool value = test<T>(
int());
110typename std::enable_if<has_dependencies<T>::value, std::pair<std::unordered_set<std::string>, std::unordered_set<std::string>>>::type
113 return T::dependencies();
122typename std::enable_if<!has_dependencies<T>::value, std::pair<std::unordered_set<std::string>, std::unordered_set<std::string>>>::type
131struct has_pretty_name {
132 template <
typename C>
133 static constexpr decltype(C::pretty_name(), bool()) test(
int)
138 template <
typename C>
139 static constexpr bool test(...)
144 static constexpr bool value = test<T>(
int());
153typename std::enable_if<has_pretty_name<T>::value, std::string>::type plugin_pretty_name(
const std::string& plugin_name)
155 return T::pretty_name();
164typename std::enable_if<!has_pretty_name<T>::value, std::string>::type plugin_pretty_name(
const std::string& plugin_name)
188#define PDI_PLUGIN(name) \
189 _Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wmissing-prototypes\"") \
190 _Pragma("clang diagnostic ignored \"-Wreturn-type-c-linkage\"" \
191 ) extern "C" ::std::unique_ptr<::PDI::Plugin> PDI_EXPORT PDI_plugin_##name##_loader(::PDI::Context& ctx, PC_tree_t conf) \
193 auto plugin = ::std::unique_ptr<name##_plugin>{new name##_plugin{ctx, conf}}; \
194 ::PDI::plugin_api_version(PLUGIN_API_VERSION); \
197 extern "C" ::std::pair<::std::unordered_set<::std::string>, ::std::unordered_set<::std::string>> PDI_EXPORT PDI_plugin_##name##_dependencies() \
199 return ::plugin_dependencies<name##_plugin>(); \
201 extern "C" ::std::string PDI_EXPORT PDI_plugin_##name##_pretty_name() \
203 return ::plugin_pretty_name<name##_plugin>(#name); \
205 _Pragma("clang diagnostic pop")
The class PDI plugins should implement.
Definition: plugin.h:43
virtual ~Plugin() noexcept(false)
Plugin(Context &ctx)
Initialization of the plugin.
Plugin(const Plugin &)=delete
Definition: array_datatype.h:38
unsigned long plugin_api_version(unsigned long expected_version=0)
Checks compatibility with a plugin API.