CFEL - ASG Software Suite
2.5.0
CASS
|
read and write data to files More...
#include <file_handler.h>
Public Member Functions | |
FileHandler (const QString &filename=QString()) | |
constructor More... | |
result_t::shared_pointer | result (const QString &key, quint64 id=0) |
retrieve an result from the file More... | |
QStringList | resultNames () |
retrieve the list of names that an be displayed from the file More... | |
QString | type () const |
retrieve the type of source More... | |
void | setFilename (const QString &filename) |
set the filename More... | |
Static Public Member Functions | |
static QString | getBaseName (const QString &filename) |
return the basename of the filename More... | |
static bool | isContainerFile (const QString &filename) |
return whether the file is a container file More... | |
static void | saveData (const QString &filename, result_t::shared_pointer data) |
save data to a given file More... | |
static void | createContainer (const QString &filename) |
create the container file More... | |
Private Member Functions | |
QImage | loadImage (const QString &filename) |
read the data from an image file More... | |
void | saveImage (const QString &filename, const QImage &image) |
save image data More... | |
result_t::shared_pointer | loadDataFromHist () |
read the data from a hist file More... | |
void | saveDataToHist (const QString &filename, result_t::shared_pointer data) |
save the data from a hist file More... | |
result_t::shared_pointer | loadDataFromCSV () |
read the data from a CSV file More... | |
void | saveDataToCSV (const QString &filename, result_t::shared_pointer data) |
save the data from a CSV file More... | |
result_t::shared_pointer | loadDataFromH5 (const QString &key="") |
read the data from a hdf5 file More... | |
void | saveDataToH5 (const QString &filename, result_t::shared_pointer data, const QString &mode="w") |
write the data to a hdf5 file More... | |
result_t::shared_pointer | loadDataFromCBF () |
read the data from a cbf file More... | |
void | saveDataToCBF (const QString &filename, result_t::shared_pointer data) |
save the data to a cbf file More... | |
Private Attributes | |
QString | _filename |
the filename of the file to work on More... | |
Additional Inherited Members | |
![]() | |
typedef cass::Result< float > | result_t |
define the result type More... | |
read and write data to files
Definition at line 30 of file file_handler.h.
constructor
filename | the filename that the handler handels |
Definition at line 40 of file file_handler.cpp.
|
static |
create the container file
filename | The filename to save the data to |
Definition at line 95 of file file_handler.cpp.
References QFileInfo::exists().
Referenced by jocassview::JoCASSViewer::saveFile().
return the basename of the filename
filename | the filename whos basename should be extracted |
Definition at line 46 of file file_handler.cpp.
References QFileInfo::baseName(), and QFileInfo::exists().
Referenced by resultNames().
|
static |
return whether the file is a container file
filename | the name of the file |
Definition at line 55 of file file_handler.cpp.
References QFileInfo::suffix(), and QString::toUpper().
Referenced by jocassview::JoCASSViewer::autoSave(), resultNames(), jocassview::OneDViewer::saveData(), and jocassview::JoCASSViewer::saveFile().
|
private |
read the data from a cbf file
try to retrieve the center from the header
Definition at line 439 of file file_handler.cpp.
References _filename, QString::contains(), QString::fromStdString(), QString::isNull(), cass::CBF::read(), QTextStream::readLine(), QString::remove(), result(), QString::split(), and QString::toDouble().
Referenced by result().
|
private |
read the data from a CSV file
Definition at line 213 of file file_handler.cpp.
References QMessageBox::information(), and QObject::tr().
Referenced by result().
|
private |
read the data from a hdf5 file
key | in case of a hdf5 file the key to the requested data. Default is "" |
Definition at line 427 of file file_handler.cpp.
Referenced by result().
|
private |
read the data from a hist file
use a file serializer to deserialize the data in the file to a hist object and get the dimension from the object.
Definition at line 193 of file file_handler.cpp.
References _filename, and result().
Referenced by result().
read the data from an image file
filename | the name of the file that contains the image data |
Definition at line 178 of file file_handler.cpp.
References QImageReader::canRead().
|
virtual |
retrieve an result from the file
key | the key of the result |
id | the eventid of the result |
Implements jocassview::DataSource.
Definition at line 106 of file file_handler.cpp.
References _filename, QMessageBox::critical(), QFileInfo::exists(), loadDataFromCBF(), loadDataFromCSV(), loadDataFromH5(), loadDataFromHist(), QFileInfo::suffix(), QString::toUpper(), and QObject::tr().
Referenced by loadDataFromCBF(), and loadDataFromHist().
|
virtual |
retrieve the list of names that an be displayed from the file
Implements jocassview::DataSource.
Definition at line 141 of file file_handler.cpp.
References _filename, QMessageBox::critical(), QFileInfo::exists(), QString::fromStdString(), getBaseName(), isContainerFile(), and QObject::tr().
|
static |
save data to a given file
filename | The filename to save the data to |
data | the data to save |
Definition at line 67 of file file_handler.cpp.
References QFileInfo::exists(), saveDataToCBF(), saveDataToCSV(), saveDataToH5(), saveDataToHist(), QFileInfo::suffix(), and QString::toUpper().
Referenced by jocassview::ZeroDViewer::saveData(), jocassview::TwoDViewer::saveData(), and jocassview::OneDViewer::saveData().
|
private |
save the data to a cbf file
filename | the name of the file |
data | pointer to the data |
Definition at line 487 of file file_handler.cpp.
References QString::begin(), and cass::CBF::write().
Referenced by saveData().
|
private |
save the data from a CSV file
filename | the name of the file |
data | pointer to the data to save |
Definition at line 219 of file file_handler.cpp.
References QFile::open(), QTextStream::pos(), cass::Result< float >::xAxis, and cass::Result< float >::yAxis.
Referenced by saveData().
|
private |
write the data to a hdf5 file
The key under which name the data is saved in the file is given provided as part of the data.
filename | the name of the file |
data | pointer to the data |
mode | The mode in which the file will be opened. Default is "w". |
Definition at line 432 of file file_handler.cpp.
Referenced by saveData().
|
private |
save the data from a hist file
filename | the name of the file |
data | pointer to the data to save |
Definition at line 206 of file file_handler.cpp.
References cass::SerializerWriteFile::close().
Referenced by saveData().
save image data
filename | the name of the file to save the image in |
image | the image to save |
Definition at line 186 of file file_handler.cpp.
References QMessageBox::critical(), QImage::save(), and QObject::tr().
void FileHandler::setFilename | ( | const QString & | filename | ) |
set the filename
filename | the filename to work on |
Definition at line 173 of file file_handler.cpp.
References _filename.
|
virtual |
retrieve the type of source
Implements jocassview::DataSource.
Definition at line 168 of file file_handler.cpp.
|
private |
the filename of the file to work on
Definition at line 167 of file file_handler.h.
Referenced by loadDataFromCBF(), loadDataFromHist(), result(), resultNames(), and setFilename().