31#include <unordered_set>
34#include <pdi/pdi_fwd.h>
35#include <pdi/logger.h>
65#define PLUGIN_API_VERSION_MAJOR (0ul)
67#define PLUGIN_API_VERSION_MINOR (0ul)
69#define PLUGIN_API_VERSION_PATCH (1ul)
71#define PLUGIN_API_VERSION ((PLUGIN_API_VERSION_MAJOR<<24) + (PLUGIN_API_VERSION_MINOR<<16) + (PLUGIN_API_VERSION_PATCH<<8))
89struct has_dependencies {
91 static constexpr decltype(C::dependencies(), bool()) test(
int)
96 static constexpr bool test(...)
100 static constexpr bool value = test<T>(
int());
109typename std::enable_if<has_dependencies<T>::value, std::pair<std::unordered_set<std::string>, std::unordered_set<std::string>>>::type plugin_dependencies()
111 return T::dependencies();
120typename std::enable_if<!has_dependencies<T>::value, std::pair<std::unordered_set<std::string>, std::unordered_set<std::string>>>::type plugin_dependencies()
128struct has_pretty_name {
129 template <
typename C>
130 static constexpr decltype(C::pretty_name(), bool()) test(
int)
134 template <
typename C>
135 static constexpr bool test(...)
139 static constexpr bool value = test<T>(
int());
148typename std::enable_if<has_pretty_name<T>::value, std::string>::type plugin_pretty_name(
const std::string& plugin_name)
150 return T::pretty_name();
159typename std::enable_if<!has_pretty_name<T>::value, std::string>::type plugin_pretty_name(
const std::string& plugin_name)
183#define PDI_PLUGIN(name)\
184 _Pragma("clang diagnostic push")\
185 _Pragma("clang diagnostic ignored \"-Wmissing-prototypes\"")\
186 _Pragma("clang diagnostic ignored \"-Wreturn-type-c-linkage\"")\
187 extern "C" ::std::unique_ptr<::PDI::Plugin> PDI_EXPORT PDI_plugin_##name##_loader(::PDI::Context& ctx, PC_tree_t conf) \
189 auto plugin = ::std::unique_ptr<name##_plugin>{new name##_plugin{ctx, conf}};\
190 ::PDI::plugin_api_version(PLUGIN_API_VERSION);\
193 extern "C" ::std::pair<::std::unordered_set<::std::string>, ::std::unordered_set<::std::string>> PDI_EXPORT PDI_plugin_##name##_dependencies() \
195 return ::plugin_dependencies<name##_plugin>();\
197 extern "C" ::std::string PDI_EXPORT PDI_plugin_##name##_pretty_name() \
199 return ::plugin_pretty_name<name##_plugin>(#name);\
201 _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.