File indexing completed on 2024-12-22 04:17:19
0001 /*************************************************************************** 0002 * * 0003 * copyright : (C) 2007 The University of Toronto * 0004 * netterfield@astro.utoronto.ca * 0005 * * 0006 * This program is free software; you can redistribute it and/or modify * 0007 * it under the terms of the GNU General Public License as published by * 0008 * the Free Software Foundation; either version 2 of the License, or * 0009 * (at your option) any later version. * 0010 * * 0011 ***************************************************************************/ 0012 0013 #ifndef KST_DATA_SOURCE_PLUGIN_MANAGER_H 0014 #define KST_DATA_SOURCE_PLUGIN_MANAGER_H 0015 0016 0017 #include "dataplugin.h" 0018 #include "sharedptr.h" 0019 #include "datasource.h" 0020 0021 #include <QSettings> 0022 #include <QMap> 0023 0024 0025 namespace Kst { 0026 0027 class ObjectStore; 0028 0029 0030 0031 class KSTCORE_EXPORT DataSourcePluginManager 0032 { 0033 public: 0034 0035 static const QMap<QString, QString> urlMap(); 0036 0037 static void init(); 0038 static void cleanupForExit(); 0039 static void initPlugins(); 0040 0041 /** Returns a list of plugins found on the system. */ 0042 static QStringList pluginList(); 0043 0044 static QString pluginFileName(const QString& pluginName); 0045 0046 static SharedPtr<DataSource> loadSource(ObjectStore *store, const QString& filename, const QString& type = QString()); 0047 //static SharedPtr<DataSource> loadSource(ObjectStore *store, QDomElement& e, bool updatesDisabled = false); 0048 static SharedPtr<DataSource> findOrLoadSource(ObjectStore *store, const QString& filename, bool updatesDisabled = false); 0049 static bool validSource(const QString& filename); 0050 0051 static bool sourceHasConfigWidget(const QString& filename, const QString& type = QString()); 0052 static DataSourceConfigWidget *configWidgetForSource(const QString& filename, const QString& type = QString()); 0053 0054 static bool pluginHasConfigWidget(const QString& plugin); 0055 static DataSourceConfigWidget *configWidgetForPlugin(const QString& plugin); 0056 0057 //static QStringList matrixListForSource(const QString& filename, const QString& type = QString(), QString *outType = 0L, bool *complete = 0L); 0058 static QStringList scalarListForSource(const QString& filename, const QString& type = QString(), QString *outType = 0L, bool *complete = 0L); 0059 static QStringList stringListForSource(const QString& filename, const QString& type = QString(), QString *outType = 0L, bool *complete = 0L); 0060 static QSettings& settingsObject(); 0061 0062 0063 private: 0064 static QMap<QString,QString> url_map; 0065 static QString obtainFile(const QString& source); 0066 0067 struct PluginSortContainer { 0068 SharedPtr<DataSourcePluginInterface> plugin; 0069 int match; 0070 int operator<(const PluginSortContainer& x) const; 0071 int operator==(const PluginSortContainer& x) const; 0072 }; 0073 static QList<PluginSortContainer> bestPluginsForSource(const QString& filename, const QString& type); 0074 static DataSourcePtr findPluginFor(ObjectStore *store, const QString& filename, const QString& type, const QDomElement& e = QDomElement()); 0075 }; 0076 0077 } 0078 0079 0080 #endif