PluginLoader singleton to load plugins from multiple directories Plugins have the extension omnix.
More...
#include <PluginLoader.h>
|
| PluginLoader (std::vector< QDir >const &_paths=std::vector< QDir >(), bool _defaultPaths=true) |
|
|
static void | load (std::vector< QDir >const &_paths) |
| Load plugins from list of paths. More...
|
|
static void | load (QDir const &_path) |
| Load plugins from single path. More...
|
|
static std::vector< QDir > | defaultPaths () |
| Return default plugin path. More...
|
|
static std::vector< PluginInfo >
const & | loadedPlugins () |
| Return list of information about loaded plugins. More...
|
|
|
static void | loadPlugin (QString const &_file) |
| Load a single plugin from file. More...
|
|
PluginLoader singleton to load plugins from multiple directories Plugins have the extension omnix.
omni::PluginLoader::PluginLoader |
( |
std::vector< QDir >const & |
_paths = std::vector<QDir>() , |
|
|
bool |
_defaultPaths = true |
|
) |
| |
static std::vector< QDir > defaultPaths()
Return default plugin path.
Definition: PluginLoader.cpp:83
static void load(std::vector< QDir >const &_paths)
Load plugins from list of paths.
Definition: PluginLoader.cpp:38
std::vector< QDir > omni::PluginLoader::defaultPaths |
( |
| ) |
|
|
static |
Return default plugin path.
84 std::vector<QDir> _pluginDirs;
85 _pluginDirs.push_back(QCoreApplication::applicationDirPath());
88 QDir _appDir(QCoreApplication::applicationDirPath());
89 if (_appDir.dirName() ==
"MacOS") {
95 _pluginDirs.push_back(_dir);
101 _pluginDirs.push_back(_dir);
104 _dir.cd(
"omnidome.app");
107 _pluginDirs.push_back(_dir);
111 #if defined(Q_OS_LINUX)
112 _pluginDirs.push_back(QDir(
"/usr/share/Omnidome/plugins"));
113 _pluginDirs.push_back(QDir(QDir::homePath() +
"/.local/Omnidome/plugins"));
void omni::PluginLoader::load |
( |
std::vector< QDir >const & |
_paths | ) |
|
|
static |
Load plugins from list of paths.
39 for (
auto& _path : _paths) {
40 qDebug() <<
"Plugin Path: " << _path.absolutePath();
static void load(std::vector< QDir >const &_paths)
Load plugins from list of paths.
Definition: PluginLoader.cpp:38
void omni::PluginLoader::load |
( |
QDir const & |
_path | ) |
|
|
static |
Load plugins from single path.
26 QDirIterator dirIt(_path);
27 while (dirIt.hasNext()) {
29 auto _path = dirIt.filePath();
30 if (!QFileInfo(_path).isFile())
continue;
32 if (QFileInfo(_path).suffix() ==
"omnix") {
static void loadPlugin(QString const &_file)
Load a single plugin from file.
Definition: PluginLoader.cpp:45
std::vector< PluginInfo > const & omni::PluginLoader::loadedPlugins |
( |
| ) |
|
|
static |
Return list of information about loaded plugins.
static std::vector< PluginInfo > loadedPlugins_
Kept list of loaded plugins.
Definition: PluginLoader.h:33
void omni::PluginLoader::loadPlugin |
( |
QString const & |
_file | ) |
|
|
staticprivate |
Load a single plugin from file.
46 QPluginLoader _pluginLoader(_path);
47 qDebug() <<
"Loading plugin: " << _path;
48 QObject *plugin = _pluginLoader.instance();
52 auto* _inputInterface = qobject_cast<input::Interface*>(plugin);
53 if (_inputInterface) {
54 qDebug() <<
"Loaded input plugin: " << _inputInterface->getTypeId();
55 _inputInterface->registerInFactory();
57 auto* _mappingInterface = qobject_cast<mapping::Interface*>(plugin);
58 if (_mappingInterface) {
59 qDebug() <<
"Loaded mapping plugin: " << _mappingInterface->getTypeId();
60 _mappingInterface->registerInFactory();
62 auto* _canvasInterface = qobject_cast<canvas::Interface*>(plugin);
63 if (_canvasInterface) {
64 qDebug() <<
"Loaded canvas plugin: " << _canvasInterface->getTypeId();
65 _canvasInterface->registerInFactory();
68 auto* _patchInterface = qobject_cast<patch::Interface*>(plugin);
69 if (_patchInterface) {
70 qDebug() <<
"Loaded patch plugin: " << _patchInterface->getTypeId();
71 _patchInterface->registerInFactory();
75 qDebug() <<
"Error loading plugin: " << _pluginLoader.errorString();
static std::vector< PluginInfo > loadedPlugins_
Kept list of loaded plugins.
Definition: PluginLoader.h:33
static PluginInfo make(QString const &_file, QObject const *)
Make a PluginInfo from file and QObject.
Definition: PluginInfo.cpp:80
std::vector< PluginInfo > omni::PluginLoader::loadedPlugins_ |
|
staticprivate |
Kept list of loaded plugins.
The documentation for this class was generated from the following files: