From df0080bb4e675c4dd59cf88ee823a5c51090fe4d Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 20 Sep 2015 20:01:23 +0100 Subject: Macro for instantiating plug-in resolver --- libadhocutil/plugins.impl.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libadhocutil/plugins.impl.h b/libadhocutil/plugins.impl.h index 6d69880..a0cff98 100644 --- a/libadhocutil/plugins.impl.h +++ b/libadhocutil/plugins.impl.h @@ -99,5 +99,17 @@ namespace AdHoc { template void AdHoc::PluginManager::addResolver(const AdHoc::PluginManager::PluginResolver & f); \ template void AdHoc::PluginManager::removeResolver(); \ +#define PLUGINRESOLVER(T, F) \ + namespace MAKE_UNIQUE(__plugin__) { \ + static void InstallResolver() __attribute__((constructor(102))); \ + void InstallResolver() { \ + ::AdHoc::PluginManager::getDefault()->addResolver(F); \ + } \ + static void UninstallResolver() __attribute__((destructor(102))); \ + void UninstallResolver() { \ + ::AdHoc::PluginManager::getDefault()->removeResolver(); \ + } \ + } + #endif -- cgit v1.2.3