[Kst] branches/work/kst/portto4/kst/src/datasources/dmc
Peter Kümmel
syntheticpp at gmx.net
Mon Jan 10 19:05:35 CET 2011
SVN commit 1213514 by kuemmel:
add vector interface for dmc
M +71 -3 dmcsource.cpp
M +4 -15 dmcsource.h
--- branches/work/kst/portto4/kst/src/datasources/dmc/dmcsource.cpp #1213513:1213514
@@ -28,7 +28,75 @@
using namespace Kst;
+//
+// Vector interface
+//
+
+//-------------------------------------------------------------------------------------------
+class DataInterfaceDmcVector : public DataSource::DataInterface<DataVector>
+{
+public:
+ DataInterfaceDmcVector(DmcSource& s) : src(s) {}
+
+ // read one element
+ int read(const QString&, DataVector::ReadInfo&);
+
+ // named elements
+ QStringList list() const { return src._fieldList; }
+ bool isListComplete() const {
+#warning port/ review
+ return true;
+ }
+ bool isValid(const QString& field) const { return src._fieldList.contains( field ); }
+
+ // T specific
+ const DataVector::DataInfo dataInfo(const QString&) const;
+ void setDataInfo(const QString&, const DataVector::DataInfo&) {}
+
+ // meta data
+ QMap<QString, double> metaScalars(const QString&);
+ QMap<QString, QString> metaStrings(const QString&) { return QMap<QString, QString>(); }
+
+
+ DmcSource& src;
+};
+
+
+//-------------------------------------------------------------------------------------------
+const DataVector::DataInfo DataInterfaceDmcVector::dataInfo(const QString &field) const
+{
+ if (!src._fieldList.contains(field))
+ return DataVector::DataInfo();
+
+ return DataVector::DataInfo(src._numFrames, 1);
+}
+
+
+//-------------------------------------------------------------------------------------------
+ int DataInterfaceDmcVector::read(const QString& field, DataVector::ReadInfo& p)
+{
+ return src.readField(p.data, field, p.startingFrame, p.numberOfFrames);
+}
+
+
+//-------------------------------------------------------------------------------------------
+// TODO FRAMES only in vector?
+QMap<QString, double> DataInterfaceDmcVector::metaScalars(const QString&)
+{
+ QMap<QString, double> m;
+ m["FRAMES"] = src._numFrames;;
+ return m;
+}
+
+
+
+
+
+//
+// DmcSource
+//
+
static QString dmcTypeString = I18N_NOOP("PLANCK DMC I/O");
const QString& DmcSource::typeString() const
@@ -43,9 +111,9 @@
}
-
DmcSource::DmcSource(Kst::ObjectStore *store, QSettings *cfg, const QString& filename, const QString& type, const QDomElement& e) :
- Kst::DataSource(store, cfg, filename, type)
+ Kst::DataSource(store, cfg, filename, type),
+ iv(new DataInterfaceDmcVector(*this))
{
_filename = filename;
@@ -251,7 +319,7 @@
QString DmcSource::fileType() const {
- return "PLANCK DMC I/O";
+ return dmcTypeString;
}
--- branches/work/kst/portto4/kst/src/datasources/dmc/dmcsource.h #1213513:1213514
@@ -69,27 +69,16 @@
private:
QMap<QString, int> _frameCounts;
+ int _numFrames;
- // QMap<QString, QString> _metaData;
-
- // TODO remove friend
- QStringList _scalarList;
QStringList _fieldList;
- QStringList _matrixList;
- QStringList _stringList;
+ DataInterfaceDmcVector* iv;
-
- friend class DataInterfaceDmcScalar;
- friend class DataInterfaceDmcString;
+ // TODO remove friend
friend class DataInterfaceDmcVector;
- friend class DataInterfaceDmcMatrix;
- DataInterfaceDmcScalar* is;
- DataInterfaceDmcString* it;
- DataInterfaceDmcVector* iv;
- DataInterfaceDmcMatrix* im;
- // from old dmc code
+ // from kst1 old dmc code
Kst::SharedPtr<DMC::Object> _dmcObject;
QString _filename;
More information about the Kst
mailing list