Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

qgspluginregistry.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002                     QgsPluginRegistry.cpp  -  Singleton class for
00003                     tracking registering plugins.
00004                              -------------------
00005     begin                : Fri Feb 7 2004
00006     copyright            : (C) 2004 by Gary E.Sherman
00007     email                : sherman at mrcc.com
00008  ***************************************************************************/
00009 
00010 /***************************************************************************
00011  *                                                                         *
00012  *   This program is free software; you can redistribute it and/or modify  *
00013  *   it under the terms of the GNU General Public License as published by  *
00014  *   the Free Software Foundation; either version 2 of the License, or     *
00015  *   (at your option) any later version.                                   *
00016  *                                                                         *
00017  ***************************************************************************/
00018  /* $Id: qgspluginregistry.cpp 6415 2007-01-09 02:39:15Z wonder $ */
00019 
00020 #include <iostream>
00021 #include <qmessagebox.h>
00022 #include <qstring.h>
00023 #include <qdir.h>
00024 #include <qlibrary.h>
00025 #include <qapplication.h>
00026 #include "qgsprovidermetadata.h"
00027 #include "qgspluginregistry.h"
00028 
00029 QgsPluginRegistry *QgsPluginRegistry::_instance = 0;
00030 QgsPluginRegistry *QgsPluginRegistry::instance()
00031 {
00032   if (_instance == 0)
00033     {
00034       _instance = new QgsPluginRegistry();
00035     }
00036   return _instance;
00037 }
00038 
00039 QgsPluginRegistry::QgsPluginRegistry()
00040 {
00041 // constructor does nothing
00042 }
00043 QString QgsPluginRegistry::library(QString pluginKey)
00044 {
00045   QgsPluginMetadata *pmd = plugins[pluginKey];
00046   QString retval;
00047   if (pmd)
00048     {
00049       retval = pmd->library();
00050     }
00051   return retval;
00052 }
00053 
00054 QgsPluginMetadata *QgsPluginRegistry::pluginMetadata(QString name)
00055 {
00056   return plugins[name];
00057 }
00058 
00059 QgisPlugin *QgsPluginRegistry::plugin(QString name)
00060 {
00061   QgsPluginMetadata *pmd = plugins[name];
00062   QgisPlugin *retval = 0;
00063   if (pmd)
00064     {
00065       retval = pmd->plugin();
00066     }
00067   return retval;
00068 }
00069 
00070 bool QgsPluginRegistry::isPythonPlugin(QString name)
00071 {
00072   QgsPluginMetadata* pmd = plugins[name];
00073   if (pmd)
00074     return pmd->isPython();
00075   else
00076     return false;
00077 }
00078 
00079 void QgsPluginRegistry::addPlugin(QString library, QString name, QgisPlugin * plugin)
00080 {
00081   plugins[name] = new QgsPluginMetadata(library, name, plugin);
00082 }
00083 
00084 
00085 void QgsPluginRegistry::addPythonPlugin(QString packageName, QString pluginName)
00086 {
00087   plugins[pluginName] = new QgsPluginMetadata(packageName, pluginName, NULL, true); // true == python plugin
00088 }
00089 
00090 void QgsPluginRegistry::removePlugin(QString name)
00091 {
00092   plugins.erase(name);
00093 }

Generated on Mon Apr 28 15:07:53 2008 for openModellerDesktop by  doxygen 1.4.1-20050210