Field3D
Hdf5Util.h File Reference

Contains various utility functions for Hdf5. More...

#include <string>
#include <exception>
#include <vector>
#include <boost/lexical_cast.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/recursive_mutex.hpp>
#include <hdf5.h>
#include "Exception.h"
#include "Traits.h"
#include "Field.h"
#include "ns.h"

Go to the source code of this file.

Classes

class  Hdf5Util::H5Base
 Base class for all scoped Hdf5 util classes. More...
 
class  Hdf5Util::H5ScopedAget_space
 Scoped object - opens an attribute data space on creation and closes it on destruction. More...
 
class  Hdf5Util::H5ScopedAget_type
 Scoped object - opens an attribute data type on creation and closes it on destruction. More...
 
class  Hdf5Util::H5ScopedAopen
 Scoped object - Opens attribute by name and closes it on destruction. More...
 
class  Hdf5Util::H5ScopedAopenIdx
 Scoped object - Opens attribute by index and closes it on destruction. More...
 
class  Hdf5Util::H5ScopedDcreate
 Scoped object - creates a dataset on creation and closes it on destruction. More...
 
class  Hdf5Util::H5ScopedDget_space
 Scoped object - opens a dataset on creation and closes it on destruction. More...
 
class  Hdf5Util::H5ScopedDget_type
 Scoped object - opens a dataset on creation and closes it on destruction. More...
 
class  Hdf5Util::H5ScopedDopen
 Scoped object - opens a dataset on creation and closes it on destruction. More...
 
class  Hdf5Util::H5ScopedGcreate
 Scoped object - creates a group on creation and closes it on destruction. More...
 
class  Hdf5Util::H5ScopedGopen
 Scoped object - opens a group on creation and closes it on destruction. More...
 
class  Hdf5Util::H5ScopedScreate
 Scoped object - creates a dataspace on creation and closes it on destruction. More...
 
class  Hdf5Util::H5ScopedTget_native_type
 Scoped object - opens an native type id on creation and closes it on destruction. More...
 

Namespaces

 Hdf5Util
 Contains utility functions and classes for Hdf5 files.
 

Typedefs

typedef boost::recursive_mutex::scoped_lock GlobalLock
 

Functions

FIELD3D_API bool Hdf5Util::checkHdf5Gzip ()
 Checks whether gzip is available in the current hdf5 library. More...
 
Read/write simple data to hdf5 location
template<typename T >
void Hdf5Util::readSimpleData (hid_t location, const std::string &name, std::vector< T > &data)
 Reads a simple linear data set from the given location. More...
 
template<typename T >
void Hdf5Util::writeSimpleData (hid_t location, const std::string &name, const std::vector< T > &data)
 Writes a simple linear data set to the given location. More...
 
Attribute reading
FIELD3D_API bool Hdf5Util::readAttribute (hid_t location, const std::string &attrName, std::string &value)
 Reads a string attribute. More...
 
FIELD3D_API bool Hdf5Util::readAttribute (hid_t location, const std::string &attrName, std::vector< unsigned int > &attrSize, double &value)
 Reads a double attribute of arbitrary size and rank. More...
 
FIELD3D_API bool Hdf5Util::readAttribute (hid_t location, const std::string &attrName, std::vector< unsigned int > &attrSize, float &value)
 Reads a float attribute of arbitrary size and rank. More...
 
FIELD3D_API bool Hdf5Util::readAttribute (hid_t location, const std::string &attrName, std::vector< unsigned int > &attrSize, int &value)
 Reads a int attribute of arbitrary size and rank. More...
 
FIELD3D_API bool Hdf5Util::readAttribute (hid_t location, const std::string &attrName, unsigned int attrSize, double &value)
 Reads a double attribute of arbitrary size. More...
 
FIELD3D_API bool Hdf5Util::readAttribute (hid_t location, const std::string &attrName, unsigned int attrSize, float &value)
 Reads a float attribute of arbitrary size. More...
 
FIELD3D_API bool Hdf5Util::readAttribute (hid_t location, const std::string &attrName, unsigned int attrSize, int &value)
 Reads an int attribute of arbitrary size. More...
 
Attribute writing
FIELD3D_API bool Hdf5Util::writeAttribute (hid_t location, const std::string &attrName, const std::string &value)
 Writes a string attribute. More...
 
FIELD3D_API bool Hdf5Util::writeAttribute (hid_t location, const std::string &attrName, std::vector< unsigned int > &attrSize, const double &value)
 Writes a double attribute of arbitrary size and rank. More...
 
FIELD3D_API bool Hdf5Util::writeAttribute (hid_t location, const std::string &attrName, std::vector< unsigned int > &attrSize, const float &value)
 Writes a float attribute of arbitrary size and rank. More...
 
FIELD3D_API bool Hdf5Util::writeAttribute (hid_t location, const std::string &attrName, std::vector< unsigned int > &attrSize, const int &value)
 Writes a float attribute of arbitrary size and rank. More...
 
FIELD3D_API bool Hdf5Util::writeAttribute (hid_t location, const std::string &attrName, unsigned int attrSize, const double &value)
 Writes a double attribute of arbitrary size. More...
 
FIELD3D_API bool Hdf5Util::writeAttribute (hid_t location, const std::string &attrName, unsigned int attrSize, const float &value)
 Writes a float attribute of arbitrary size. More...
 
FIELD3D_API bool Hdf5Util::writeAttribute (hid_t location, const std::string &attrName, unsigned int attrSize, const int &value)
 Writes an int attribute of arbitrary size. More...
 
Read/write simple data to hdf5 location
template<typename T >
void Hdf5Util::writeSimpleData (hid_t location, const std::string &name, const std::vector< T > &data)
 Writes a simple linear data set to the given location. More...
 
template<typename T >
void Hdf5Util::readSimpleData (hid_t location, const std::string &name, std::vector< T > &data)
 Reads a simple linear data set from the given location. More...
 
Attribute reading
FIELD3D_API bool Hdf5Util::readAttribute (hid_t location, const std::string &attrName, std::string &value)
 Reads a string attribute. More...
 
FIELD3D_API bool Hdf5Util::readAttribute (hid_t location, const std::string &attrName, unsigned int attrSize, int &value)
 Reads an int attribute of arbitrary size. More...
 
FIELD3D_API bool Hdf5Util::readAttribute (hid_t location, const std::string &attrName, unsigned int attrSize, float &value)
 Reads a float attribute of arbitrary size. More...
 
FIELD3D_API bool Hdf5Util::readAttribute (hid_t location, const std::string &attrName, unsigned int attrSize, double &value)
 Reads a double attribute of arbitrary size. More...
 
FIELD3D_API bool Hdf5Util::readAttribute (hid_t location, const std::string &attrName, std::vector< unsigned int > &attrSize, int &value)
 Reads a int attribute of arbitrary size and rank. More...
 
FIELD3D_API bool Hdf5Util::readAttribute (hid_t location, const std::string &attrName, std::vector< unsigned int > &attrSize, float &value)
 Reads a float attribute of arbitrary size and rank. More...
 
FIELD3D_API bool Hdf5Util::readAttribute (hid_t location, const std::string &attrName, std::vector< unsigned int > &attrSize, double &value)
 Reads a double attribute of arbitrary size and rank. More...
 
Attribute writing
FIELD3D_API bool Hdf5Util::writeAttribute (hid_t location, const std::string &attrName, const std::string &value)
 Writes a string attribute. More...
 
FIELD3D_API bool Hdf5Util::writeAttribute (hid_t location, const std::string &attrName, unsigned int attrSize, const int &value)
 Writes an int attribute of arbitrary size. More...
 
FIELD3D_API bool Hdf5Util::writeAttribute (hid_t location, const std::string &attrName, unsigned int attrSize, const float &value)
 Writes a float attribute of arbitrary size. More...
 
FIELD3D_API bool Hdf5Util::writeAttribute (hid_t location, const std::string &attrName, unsigned int attrSize, const double &value)
 Writes a double attribute of arbitrary size. More...
 
FIELD3D_API bool Hdf5Util::writeAttribute (hid_t location, const std::string &attrName, std::vector< unsigned int > &attrSize, const int &value)
 Writes a float attribute of arbitrary size and rank. More...
 
FIELD3D_API bool Hdf5Util::writeAttribute (hid_t location, const std::string &attrName, std::vector< unsigned int > &attrSize, const float &value)
 Writes a float attribute of arbitrary size and rank. More...
 
FIELD3D_API bool Hdf5Util::writeAttribute (hid_t location, const std::string &attrName, std::vector< unsigned int > &attrSize, const double &value)
 Writes a double attribute of arbitrary size and rank. More...
 

Variables

FIELD3D_NAMESPACE_OPEN FIELD3D_API boost::recursive_mutex g_hdf5Mutex
 

Detailed Description

Contains various utility functions for Hdf5.

Todo:
Clean up the attribute read/write functions. Make them throw exceptions when failing.

Definition in file Hdf5Util.h.

Typedef Documentation

◆ GlobalLock

typedef boost::recursive_mutex::scoped_lock GlobalLock

Definition at line 78 of file Hdf5Util.h.

Variable Documentation

◆ g_hdf5Mutex

FIELD3D_NAMESPACE_OPEN FIELD3D_API boost::recursive_mutex g_hdf5Mutex

Definition at line 67 of file Hdf5Util.cpp.

Referenced by Hdf5Util::checkHdf5Gzip(), Field3DFileHDF5Base::closeInternal(), Field3DOutputFileHDF5::create(), Hdf5Util::H5ScopedScreate::create(), Field3DOutputFileHDF5::createNewPartition(), Field3DFileHDF5Base::Field3DFileHDF5Base(), Hdf5Util::H5ScopedAget_space::H5ScopedAget_space(), Hdf5Util::H5ScopedAget_type::H5ScopedAget_type(), Hdf5Util::H5ScopedAopen::H5ScopedAopen(), Hdf5Util::H5ScopedAopenIdx::H5ScopedAopenIdx(), Hdf5Util::H5ScopedDcreate::H5ScopedDcreate(), Hdf5Util::H5ScopedGcreate::H5ScopedGcreate(), Hdf5Util::H5ScopedTget_native_type::H5ScopedTget_native_type(), Field3DInputFileHDF5::open(), Hdf5Util::H5ScopedDget_space::open(), Hdf5Util::H5ScopedDget_type::open(), Hdf5Util::H5ScopedGopen::open(), Hdf5Util::H5ScopedDopen::open(), SparseFile::Reference< Data_T >::openFile(), InputFileHDF5::parseLayers(), InputFileHDF5::parsePartitions(), Hdf5Util::readAttribute(), SparseDataReader< Data_T >::readBlock(), SparseDataReader< Data_T >::readBlockList(), Field3DInputFileHDF5::readGroupMembership(), Field3DInputFileHDF5::readLayer(), Field3DInputFileHDF5::readMetadata(), Field3DInputFileHDF5::readPartitionAndLayerInfo(), Field3DInputFileHDF5::readProxyLayer(), Hdf5Util::readSimpleData(), Hdf5Util::writeAttribute(), Field3DOutputFileHDF5::writeGlobalMetadata(), Field3DOutputFileHDF5::writeGroupMembership(), Field3DOutputFileHDF5::writeLayer(), Field3DOutputFileHDF5::writeMapping(), Hdf5Util::writeSimpleData(), Hdf5Util::H5ScopedAget_space::~H5ScopedAget_space(), Hdf5Util::H5ScopedAget_type::~H5ScopedAget_type(), Hdf5Util::H5ScopedAopen::~H5ScopedAopen(), Hdf5Util::H5ScopedAopenIdx::~H5ScopedAopenIdx(), Hdf5Util::H5ScopedDcreate::~H5ScopedDcreate(), Hdf5Util::H5ScopedDget_space::~H5ScopedDget_space(), Hdf5Util::H5ScopedDget_type::~H5ScopedDget_type(), Hdf5Util::H5ScopedDopen::~H5ScopedDopen(), Hdf5Util::H5ScopedGcreate::~H5ScopedGcreate(), Hdf5Util::H5ScopedGopen::~H5ScopedGopen(), Hdf5Util::H5ScopedScreate::~H5ScopedScreate(), and Hdf5Util::H5ScopedTget_native_type::~H5ScopedTget_native_type().