Albert
|
#include <albert/plugindependency.h>
Convenience holder class for plugin soft dependencies.
Fetches and holds the weak pointer to the dependecy. On (de)registration of the dependency the pointer is updated and the callback called.
If you use this class you may want to lock a mutex against a query handler or an action. This should not be necessary since the plugin loader and the extension registry must not be accessed while a session query is running. Take care though if you defer the execution of the action using a timer or similar.
Public Member Functions | |
WeakDependency (ExtensionRegistry ®istry, const QString &id, std::function< void(bool)> registeredCallback={}) | |
WeakDependency constructor. | |
~WeakDependency () | |
Public Member Functions inherited from albert::Dependency< T > | |
operator T () const | |
operator bool () const | |
const T * | operator-> () const |
T * | operator-> () |
const T * | get () const |
T * | get () |
Public Attributes | |
std::function< void(bool)> | callback |
(De)Registration callback | |
Additional Inherited Members | |
Protected Member Functions inherited from albert::Dependency< T > | |
Dependency (ExtensionRegistry ®istry, const QString &id) | |
Protected Attributes inherited from albert::Dependency< T > | |
T * | dependency = nullptr |
|
inlineexplicit |
WeakDependency constructor.
registry | The extension registry |
id | The id of the dependency |
registeredCallback | A callback that is called when the dependency is (un)registered |
|
inline |
std::function<void(bool)> albert::WeakDependency< T >::callback |
(De)Registration callback
bool | true if the dependency was added, false if it was removed |