From 6b5eedca8ed4c761de2202a5d4fe7711af7be198 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 27 Aug 2016 23:46:20 -0400 Subject: Use template mixins for extensions --- lv2/lv2plug.in/ns/lv2core/Plugin.hpp | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) (limited to 'lv2/lv2plug.in') diff --git a/lv2/lv2plug.in/ns/lv2core/Plugin.hpp b/lv2/lv2plug.in/ns/lv2core/Plugin.hpp index f671640..597dd38 100644 --- a/lv2/lv2plug.in/ns/lv2core/Plugin.hpp +++ b/lv2/lv2plug.in/ns/lv2core/Plugin.hpp @@ -1,5 +1,5 @@ /* - Copyright 2015 David Robillard + Copyright 2015-2016 David Robillard Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above @@ -46,7 +46,7 @@ namespace lv2 { The destructor will be called when the host cleans up the plugin. */ template -class Plugin +class PluginBase { public: /** @@ -79,10 +79,10 @@ public: @return A handle for the new plugin instance, or NULL if instantiation has failed. */ - Plugin(double sample_rate, - const char* bundle_path, - const LV2_Feature*const* features, - bool* valid) + PluginBase(double sampcle_rate, + const char* bundle_path, + const LV2_Feature*const* features, + bool* valid) {} /** @@ -215,7 +215,7 @@ public: &s_run, &s_deactivate, &s_cleanup, - &Plugin::extension_data }; + &PluginBase::extension_data }; return desc; } @@ -254,6 +254,28 @@ private: } }; +template class First=PluginBase, template class... Rest> +struct Plugin : public First< Plugin > { + Plugin(double rate, + const char* bundle_path, + const LV2_Feature* const* features, + bool* valid) + : First< Plugin >(rate, bundle_path, features, valid) + {} + +}; + +template class First> +struct Plugin : public First< PluginBase > { + Plugin(double rate, + const char* bundle_path, + const LV2_Feature* const* features, + bool* valid) + : First< PluginBase >(rate, bundle_path, features, valid) + {} + +}; + } /* namespace lv2 */ #endif /* LV2_PLUGIN_HPP */ -- cgit v1.2.1