GemaCoreLib
The GeMA Core library
gmPluginInfo.h
Go to the documentation of this file.
1 /************************************************************************
2 **
3 ** Copyright (C) 2014 by Carlos Augusto Teixera Mendes
4 ** All rights reserved.
5 **
6 ** This file is part of the "GeMA" software. It's use should respect
7 ** the terms in the license agreement that can be found together
8 ** with this source code.
9 ** It is provided AS IS, with NO WARRANTY OF ANY KIND,
10 ** INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR
11 ** A PARTICULAR PURPOSE.
12 **
13 ************************************************************************/
14 
24 #ifndef _GEMA_PLUGIN_INFO_H_
25 #define _GEMA_PLUGIN_INFO_H_
26 
27 #include <QString>
28 #include <QStringList>
29 #include <QMap>
30 #include <QVariant>
31 
32 #include "gmCoreConfig.h"
33 
34 class GmLogCategory;
35 class LuaTable;
36 
39 {
40 public:
41  ~GmPluginInfo();
42 
44  QString path() const { return _path; }
45 
47  QString name() const { return _name; }
48 
50  QString version() const { return _version; }
51 
53  const QStringList& categoryList() const { return _categoryList; }
54 
56  QString categoryStr() const { return _categoryList.join(", "); }
57 
59  int categoryIndex(QString cat) const { return _categoryList.indexOf(cat); }
60 
62  const QStringList& typeList(int catIndex) const { return _typeList.at(catIndex); }
63 
65  int typeIndex(int catIndex, QString objType) const { return _typeList.at(catIndex).indexOf(objType); }
66 
68  QString typeName(int catIndex, int typeIndex) const { return _name + "." + _typeList.at(catIndex).at(typeIndex); }
69 
73  QString pluginLuaRsrc() const { return _pluginRsrc; }
74 
76  QString pluginLuaTableName() const { return _name + "Plugin"; }
77 
82  QString checkAttributesFunction() const { return _checkFunctionName; }
83 
88  QString pluginDataCheckFunction() const { return _pluginDataCheckFunctionName; }
89 
91  const QStringList& pluginDataAliases() const { return _pluginDataAliases; }
92 
94  const QVariantMap& attributes() const { return _pluginAttributes; }
95 
96 
98  const QStringList& dependencies() const { return _pluginDependencies; }
99 
100  void printParameters(const GmLogCategory& logger);
101 
102  static GmPluginInfo* instance(QString infoFileName, QString sharedFileName, const GmLogCategory& logger);
103 
104  static void splitTypeName(QString typeName, QString& pluginName, QString& pluginType);
105 
106 private:
107  GmPluginInfo(QString name, const QStringList& category, QString version, const QList<QStringList>& typeList,
108  QVariantMap pluginAttr, QString rsrc, QString checkFuncName, const QStringList& dependencies,
109  QString pluginDataCheckFuncName, const QStringList& pluginDataAliases, QString sharedFilePath);
110 
116  QVariantMap _pluginAttributes;
122 };
123 
124 
125 #endif
126 
const QStringList & pluginDataAliases() const
Returns a list of aliases for PluginData objects understood by this plugin.
Definition: gmPluginInfo.h:91
QString path() const
Returns the path to the shared library that implements this plugin.
Definition: gmPluginInfo.h:44
QString _checkFunctionName
Name of a Lua function used to validate plugin parameters.
Definition: gmPluginInfo.h:118
const QStringList & categoryList() const
Returns the plugin type.
Definition: gmPluginInfo.h:53
Base class used to store information about a generic plugin.
Definition: gmPluginInfo.h:38
QString checkAttributesFunction() const
Returns the name of the Lua function defined in the resource returned by pluginLuaRsrc() used to vali...
Definition: gmPluginInfo.h:82
const QVariantMap & attributes() const
Map with additional attributes describing the plugin and unused by the plugin manager.
Definition: gmPluginInfo.h:94
QString typeName(int catIndex, int typeIndex) const
Returns the full hierarchical type name for one entry in the typeList.
Definition: gmPluginInfo.h:68
QString name() const
Returns the plugin name.
Definition: gmPluginInfo.h:47
Declaration of usefull configuration definitions for the Core library.
const T & at(int i) const const
QStringList _categoryList
Plugin category list.
Definition: gmPluginInfo.h:114
const QStringList & typeList(int catIndex) const
Returns a list with the object types implemented by the plugin for one entry in the categoryList.
Definition: gmPluginInfo.h:62
QString categoryStr() const
Returns a comma separated string combining the names of all categories supported by this plugin.
Definition: gmPluginInfo.h:56
const QStringList & dependencies() const
Returns a list of plugins that must be loaded before this plugin can be loaded to memory.
Definition: gmPluginInfo.h:98
int categoryIndex(QString cat) const
Returns the index of the given category in the category list or -1 if not found.
Definition: gmPluginInfo.h:59
QList< QStringList > _typeList
List of object types implemented by the plugin per category. Ordered as _categoryList.
Definition: gmPluginInfo.h:115
QVariantMap _pluginAttributes
Map with additional attributes provided by the plugin.
Definition: gmPluginInfo.h:116
int typeIndex(int catIndex, QString objType) const
Returns the index of the given object type in the type list or -1 if not found.
Definition: gmPluginInfo.h:65
QStringList _pluginDataAliases
List of aliases for PluginData objects understood by this plugin.
Definition: gmPluginInfo.h:121
QStringList _pluginDependencies
List of plugins that should be loaded before this one. Can be empty.
Definition: gmPluginInfo.h:119
QString _pluginRsrc
Rsrc containing a Lua script with functions used by the plugin.
Definition: gmPluginInfo.h:117
#define GMC_API_EXPORT
Macro for controling if the class is being exported (GEMA_CORE_LIB defined) or imported (GEMA_CORE_LI...
Definition: gmCoreConfig.h:35
Class representing a category with multiple logging levels.
Definition: gmLog.h:58
QString _path
Path to the plugin shared library.
Definition: gmPluginInfo.h:111
QString _name
Plugin name.
Definition: gmPluginInfo.h:112
QString _version
Plugin version (optional, from the Lua file, NOT from the plugin itself)
Definition: gmPluginInfo.h:113
const QChar at(int position) const const
QString pluginLuaRsrc() const
Returns the rsrc name for a set of Lua functions defined by the plugin or "" if the plugin does not h...
Definition: gmPluginInfo.h:73
QString version() const
Returns the optional plugin version from the Lua file, NOT from the plugin itself.
Definition: gmPluginInfo.h:50
QString pluginLuaTableName() const
Returns the name of the Lua table used to host functions defined in the plugin rsrc (if it exists)
Definition: gmPluginInfo.h:76
QString _pluginDataCheckFunctionName
Name of a Lua function used to validate associated plugin data.
Definition: gmPluginInfo.h:120
QString pluginDataCheckFunction() const
Returns the name of the Lua function defined in the resource returned by pluginLuaRsrc() used to vali...
Definition: gmPluginInfo.h:88