Omnidome
Fulldome Mapping Software Toolkit
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | Static Private Member Functions | Static Private Attributes
omni::PluginLoader Class Reference

PluginLoader singleton to load plugins from multiple directories Plugins have the extension omnix. More...

#include <PluginLoader.h>

Collaboration diagram for omni::PluginLoader:
Collaboration graph
[legend]

Public Member Functions

 PluginLoader (std::vector< QDir >const &_paths=std::vector< QDir >(), bool _defaultPaths=true)
 

Static Public Member Functions

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 Private Member Functions

static void loadPlugin (QString const &_file)
 Load a single plugin from file. More...
 

Static Private Attributes

static std::vector< PluginInfoloadedPlugins_
 Kept list of loaded plugins. More...
 

Detailed Description

PluginLoader singleton to load plugins from multiple directories Plugins have the extension omnix.

Constructor & Destructor Documentation

omni::PluginLoader::PluginLoader ( std::vector< QDir >const &  _paths = std::vector<QDir>(),
bool  _defaultPaths = true 
)
18  {
19  load(_paths);
20  if (_defaultPaths) {
21  load(defaultPaths());
22  }
23  }
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

Member Function Documentation

std::vector< QDir > omni::PluginLoader::defaultPaths ( )
static

Return default plugin path.

83  {
84  std::vector<QDir> _pluginDirs;
85  _pluginDirs.push_back(QCoreApplication::applicationDirPath());
86  #if defined(Q_OS_MAC)
87  {
88  QDir _appDir(QCoreApplication::applicationDirPath());
89  if (_appDir.dirName() == "MacOS") {
90  // omnidome.app/Contents/MacOS
91  QDir _dir = _appDir;
92  _dir.cdUp();
93  _dir.cdUp();
94  _dir.cdUp();
95  _pluginDirs.push_back(_dir);
96 
97  // omnidome.app/Contents/PlugIns
98  _dir = _appDir;
99  _dir.cdUp();
100  _dir.cd("PlugIns");
101  _pluginDirs.push_back(_dir);
102  } else {
103  QDir _dir = _appDir;
104  _dir.cd("omnidome.app");
105  _dir.cd("Contents");
106  _dir.cd("PlugIns");
107  _pluginDirs.push_back(_dir);
108  }
109  }
110  #endif
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"));
114  #endif
115  return _pluginDirs;
116  }
void omni::PluginLoader::load ( std::vector< QDir >const &  _paths)
static

Load plugins from list of paths.

38  {
39  for (auto& _path : _paths) {
40  qDebug() << "Plugin Path: " << _path.absolutePath();
41  load(_path);
42  }
43  }
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.

25  {
26  QDirIterator dirIt(_path);
27  while (dirIt.hasNext()) {
28  dirIt.next();
29  auto _path = dirIt.filePath();
30  if (!QFileInfo(_path).isFile()) continue;
31 
32  if (QFileInfo(_path).suffix() == "omnix") {
33  loadPlugin(_path);
34  }
35  }
36  }
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.

79  {
80  return loadedPlugins_;
81  }
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.

45  {
46  QPluginLoader _pluginLoader(_path);
47  qDebug() << "Loading plugin: " << _path;
48  QObject *plugin = _pluginLoader.instance();
49  if (plugin) {
50  loadedPlugins_.push_back(PluginInfo::make(_path,plugin));
51 
52  auto* _inputInterface = qobject_cast<input::Interface*>(plugin);
53  if (_inputInterface) {
54  qDebug() << "Loaded input plugin: " << _inputInterface->getTypeId();
55  _inputInterface->registerInFactory();
56  }
57  auto* _mappingInterface = qobject_cast<mapping::Interface*>(plugin);
58  if (_mappingInterface) {
59  qDebug() << "Loaded mapping plugin: " << _mappingInterface->getTypeId();
60  _mappingInterface->registerInFactory();
61  }
62  auto* _canvasInterface = qobject_cast<canvas::Interface*>(plugin);
63  if (_canvasInterface) {
64  qDebug() << "Loaded canvas plugin: " << _canvasInterface->getTypeId();
65  _canvasInterface->registerInFactory();
66  }
67 
68  auto* _patchInterface = qobject_cast<patch::Interface*>(plugin);
69  if (_patchInterface) {
70  qDebug() << "Loaded patch plugin: " << _patchInterface->getTypeId();
71  _patchInterface->registerInFactory();
72  }
73  delete plugin;
74  } else {
75  qDebug() << "Error loading plugin: " << _pluginLoader.errorString();
76  }
77  }
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

Field Documentation

std::vector< PluginInfo > omni::PluginLoader::loadedPlugins_
staticprivate

Kept list of loaded plugins.


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