LeechCraft  0.6.70-15082-g543737046d
Modular cross-platform feature rich live environment.
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 
16 using ILoadProgressReporter_ptr = std::shared_ptr<ILoadProgressReporter>;
17 
18 class QIcon;
19 
34 class Q_DECL_EXPORT IPluginsManager
35 {
36 public:
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 
196 Q_DECLARE_INTERFACE (IPluginsManager, "org.Deviant.LeechCraft.IPluginsManager/1.0")
IPluginsManager::GetAllCastableTo
QList< T > GetAllCastableTo() const
Similar to GetAlLCastableRoots() and provided for convenience.
Definition: ipluginsmanager.h:91
QList
Definition: ianrulesstorage.h:14
ILoadProgressReporter
Interface for reporting progress of some long-running operation during load time.
Definition: iloadprogressreporter.h:50
IPluginsManager::Filter
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...
Definition: ipluginsmanager.h:55
IPluginsManager
This interface is used to represent LeechCraft's global plugin manager.
Definition: ipluginsmanager.h:34
IPluginsManager::GetAllCastableRoots
QObjectList GetAllCastableRoots() const
This is the same as Filter<T> (GetAllPlugins()).
Definition: ipluginsmanager.h:74
IPluginsManager::~IPluginsManager
virtual ~IPluginsManager()
Definition: ipluginsmanager.h:37
ILoadProgressReporter_ptr
std::shared_ptr< ILoadProgressReporter > ILoadProgressReporter_ptr
Definition: iloadprogressreporter.h:65