All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines
Public Member Functions | Static Public Member Functions
GeopsyCore::GeopsyPlugins Class Reference

Brief description of class still missing. More...

#include <GeopsyPlugins.h>

List of all members.

Public Member Functions

GeopsyCoreInterfaceat (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 GeopsyCoreInterfaceload (QString pluginFile, bool debug=false)

Detailed Description

Brief description of class still missing.

Full description of class still missing


Constructor & Destructor Documentation

Description of constructor still missing

References load(), and TRACE.

  {
    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();
    }
  }

Description of destructor still missing

References TRACE.

  {
    TRACE;
  }

Member Function Documentation

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;
  }

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();
    }
  }

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines