diff options
Diffstat (limited to 'base/plugins.h')
-rw-r--r-- | base/plugins.h | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/base/plugins.h b/base/plugins.h index 2793ff3ffd..ce45f7102a 100644 --- a/base/plugins.h +++ b/base/plugins.h @@ -190,6 +190,15 @@ public: PluginType getType() const; const char *getName() const; + template <class T> + T &get() const { + T *pluginObject = dynamic_cast<T *>(_pluginObject); + if (!pluginObject) { + error("Invalid cast of plugin %s", getName()); + } + return *pluginObject; + } + /** * The getFileName() function gets the name of the plugin file for those * plugins that have files (ie. not static). It doesn't require the plugin @@ -202,25 +211,6 @@ public: typedef Common::Array<Plugin *> PluginList; /** - * Convenience template to make it easier defining normal Plugin - * subclasses. Namely, the PluginSubclass will manage PluginObjects - * of a type specified via the PO_t template parameter. - */ -template<class PO_t> -class PluginSubclass : public Plugin { -public: - PO_t &operator*() const { - return *(PO_t *)_pluginObject; - } - - PO_t *operator->() const { - return (PO_t *)_pluginObject; - } - - typedef Common::Array<PluginSubclass *> List; -}; - -/** * Abstract base class for Plugin factories. Subclasses of this * are responsible for creating plugin objects, e.g. by loading * loadable modules from storage media; by creating "fake" plugins |