File indexing completed on 2025-01-05 04:12:07

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 DATAPLUGIN_H
0014 #define DATAPLUGIN_H
0015 
0016 #include <QtPlugin>
0017 #include <QSettings>
0018 #include <QDomElement>
0019 
0020 #include "sharedptr.h"
0021 #include "datasource.h"
0022 
0023 #ifndef QT5
0024 #define Q_PLUGIN_METADATA(x)
0025 #endif
0026 
0027 namespace Kst {
0028 
0029 class ObjectStore;
0030 class DataSource;
0031 class DataSourceConfigWidget;
0032 
0033 
0034 KSTCORE_EXPORT QStringList pluginSearchPaths();
0035 
0036 class PluginInterface : public Shared {
0037   public:
0038     PluginInterface() {}
0039 
0040     virtual ~PluginInterface() {}
0041 
0042     virtual QString pluginName() const { return QString(); }
0043     virtual QString pluginDescription() const { return QString(); }
0044 
0045     virtual bool hasConfigWidget() const { return false; }
0046 };
0047 
0048 
0049 class DataSourcePluginInterface : public PluginInterface {
0050   public:
0051     virtual ~DataSourcePluginInterface() {}
0052 
0053     virtual DataSource *create(ObjectStore *store,
0054                             QSettings *cfg,
0055                                   const QString &filename,
0056                                   const QString &type,
0057                                   const QDomElement &element) const = 0;
0058 
0059     virtual QStringList matrixList(QSettings *cfg,
0060                                   const QString& filename,
0061                                   const QString& type,
0062                                   QString *typeSuggestion,
0063                                   bool *complete) const = 0;
0064 
0065     virtual QStringList scalarList(QSettings *cfg,
0066                                   const QString& filename,
0067                                   const QString& type,
0068                                   QString *typeSuggestion,
0069                                   bool *complete) const = 0;
0070 
0071     virtual QStringList stringList(QSettings *cfg,
0072                                   const QString& filename,
0073                                   const QString& type,
0074                                   QString *typeSuggestion,
0075                                   bool *complete) const = 0;
0076 
0077     virtual QStringList fieldList(QSettings *cfg,
0078                                   const QString& filename,
0079                                   const QString& type,
0080                                   QString *typeSuggestion,
0081                                   bool *complete) const = 0;
0082 
0083     virtual int understands(QSettings *cfg, const QString& filename) const = 0;
0084 
0085     virtual bool supportsTime(QSettings *cfg, const QString& filename) const = 0;
0086 
0087     virtual QStringList provides() const = 0;
0088 
0089     bool provides(const QString& type) const { return provides().contains(type); }
0090 
0091     virtual DataSourceConfigWidget *configWidget(QSettings *cfg, const QString& filename) const = 0;
0092 };
0093 
0094 
0095 }
0096 
0097 
0098 Q_DECLARE_INTERFACE(Kst::PluginInterface, "com.kst.PluginInterface/2.0")
0099 Q_DECLARE_INTERFACE(Kst::DataSourcePluginInterface, "com.kst.DataSourcePluginInterface/2.0")
0100 
0101 
0102 #endif