984 changes: 984 additions & 0 deletions src/datasources/hdf5/hdf5.cpp

Large diffs are not rendered by default.

151 changes: 151 additions & 0 deletions src/datasources/hdf5/hdf5.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
/***************************************************************************
* *
* copyright : (C) 2007 The University of Toronto *
* netterfield@astro.utoronto.ca *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/


#ifndef HDF5_H
#define HDF5_H

#include <datasource.h>
#include <dataplugin.h>

#include <QFileInfo>
#include <hdf5/serial/H5Cpp.h>
#include <exception>

#include "debug.h"

class DataInterfaceHDF5Vector;
class DataInterfaceHDF5Scalar;
class DataInterfaceHDF5Matrix;
class DataInterfaceHDF5String;

class HDF5Source : public Kst::DataSource {
Q_OBJECT

public:
HDF5Source(Kst::ObjectStore *store, QSettings *cfg, const QString& filename, const QString& type, const QDomElement& e);

//HDF5Source(HDF5Source& s);

~HDF5Source();

friend class DataInterfaceHDF5Vector;
friend class DataInterfaceHDF5Matrix;
friend class DataInterfaceHDF5Scalar;
friend class DataInterfaceHDF5String;

bool init();
virtual void reset();

Kst::Object::UpdateType internalDataSourceUpdate();

QString fileType() const;

void save(QXmlStreamWriter &streamWriter);

class Config;

unsigned samplesPerFrame(const QString& field);

unsigned frameCount(const QString& field);

int readField(double *v, const QString& field, int start, int numFrames);

int readScalar(double& s, const QString& field);

int readMatrix(Kst::DataMatrix::ReadInfo& m, const QString& field);

int readString(QString &data, const QString& field);

private:
mutable Config *_config;
H5::H5File* _hdfFile;

static herr_t visitFunc(hid_t id, const char* name, const H5L_info_t* info, void* opData);
static herr_t attrIterFunc(hid_t id, const char* name, const H5A_info_t* info, void* opData);
QString _directoryName;

DataInterfaceHDF5Vector* iv;
DataInterfaceHDF5Scalar* ix;
DataInterfaceHDF5Matrix* im;
DataInterfaceHDF5String* is;

QStringList _scalarList;
QStringList _vectorList;
QStringList _matrixList;
QStringList _stringList;
QStringList _fieldList;
QStringList _indexList;
QStringList _mpfList; //List of dim-3 objects that are a matrix per frame (mpf)
//Not implemented yet but could be

bool _resetNeeded;

QVector<int> lengths;

};


class HDF5Plugin : public QObject, public Kst::DataSourcePluginInterface {
Q_OBJECT
Q_INTERFACES(Kst::DataSourcePluginInterface)
Q_PLUGIN_METADATA(IID "com.kst.DataSourcePluginInterface/2.0")
public:
virtual ~HDF5Plugin() {}

virtual QString pluginName() const;
virtual QString pluginDescription() const;

virtual bool hasConfigWidget() const { return false; }

virtual Kst::DataSource *create(Kst::ObjectStore *store,
QSettings *cfg,
const QString &filename,
const QString &type,
const QDomElement &element) const;

virtual QStringList matrixList(QSettings *cfg,
const QString& filename,
const QString& type,
QString *typeSuggestion,
bool *complete) const;

virtual QStringList fieldList(QSettings *cfg,
const QString& filename,
const QString& type,
QString *typeSuggestion,
bool *complete) const;

virtual QStringList scalarList(QSettings *cfg,
const QString& filename,
const QString& type,
QString *typeSuggestion,
bool *complete) const;

virtual QStringList stringList(QSettings *cfg,
const QString& filename,
const QString& type,
QString *typeSuggestion,
bool *complete) const;

virtual int understands(QSettings *cfg, const QString& filename) const;

virtual bool supportsTime(QSettings *cfg, const QString& filename) const;

virtual QStringList provides() const;

virtual Kst::DataSourceConfigWidget *configWidget(QSettings *cfg, const QString& filename) const;
};


#endif
// vim: ts=2 sw=2 et
14 changes: 14 additions & 0 deletions src/datasources/hdf5/hdf5.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
TOPOUT_REL=../../..
include($$PWD/$$TOPOUT_REL/kst.pri)
include($$PWD/../../../datasourceplugin.pri)

TARGET = $$kstlib(kst2data_hdf5)
INCLUDEPATH += $$OUTPUT_DIR/src/datasources/hdf5/tmp

LIBS += -lhdf5_cpp -lhdf5_hl_cpp -lhdf5 -lhdf5_hl

SOURCES += \
hdf5.cpp

HEADERS += \
hdf5.h
45 changes: 45 additions & 0 deletions src/datasources/hdf5/kstdata_hdf5.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
[Desktop Entry]
Type=Service
ServiceTypes=Kst Data Source
X-KDE-ModuleType=Plugin
X-KDE-Library=hdf5
X-Kst-Plugin-Author=The University of Toronto
Name=HDF5 Reader
Name[bs]=Uzorak čitača datoteke
Name[ca]=Plantilla de lector de fitxer
Name[ca@valencia]=Plantilla de lector de fitxer
Name[de]=Vorlage für Dateileser
Name[el]=Πρότυπο προγραμμάτων ανάγνωσης αρχείων
Name[en_GB]=File Reader Template
Name[es]=Plantilla del lector de archivos
Name[fr]=Modèle de lecteur de fichier
Name[gl]=Modelo de lector de ficheiros
Name[it]=Modello lettore di file
Name[nb]=Filleser-mal
Name[nl]=File Reader Template
Name[pl]=Szablon czytnika plików
Name[pt]=Modelo de Leitor de Ficheiros
Name[pt_BR]=Modelo de leitor de arquivos
Name[sk]=Šablóna čítača súborov
Name[sv]=Mall för filläsare
Name[uk]=Шаблон засобу для читання файлів
Name[x-test]=xxFile Reader Templatexx
Comment=Plugin that reads HDF5 files
Comment[bs]=Uzorak koda za dodatak čitača datoteke.
Comment[ca]=Plantilla de codi per un connector de lector de fitxer.
Comment[ca@valencia]=Plantilla de codi per un connector de lector de fitxer.
Comment[de]=Quelltext-Vorlage für Dateileser-Module
Comment[el]=Πρότυπο κώδικα για πρόσθετα ανάγνωσης αρχείων.
Comment[en_GB]=Code template for a file reader plugin.
Comment[es]=Plantilla de código para un complemento del lector de archivos.
Comment[fr]=Modèle de code pour un module de lecture de fichiers.
Comment[gl]=Modelo de código para un complemento de lector de ficheiros.
Comment[it]=Modello codice per un'estensione del lettore file.
Comment[nb]=Kodemal for et tillegg som leser filer.
Comment[nl]=Sjabloon voor code voor een plugin voor het lezen van bestanden.
Comment[pl]=Szablon kodu dla wtyczki czytnika plików.
Comment[pt]=Um modelo de código para um 'plugin' de leitura de ficheiros.
Comment[pt_BR]=Modelo de código para um plugin de leitura de arquivos.
Comment[sv]=Kodmall för ett insticksprogram för filläsning.
Comment[uk]=Шаблон коду додатка для читання файлів.
Comment[x-test]=xxCode template for a file reader plugin.xx