summaryrefslogtreecommitdiff
path: root/libadhocutil/plugins.h
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2018-04-06 11:30:10 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2018-04-07 08:45:51 +0100
commit66107ea15378cc30260224b668a0152acbcc353d (patch)
treec6750cfe82fe3d371dcd7ac7432ed8b3b0a44562 /libadhocutil/plugins.h
parentC++17 (diff)
downloadlibadhocutil-66107ea15378cc30260224b668a0152acbcc353d.tar.bz2
libadhocutil-66107ea15378cc30260224b668a0152acbcc353d.tar.xz
libadhocutil-66107ea15378cc30260224b668a0152acbcc353d.zip
C++17
Adds a friendly wrapper function to construct and install a plugin (similar interface std::make_...)
Diffstat (limited to 'libadhocutil/plugins.h')
-rw-r--r--libadhocutil/plugins.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/libadhocutil/plugins.h b/libadhocutil/plugins.h
index 0fab76e..fe86834 100644
--- a/libadhocutil/plugins.h
+++ b/libadhocutil/plugins.h
@@ -129,6 +129,21 @@ namespace AdHoc {
template<typename T> void add(const std::shared_ptr<T> & i, const std::string & n, const std::string & f, int l);
/**
+ * Create and install a plugin
+ * @tparam T Base type of plugin
+ * @tparam I Implementation type of plugin
+ * @tparam Args Constructor arguments types
+ * @param n Name of plugin.
+ * @param f Filename of plugin.
+ * @param l Line number.
+ * @param args Arguments to construct an instance of I with.
+ */
+ template<typename T, typename I, typename ... Args> void create(const std::string & n, const std::string & f, int l, const Args & ... args)
+ {
+ add<T>(std::make_shared<I>(args...), n, f, l);
+ }
+
+ /**
* Uninstall a plugin.
* @param n Name of plugin.
*/