LeechCraft  0.6.70-15082-g543737046d
Modular cross-platform feature rich live environment.
IPluginsManager Class Referenceabstract

This interface is used to represent LeechCraft's global plugin manager. More...

#include "ipluginsmanager.h"

Public Member Functions

virtual ~IPluginsManager ()
 
virtual QObjectList GetAllPlugins () const =0
 Returns list of pointers to all present plugins. More...
 
template<typename T >
QObjectList Filter (const QObjectList &source) const
 Filters the given list of plugins and returns only those that can be casted to the given template type. More...
 
template<typename T >
QObjectList GetAllCastableRoots () const
 This is the same as Filter<T> (GetAllPlugins()). More...
 
template<typename T >
QList< T > GetAllCastableTo () const
 Similar to GetAlLCastableRoots() and provided for convenience. More...
 
virtual QObject * GetPluginByID (const QByteArray &id) const =0
 Returns plugin identified by its id. More...
 
virtual QString GetPluginLibraryPath (const QObject *object) const =0
 Returns the library path from which plugin instance object has been loaded. More...
 
virtual void InjectPlugin (QObject *object)=0
 Injects the given plugin object. More...
 
virtual void ReleasePlugin (QObject *object)=0
 Releases and removes the given plugin object. More...
 
virtual QObject * GetQObject ()=0
 Returns the pointer to plugin manager as a QObject. More...
 
virtual void OpenSettings (QObject *plugin)=0
 Opens the settings page for the given plugin object. More...
 
virtual ILoadProgressReporter_ptr CreateLoadProgressReporter (QObject *thisPlugin)=0
 Creates an object for reporting progress of a long-running load-time operation. More...
 
virtual QIcon GetPluginIcon (QObject *)=0
 

Detailed Description

This interface is used to represent LeechCraft's global plugin manager.

Through is interface you can get information about currently installed and running plugins, communicate with them at low-level (for example, by getting a pointer to the corresponding QObject* and casting it to any interface you want). It is also possible to inject new plugins into LeechCraft via this interface and try to release already running ones.

This object also has the following signals:

  • pluginInjected(QObject*), which is emitted after a successful plugin injection.

Definition at line 34 of file ipluginsmanager.h.

Constructor & Destructor Documentation

◆ ~IPluginsManager()

virtual IPluginsManager::~IPluginsManager ( )
inlinevirtual

Definition at line 37 of file ipluginsmanager.h.

Member Function Documentation

◆ CreateLoadProgressReporter()

virtual ILoadProgressReporter_ptr IPluginsManager::CreateLoadProgressReporter ( QObject *  thisPlugin)
pure virtual

Creates an object for reporting progress of a long-running load-time operation.

This method should be called by any plugin doing some long-running operation during LeechCraft load (like a DB migration) because of usability reasons.

Parameters
[in]thisPluginThe pointer to the instance object of the plugin that runs the long-running operation (typically the plugin where the code invoking this function belongs).
Returns
The object used to track progress of the long-running operation. The returnd object may be used for progress reports of multiple operations at once.
See also
ILoadProgressReporter

◆ Filter()

template<typename T >
QObjectList IPluginsManager::Filter ( const QObjectList &  source) const
inline

Filters the given list of plugins and returns only those that can be casted to the given template type.

Please note that you will almost always call it as Filter<T*> — note that you check against the pointer type.

Parameters
[in]sourceThe list of plugins to filter.
Returns
The list of plugins from source that can be casted ty type T.

Definition at line 55 of file ipluginsmanager.h.

◆ GetAllCastableRoots()

template<typename T >
QObjectList IPluginsManager::GetAllCastableRoots ( ) const
inline

This is the same as Filter<T> (GetAllPlugins()).

This function takes all available plugins from GetAllPlugins() and returns only those that can be casted to T via passing the result of GetAllPlugins() to Filter<T>().

Returns
The list of pointers to plugin instances that are castable to type T.

Definition at line 74 of file ipluginsmanager.h.

◆ GetAllCastableTo()

template<typename T >
QList<T> IPluginsManager::GetAllCastableTo ( ) const
inline

Similar to GetAlLCastableRoots() and provided for convenience.

This function is almost the same as GetAllCastableRoots(), except it returns the list of pointers to the corresponding interface. Generally, it takes the result of GetAllCastableRoots() and converts each pointer from the list returned by GetAllCastableRoots() to the requested interface.

Returns
The list of pointers to the requested interface.

Definition at line 91 of file ipluginsmanager.h.

◆ GetAllPlugins()

virtual QObjectList IPluginsManager::GetAllPlugins ( ) const
pure virtual

Returns list of pointers to all present plugins.

Returns
The list of pointers to all present plugins.

◆ GetPluginByID()

virtual QObject* IPluginsManager::GetPluginByID ( const QByteArray &  id) const
pure virtual

Returns plugin identified by its id.

If there is no such plugin with the given id, this function returns a null pointer.

Parameters
[in]idThe ID of the plugin.
Returns
The plugin instance or null if no such plugin exists.

◆ GetPluginIcon()

virtual QIcon IPluginsManager::GetPluginIcon ( QObject *  )
pure virtual

◆ GetPluginLibraryPath()

virtual QString IPluginsManager::GetPluginLibraryPath ( const QObject *  object) const
pure virtual

Returns the library path from which plugin instance object has been loaded.

If the path could not be determined for some reason (for example, if the plugin was injected or provided by a plugin adaptor, or if the given object is not a plugin instance) this function returns an empty string.

Please note that you cannot get library path for an arbitrary object. Only objects that are plugin instances ("root" objects in a plugin) are supported.

Parameters
[in]objectThe object for which to get the library path.
Returns
The path corresponding to the plugin represented by the plugin instance object.

◆ GetQObject()

virtual QObject* IPluginsManager::GetQObject ( )
pure virtual

Returns the pointer to plugin manager as a QObject.

You can connect to signals of the plugin manager with the use of this function, for example.

Returns
The plugin manager as a QObject.

◆ InjectPlugin()

virtual void IPluginsManager::InjectPlugin ( QObject *  object)
pure virtual

Injects the given plugin object.

The object's semantics are the same as the semantics of the "root" plugin object (returned by QPluginLoader::instance()). Thus, object should be castable at least to IInfo interface in order to be successfully loaded.

Parameters
[in]objectThe pointer to the "root" plugin object.
See also
ReleasePlugin()

◆ OpenSettings()

virtual void IPluginsManager::OpenSettings ( QObject *  plugin)
pure virtual

Opens the settings page for the given plugin object.

If the plugin doesn't implement IHaveSettings, this function does nothing.

Parameters
[in]pluginThe plugin for which to open the settings page.

◆ ReleasePlugin()

virtual void IPluginsManager::ReleasePlugin ( QObject *  object)
pure virtual

Releases and removes the given plugin object.

This function tries to release and remove the given object plugin from LeechCraft. Because of that, object has to be injected earlier with InjectPlugin().

Usage of this function is discouraged as it may lead to instabilities, because other plugins may have established connections and kept pointers to the object.

Parameters
[in]objectThe object previously injected with InjectPlugin().
See also
InjectPlugin()

The documentation for this class was generated from the following file: