Brief description of class still missing. More...
#include <GeopsyPlugins.h>
Public Member Functions | |
GeopsyCoreInterface * | at (int index) const |
int | count () const |
GeopsyPlugins (bool debug=false) | |
void | polish () |
~GeopsyPlugins () | |
Static Public Member Functions | |
static QStringList | getList (QStringList libs, bool &ok, bool debug=false) |
static GeopsyCoreInterface * | load (QString pluginFile, bool debug=false) |
Brief description of class still missing.
Full description of class still missing
GeopsyCore::GeopsyPlugins::GeopsyPlugins | ( | bool | debug = false | ) |
Description of constructor still missing
{ TRACE; QSettings reg; reg.beginGroup("Plugins"); reg.beginGroup(GEOPSYCORE_VERSION_TYPE); if(debug || !reg.contains("pluginList")) { init(debug); } if(!load()) { printf("Detected wrong interface version reset to default\n"); // Clean all previously loaded plugins (there will be deleted by application) _list.clear(); reg.remove(""); // remove current paths and force default ones init(debug); load(); } }
GeopsyCoreInterface* GeopsyCore::GeopsyPlugins::at | ( | int | index | ) | const [inline] |
Referenced by ToolFactory::ToolFactory().
{return _list.at(index);}
int GeopsyCore::GeopsyPlugins::count | ( | ) | const [inline] |
Referenced by ToolFactory::ToolFactory().
{return _list.count();}
QStringList GeopsyCore::GeopsyPlugins::getList | ( | QStringList | libs, |
bool & | ok, | ||
bool | debug = false |
||
) | [static] |
ok is set to false if plugins with wrong interface versions are detected.
References QGpCoreTools::endl(), GeopsyCore::GeopsyCoreInterface::isValid(), load(), QGpCoreTools::tr(), and TRACE.
{ TRACE; ok=true; QStringList plugins; int n=libs.count(); if(n<=0) return plugins; /*QProgressDialog * d; if(Application::instance()->hasGui()) { d=new QProgressDialog(tr("Searching plugins ..."), QString::null, 0, n-1, QApplication::activeWindow()); } else { d=0; }*/ for(int i=0;i<n;i++) { //if(d) d->setValue(i); QString libFile=libs.at(i); if(libFile.isEmpty()) { plugins << ""; } else { GeopsyCoreInterface * p=load(libFile, debug); if(p) { if(p->isValid()) { plugins << libFile; } else { App::stream() << tr("%1 has not a correct interface version.").arg(libFile) << endl; ok=false; } CoreApplication::instance()->deletePlugin(p); } } } //delete d; return plugins; }
GeopsyCoreInterface * GeopsyCore::GeopsyPlugins::load | ( | QString | pluginFile, |
bool | debug = false |
||
) | [static] |
References GeopsyCore::GeopsyCoreInterface::interfaceVersion(), and TRACE.
Referenced by GeopsyPlugins(), and getList().
{ TRACE; if(debug) { printf("Load library %s\n",pluginFile.toAscii().data()); fflush(stdout); } QPluginLoader pluginTest; pluginTest.setFileName(pluginFile); QObject * instance=pluginTest.instance(); if(instance) { if(debug) { printf(" Library loaded successfully\n"); fflush(stdout); } GeopsyCoreInterface * p=qobject_cast<GeopsyCoreInterface *>(instance); if(p) { if(debug) { printf(" Geopsy tool interface\n"); printf(" Geopsy interface version=%s\n",p->interfaceVersion()); fflush(stdout); } return p; } } else if(debug) { printf(" %s\n",pluginTest.errorString().toAscii().data()); fflush(stdout); } CoreApplication::instance()->deletePlugin(instance); return 0; }
void GeopsyCore::GeopsyPlugins::polish | ( | ) |
Actions to be executed after a complete initialization of GeopsyCoreEngine.
References GeopsyCore::GeopsyCoreInterface::polish(), and TRACE.
Referenced by GeopsyCore::GeopsyCoreEngine::GeopsyCoreEngine().
{ TRACE; foreach(GeopsyCoreInterface * p, _list) { p->polish(); } }