diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-09-20 20:01:23 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-09-20 20:01:23 +0100 |
commit | df0080bb4e675c4dd59cf88ee823a5c51090fe4d (patch) | |
tree | f41176e60400df31529bc91545312f96e1985f19 | |
parent | Use resolvers to load libraries automagically on demand (diff) | |
download | libadhocutil-df0080bb4e675c4dd59cf88ee823a5c51090fe4d.tar.bz2 libadhocutil-df0080bb4e675c4dd59cf88ee823a5c51090fe4d.tar.xz libadhocutil-df0080bb4e675c4dd59cf88ee823a5c51090fe4d.zip |
Macro for instantiating plug-in resolver
-rw-r--r-- | libadhocutil/plugins.impl.h | 12 |
1 files changed, 12 insertions, 0 deletions
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<T>(const AdHoc::PluginManager::PluginResolver & f); \ template void AdHoc::PluginManager::removeResolver<T>(); \ +#define PLUGINRESOLVER(T, F) \ + namespace MAKE_UNIQUE(__plugin__) { \ + static void InstallResolver() __attribute__((constructor(102))); \ + void InstallResolver() { \ + ::AdHoc::PluginManager::getDefault()->addResolver<T>(F); \ + } \ + static void UninstallResolver() __attribute__((destructor(102))); \ + void UninstallResolver() { \ + ::AdHoc::PluginManager::getDefault()->removeResolver<T>(); \ + } \ + } + #endif |