[Kst] branches/work/kst/portto4/kst/src/datasources/dirfilesource

Barth Netterfield netterfield at astro.utoronto.ca
Wed Apr 20 15:15:31 CEST 2011


SVN commit 1228580 by netterfield:

dirfile data sources were not exporting data vectors and data scalars.
Now they are.



 M  +69 -1     dirfilesource.cpp  
 M  +6 -1      dirfilesource.h  


--- branches/work/kst/portto4/kst/src/datasources/dirfilesource/dirfilesource.cpp #1228579:1228580
@@ -46,8 +46,74 @@
     }
 };
 
+//
+// Scalar Interface
+//
+class DataInterfaceDirFileScalar : public DataSource::DataInterface<DataScalar>
+{
+public:
+  DataInterfaceDirFileScalar(DirFileSource& d) : dir(d) {}
 
+  // read one element
+  int read(const QString&, DataScalar::ReadInfo&);
+
+  // named elements
+  QStringList list() const { return dir._scalarList; }
+  bool isListComplete() const { return true; }
+  bool isValid(const QString& field) const { return dir._scalarList.contains( field ); }
+
+  // T specific: not used for scalars
+  const DataScalar::DataInfo dataInfo(const QString&) const { return DataScalar::DataInfo(); }
+  void setDataInfo(const QString&, const DataScalar::DataInfo&) {}
+
+  // meta data
+  QMap<QString, double> metaScalars(const QString&) { return QMap<QString, double>(); }
+  QMap<QString, QString> metaStrings(const QString&) { return QMap<QString, QString>(); }
+
+
+  DirFileSource& dir;
+};
+
+int DataInterfaceDirFileScalar::read(const QString& field, DataScalar::ReadInfo& p)
+{
+  return dir.readScalar(*p.value, field);
+}
+
 //
+// String Interface
+//
+class DataInterfaceDirFileString : public DataSource::DataInterface<DataString>
+{
+public:
+  DataInterfaceDirFileString(DirFileSource& d) : dir(d) {}
+
+  // read one element
+  int read(const QString&, DataString::ReadInfo&);
+
+  // named elements
+  QStringList list() const { return dir._stringList; }
+  bool isListComplete() const { return true; }
+  bool isValid(const QString& field) const { return dir._stringList.contains( field ); }
+
+  // T specific: not used for Strings
+  const DataString::DataInfo dataInfo(const QString&) const { return DataString::DataInfo(); }
+  void setDataInfo(const QString&, const DataString::DataInfo&) {}
+
+  // meta data
+  QMap<QString, double> metaScalars(const QString&) { return QMap<QString, double>(); }
+  QMap<QString, QString> metaStrings(const QString&) { return QMap<QString, QString>(); }
+
+
+  DirFileSource& dir;
+};
+
+int DataInterfaceDirFileString::read(const QString& field, DataString::ReadInfo& p)
+{
+  return dir.readString(*p.value, field);
+}
+
+
+//
 // Vector interface
 //
 
@@ -126,9 +192,11 @@
 
 DirFileSource::DirFileSource(Kst::ObjectStore *store, QSettings *cfg, const QString& filename, const QString& type, const QDomElement& e) :
     Kst::DataSource(store, cfg, filename, type), _config(0L),
-    iv(new DataInterfaceDirFileVector(*this))
+    iv(new DataInterfaceDirFileVector(*this)), ix(new DataInterfaceDirFileScalar(*this)), is(new DataInterfaceDirFileString(*this))
 {
   setInterface(iv);
+  setInterface(ix);
+  setInterface(is);
 
   setUpdateType(None);
 
--- branches/work/kst/portto4/kst/src/datasources/dirfilesource/dirfilesource.h #1228579:1228580
@@ -26,6 +26,8 @@
 
 class QFileSystemWatcher;
 class DataInterfaceDirFileVector;
+class DataInterfaceDirFileScalar;
+class DataInterfaceDirFileString;
 
 class DirFileSource : public Kst::DataSource {
   Q_OBJECT
@@ -87,9 +89,12 @@
     mutable Config *_config;
 
     DataInterfaceDirFileVector* iv;
+    DataInterfaceDirFileScalar* ix;
+    DataInterfaceDirFileString* is;
 
-    // TODO remove
     friend class DataInterfaceDirFileVector;
+    friend class DataInterfaceDirFileScalar;
+    friend class DataInterfaceDirFileString;
 };
 
 


More information about the Kst mailing list