LeechCraft 0.6.70-17609-g3dde4097dd
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
ipluginsmanager.h
Go to the documentation of this file.
1/**********************************************************************
2 * LeechCraft - modular cross-platform feature rich internet client.
3 * Copyright (C) 2006-2014 Georg Rudoy
4 *
5 * Distributed under the Boost Software License, Version 1.0.
6 * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7 **********************************************************************/
8
9#pragma once
10
11#include <memory>
12#include <QStringList>
13#include <QObjectList>
14
16using ILoadProgressReporter_ptr = std::shared_ptr<ILoadProgressReporter>;
17
18class QIcon;
19
34class Q_DECL_EXPORT IPluginsManager
35{
36public:
37 virtual ~IPluginsManager () {}
38
43 virtual QObjectList GetAllPlugins () const = 0;
44
54 template<typename T>
55 QObjectList Filter (const QObjectList& source) const
56 {
57 QObjectList result;
58 for (const auto sp : source)
59 if (qobject_cast<T> (sp))
60 result << sp;
61 return result;
62 }
63
73 template<typename T>
74 QObjectList GetAllCastableRoots () const
75 {
76 return Filter<T> (GetAllPlugins ());
77 }
78
90 template<typename T>
92 {
93 QList<T> result;
94 for (const auto root : GetAllCastableRoots<T> ())
95 result << qobject_cast<T> (root);
96 return result;
97 }
98
107 virtual QObject* GetPluginByID (const QByteArray& id) const = 0;
108
125 virtual QString GetPluginLibraryPath (const QObject* object) const = 0;
126
138 virtual void InjectPlugin (QObject *object) = 0;
139
155 virtual void ReleasePlugin (QObject *object) = 0;
156
164 virtual QObject* GetQObject () = 0;
165
173 virtual void OpenSettings (QObject *plugin) = 0;
174
191 virtual ILoadProgressReporter_ptr CreateLoadProgressReporter (QObject *thisPlugin) = 0;
192
193 virtual QIcon GetPluginIcon (QObject*) = 0;
194};
195
196Q_DECLARE_INTERFACE (IPluginsManager, "org.Deviant.LeechCraft.IPluginsManager/1.0")
Interface for reporting progress of some long-running operation during load time.
This interface is used to represent LeechCraft's global plugin manager.
virtual void OpenSettings(QObject *plugin)=0
Opens the settings page for the given plugin object.
virtual void ReleasePlugin(QObject *object)=0
Releases and removes the given plugin object.
virtual void InjectPlugin(QObject *object)=0
Injects the given plugin object.
virtual ILoadProgressReporter_ptr CreateLoadProgressReporter(QObject *thisPlugin)=0
Creates an object for reporting progress of a long-running load-time operation.
virtual ~IPluginsManager()
virtual QString GetPluginLibraryPath(const QObject *object) const =0
Returns the library path from which plugin instance object has been loaded.
virtual QIcon GetPluginIcon(QObject *)=0
virtual QObjectList GetAllPlugins() const =0
Returns list of pointers to all present plugins.
QObjectList GetAllCastableRoots() const
This is the same as Filter<T> (GetAllPlugins()).
virtual QObject * GetQObject()=0
Returns the pointer to plugin manager as a QObject.
QObjectList Filter(const QObjectList &source) const
Filters the given list of plugins and returns only those that can be casted to the given template typ...
virtual QObject * GetPluginByID(const QByteArray &id) const =0
Returns plugin identified by its id.
QList< T > GetAllCastableTo() const
Similar to GetAlLCastableRoots() and provided for convenience.
std::shared_ptr< ILoadProgressReporter > ILoadProgressReporter_ptr
std::shared_ptr< ILoadProgressReporter > ILoadProgressReporter_ptr