File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,11 @@ namespace clap { namespace helpers {
41
41
virtual void deinit () noexcept {}
42
42
virtual const void *getFactory (const char *factoryId) const noexcept { return nullptr ; };
43
43
virtual bool enableDraftFactories () const noexcept { return false ; }
44
+ // needed for adding custom factories to a class derived from PluginEntry
45
+ template <typename T,
46
+ typename = typename std::enable_if<std::is_base_of<PluginEntry, T>::value &&
47
+ std::is_default_constructible<T>::value>::type>
48
+ static const T &getInstance () noexcept ;
44
49
45
50
// clap_plugin_factory
46
51
virtual bool implementsPluginFactory () const noexcept { return false ; }
Original file line number Diff line number Diff line change @@ -25,6 +25,14 @@ namespace clap { namespace helpers {
25
25
};
26
26
}
27
27
28
+ template <MisbehaviourHandler h, CheckingLevel l>
29
+ template <typename T, typename ValidImpl>
30
+ const T &PluginEntry<h, l>::getInstance() noexcept {
31
+ assert (_instance &&
32
+ " make sure to call this only between plugin_entry.init and plugin_entry.deinit" );
33
+ return *static_cast <const T *>(_instance.get ());
34
+ }
35
+
28
36
template <MisbehaviourHandler h, CheckingLevel l>
29
37
int32_t PluginEntry<h, l>::getPluginIndexForPluginId(const char *pluginId) const noexcept {
30
38
const auto count = pluginFactoryGetPluginCount ();
You can’t perform that action at this time.
0 commit comments