File indexing completed on 2024-12-22 04:17:13
0001 /*************************************************************************** 0002 dirfile.h - data source plugin for dirfiles 0003 ------------------- 0004 begin : Tue Oct 21 2003 0005 copyright : (C) 2003 The University of Toronto 0006 email : netterfield@astro.utoronto.ca 0007 ***************************************************************************/ 0008 0009 /*************************************************************************** 0010 * * 0011 * This program is free software; you can redistribute it and/or modify * 0012 * it under the terms of the GNU General Public License as published by * 0013 * the Free Software Foundation; either version 2 of the License, or * 0014 * (at your option) any later version. * 0015 * * 0016 ***************************************************************************/ 0017 0018 #ifndef DIRFILE_H 0019 #define DIRFILE_H 0020 0021 #include <datasource.h> 0022 #include <dataplugin.h> 0023 #include <getdata/dirfile.h> 0024 0025 using namespace GetData; 0026 0027 class QFileSystemWatcher; 0028 class DataInterfaceDirFileVector; 0029 class DataInterfaceDirFileScalar; 0030 class DataInterfaceDirFileString; 0031 0032 class DirFileSource : public Kst::DataSource { 0033 Q_OBJECT 0034 0035 public: 0036 DirFileSource(Kst::ObjectStore *store, QSettings *cfg, const QString& filename, const QString& type, const QDomElement& e); 0037 0038 ~DirFileSource(); 0039 0040 bool init(); 0041 0042 virtual UpdateType internalDataSourceUpdate(); 0043 0044 int readField(double *v, const QString &field, int s, int n); 0045 0046 // int writeField(const double *v, const QString &field, int s, int n); 0047 0048 int samplesPerFrame(const QString &field); 0049 0050 int frameCount(const QString& field = QString()) const; 0051 0052 QString fileType() const; 0053 0054 void save(QXmlStreamWriter &streamWriter); 0055 0056 bool isEmpty() const; 0057 0058 virtual void reset(); 0059 0060 class Config; 0061 0062 int readScalar(double &S, const QString& scalar); 0063 0064 int readString(QString &S, const QString& string); 0065 int readSindir(QString &S, const QString& string, int frame); 0066 0067 virtual QStringList fieldScalars(const QString& field); 0068 0069 virtual int readFieldScalars(QList<double> &v, const QString& field, bool init); 0070 0071 virtual QStringList fieldStrings(const QString& field); 0072 0073 virtual int readFieldStrings(QStringList &v, const QString& field, bool init); 0074 0075 virtual const QString& typeString() const; 0076 //static const QString staticTypeString; 0077 //static const QString staticTypeTag; 0078 0079 /** return true if <field> is an indexable list of strings */ 0080 virtual bool isStringStream(QString field); 0081 0082 0083 private: 0084 QString _directoryName; 0085 Dirfile *_dirfile; 0086 0087 QStringList _scalarList; 0088 QStringList _stringList; 0089 QStringList _sindirList; // string stream 0090 QStringList _fieldList; 0091 0092 int _frameCount; 0093 mutable Config *_config; 0094 0095 DataInterfaceDirFileVector* iv; 0096 DataInterfaceDirFileScalar* ix; 0097 DataInterfaceDirFileString* is; 0098 0099 friend class DataInterfaceDirFileVector; 0100 friend class DataInterfaceDirFileScalar; 0101 friend class DataInterfaceDirFileString; 0102 bool _resetNeeded; 0103 }; 0104 0105 0106 class DirFilePlugin : public QObject, public Kst::DataSourcePluginInterface { 0107 Q_OBJECT 0108 Q_INTERFACES(Kst::DataSourcePluginInterface) 0109 Q_PLUGIN_METADATA(IID "com.kst.DataSourcePluginInterface/2.0") 0110 public: 0111 virtual ~DirFilePlugin() {} 0112 0113 virtual QString pluginName() const; 0114 virtual QString pluginDescription() const; 0115 0116 virtual bool hasConfigWidget() const { return false; } 0117 0118 virtual Kst::DataSource *create(Kst::ObjectStore *store, 0119 QSettings *cfg, 0120 const QString &filename, 0121 const QString &type, 0122 const QDomElement &element) const; 0123 0124 virtual QStringList matrixList(QSettings *cfg, 0125 const QString& filename, 0126 const QString& type, 0127 QString *typeSuggestion, 0128 bool *complete) const; 0129 0130 virtual QStringList fieldList(QSettings *cfg, 0131 const QString& filename, 0132 const QString& type, 0133 QString *typeSuggestion, 0134 bool *complete) const; 0135 0136 virtual QStringList scalarList(QSettings *cfg, 0137 const QString& filename, 0138 const QString& type, 0139 QString *typeSuggestion, 0140 bool *complete) const; 0141 0142 virtual QStringList stringList(QSettings *cfg, 0143 const QString& filename, 0144 const QString& type, 0145 QString *typeSuggestion, 0146 bool *complete) const; 0147 0148 virtual int understands(QSettings *cfg, const QString& filename) const; 0149 0150 static QString getDirectory(QString filepath); 0151 0152 virtual bool supportsTime(QSettings *cfg, const QString& filename) const; 0153 0154 virtual QStringList provides() const; 0155 0156 virtual Kst::DataSourceConfigWidget *configWidget(QSettings *cfg, const QString& filename) const; 0157 }; 0158 0159 0160 #endif 0161 // vim: ts=2 sw=2 et