h5cpp  0.5.2
A modern C++ wrapper for the HDF5 C library
hdf5::node::Dataset Class Reference

#include <dataset.hpp>

Inheritance diagram for hdf5::node::Dataset:
Collaboration diagram for hdf5::node::Dataset:

Public Member Functions

 Dataset ()=default
 default constructor More...
 
 Dataset (const Node &node)
 construct More...
 
 Dataset (const Group &base, const Path &path, const datatype::Datatype &type, const dataspace::Dataspace &space=dataspace::Scalar(), const property::LinkCreationList &lcpl=property::LinkCreationList(), const property::DatasetCreationList &dcpl=property::DatasetCreationList(), const property::DatasetAccessList &dapl=property::DatasetAccessList())
 constructor More...
 
dataspace::Dataspace dataspace () const
 get dataspace of dataset More...
 
property::DatasetCreationList creation_list () const
 get the dataset creation property list used for creation More...
 
property::DatasetAccessList access_list () const
 get the dataset access property list for the instance More...
 
datatype::Datatype datatype () const
 get datatype of dataset More...
 
void extent (const Dimensions &dims) const
 set extent of the dataset More...
 
void extent (size_t dim, ssize_t delta_elements) const
 
void resize (const Dimensions &dims) const
 resize the dataset More...
 
void refresh () const
 refresh the dataset (since hdf5 1.10.0) More...
 
template<typename T >
void write (const T &data, const datatype::Datatype &mem_type, const dataspace::Dataspace &mem_space, const dataspace::Dataspace &file_space, const property::DatasetTransferList &dtpl=property::DatasetTransferList::get()) const
 write data to the dataset More...
 
template<typename T >
void write (const T &data, const datatype::Datatype &mem_type, const dataspace::Dataspace &mem_space, const property::DatasetTransferList &dtpl=property::DatasetTransferList::get()) const
 write data to the dataset More...
 
template<typename T >
void read (T &data, const datatype::Datatype &mem_type, const dataspace::Dataspace &mem_space, const dataspace::Dataspace &file_space, const property::DatasetTransferList &dtpl=property::DatasetTransferList::get()) const
 read data from the dataset More...
 
template<typename T >
void read (T &data, const datatype::Datatype &mem_type, const dataspace::Dataspace &mem_space, const property::DatasetTransferList &dtpl=property::DatasetTransferList::get()) const
 
template<typename T >
void read_reshape (T &data, const datatype::Datatype &mem_type, const dataspace::Dataspace &mem_space, const property::DatasetTransferList &dtpl=property::DatasetTransferList::get()) const
 
template<typename T >
void write (const T &data, const property::DatasetTransferList &dtpl=property::DatasetTransferList::get())
 write entire dataset More...
 
template<typename T >
void write (const T &data, const property::DatasetTransferList &dtpl=property::DatasetTransferList::get()) const
 
template<typename T >
void write_reshape (const T &data, const datatype::Datatype &mem_type, const dataspace::Dataspace &mem_space, const property::DatasetTransferList &dtpl=property::DatasetTransferList::get()) const
 write entire dataset More...
 
void write (const char *data, const property::DatasetTransferList &dtpl=property::DatasetTransferList::get())
 write entire dataset More...
 
void write (const char *data, const property::DatasetTransferList &dtpl=property::DatasetTransferList::get()) const
 
template<typename T >
void write_chunk (const T &data, std::vector< unsigned long long > offset, std::uint32_t filter_mask=0, const property::DatasetTransferList &dtpl=property::DatasetTransferList::get())
 write dataset chunk More...
 
template<typename T >
void write_chunk (const T &data, std::vector< unsigned long long > offset, std::uint32_t filter_mask=0, const property::DatasetTransferList &dtpl=property::DatasetTransferList::get()) const
 
template<typename T >
void write_chunk (const T &data, const datatype::Datatype &mem_type, const dataspace::Dataspace &mem_space, std::vector< unsigned long long > &offset, std::uint32_t filter_mask=0, const property::DatasetTransferList &dtpl=property::DatasetTransferList::get()) const
 write dataset chunk More...
 
template<typename T >
std::uint32_t read_chunk (T &data, std::vector< unsigned long long > offset, const property::DatasetTransferList &dtpl=property::DatasetTransferList::get()) const
 read dataset chunk (since hdf5 1.10.2) More...
 
template<typename T >
std::uint32_t read_chunk (T &data, const datatype::Datatype &mem_type, std::vector< unsigned long long > &offset, const property::DatasetTransferList &dtpl=property::DatasetTransferList::get()) const
 read dataset chunk More...
 
unsigned long long chunk_storage_size (std::vector< unsigned long long > offset) const
 read dataset chunk More...
 
template<typename T >
void read (T &data, const property::DatasetTransferList &dtpl=property::DatasetTransferList::get())
 read entire dataset More...
 
template<typename T >
void read (T &data, const property::DatasetTransferList &dtpl=property::DatasetTransferList::get()) const
 
template<typename T >
void write (const T &data, const dataspace::Selection &selection, const property::DatasetTransferList &dtpl=property::DatasetTransferList::get())
 write data to a selection More...
 
template<typename T >
void write (const T &data, const dataspace::Selection &selection, const property::DatasetTransferList &dtpl=property::DatasetTransferList::get()) const
 
template<typename T >
void write_reshape (const T &data, const datatype::Datatype &mem_type, const dataspace::Dataspace &mem_space, const dataspace::Selection &selection, const property::DatasetTransferList &dtpl=property::DatasetTransferList::get()) const
 write data to a selection More...
 
template<typename T >
void read (T &data, const dataspace::Selection &selection, const property::DatasetTransferList &dtpl=property::DatasetTransferList::get())
 reading data from a selection More...
 
template<typename T >
void read (T &data, const dataspace::Selection &selection, const property::DatasetTransferList &dtpl=property::DatasetTransferList::get()) const
 
template<typename T >
void read_reshape (T &data, const datatype::Datatype &mem_type, const dataspace::Dataspace &mem_space, const dataspace::Selection &selection, const property::DatasetTransferList &dtpl=property::DatasetTransferList::get()) const
 reading data from a selection More...
 
template<typename T >
void read (T &data, const datatype::Datatype &memory_type, const dataspace::Dataspace &memory_space, const dataspace::Selection &file_selection, const property::DatasetTransferList &dtpl=property::DatasetTransferList::get()) const
 reading data from a dataset More...
 
filter::ExternalFilters filters () const
 get the dataset external filters for the instance More...
 
- Public Member Functions inherited from hdf5::node::Node
 Node (ObjectHandle &&handle, const Link &link)
 constructor More...
 
 Node ()
 default constructor More...
 
 Node (const Node &)
 copy constructor More...
 
Nodeoperator= (const Node &node)
 copy assignment More...
 
virtual ~Node ()
 destructor More...
 
NodeType type () const
 return the node type More...
 
ObjectId id () const
 get unique ID More...
 
 operator hid_t () const
 
bool is_valid () const
 true if an object is valid More...
 
void close ()
 close the node More...
 
const Linklink () const
 return link to object More...
 

Additional Inherited Members

- Public Attributes inherited from hdf5::node::Node
attribute::AttributeManager attributes
 access to the attribute manager More...
 

Constructor & Destructor Documentation

◆ Dataset() [1/3]

hdf5::node::Dataset::Dataset ( )
default

Use default implementation here. We need this for some STL containers. After default construction the dataset is in an invalid state.

See also
is_valid()

◆ Dataset() [2/3]

hdf5::node::Dataset::Dataset ( const Node node)

Construct a dataset from a node instance.

Exceptions
std::runtime_errorin case that the node is not a dataset
Parameters
nodereference to the original node from which to construct the dataset.

◆ Dataset() [3/3]

hdf5::node::Dataset::Dataset ( const Group base,
const Path path,
const datatype::Datatype type,
const dataspace::Dataspace space = dataspace::Scalar(),
const property::LinkCreationList lcpl = property::LinkCreationList(),
const property::DatasetCreationList dcpl = property::DatasetCreationList(),
const property::DatasetAccessList dapl = property::DatasetAccessList() 
)
Exceptions
std::runtime_errorin case of a failure
Parameters
basethe base object for the dataset creation
paththe path to the new dataset
typeoptional reference to a datatype
spaceoptional reference to a dataspace (default is a scalar one)
lcploptional reference to a link creation property list
dcploptional reference to a dataset creation property list
daploptional reference to a dataset access property list

Member Function Documentation

◆ access_list()

property::DatasetAccessList hdf5::node::Dataset::access_list ( ) const

Returns an instance of the dataset access property list for the dataset.

Exceptions
std::runtime_errorin case of a failure
Returns
instance of DatasetAccessList

◆ chunk_storage_size()

unsigned long long hdf5::node::Dataset::chunk_storage_size ( std::vector< unsigned long long >  offset) const

Read a chunk storage size from a dataset to an instance of T.

Exceptions
std::runtime_errorin case of a failure
Parameters
offsetlogical position of the first element of the chunk in the dataset's dataspace
Returns
the size in bytes for the chunk.

◆ creation_list()

property::DatasetCreationList hdf5::node::Dataset::creation_list ( ) const

Returns an instance of a dataset creation property list with the values used for the creation of the dataset.

Exceptions
std::runtime_errorin case of a failure
Returns
instance of DatasetCreationList

◆ dataspace()

dataspace::Dataspace hdf5::node::Dataset::dataspace ( ) const

Return a new instance of the dataspace describing the dataset.

Exceptions
std::runtime_errorin case of a failure
Returns
new dataspace instance

◆ datatype()

datatype::Datatype hdf5::node::Dataset::datatype ( ) const

Return an instance of the datatype describing the elements stored in the file.

Exceptions
std::runtime_errorin case of a failure
Returns
new instance of datatype

◆ extent() [1/2]

void hdf5::node::Dataset::extent ( const Dimensions dims) const

Allows to change the extent (number of elements along each dimensions) of a dataset. It is important to note that in such a case a previously requested dataspace though remaining a valid object does no longer describe the datasets layout correctly. The number of elements can be increased or decreased within the limits of the dataspace originally used to create the dataset.

Exceptions
std::runtime_errorin case of a failure
Parameters
dimsvector with new number of elements along each dimension
Deprecated:
this method is deprecated - use resize instead

◆ extent() [2/2]

void hdf5::node::Dataset::extent ( size_t  dim,
ssize_t  delta_elements 
) const

◆ filters()

filter::ExternalFilters hdf5::node::Dataset::filters ( ) const

Returns an instance of the dataset external filters for the dataset.

Exceptions
std::runtime_errorin case of a failure
Returns
instance of ExternalFilters

◆ read() [1/7]

template<typename T >
void hdf5::node::Dataset::read ( T &  data,
const dataspace::Selection selection,
const property::DatasetTransferList dtpl = property::DatasetTransferList::get() 
)

Reading data to an instance of T from a selection of a dataset. It reshapes the mem_space if its rank does not match to the selection rank

Exceptions
std::runtime_errorin case of a failure
Template Parameters
Ttype of the destination object
Parameters
datareference to the destination object
selectionreference to the selection
dtplreference to a dataset transfer property list

◆ read() [2/7]

template<typename T >
void hdf5::node::Dataset::read ( T &  data,
const dataspace::Selection selection,
const property::DatasetTransferList dtpl = property::DatasetTransferList::get() 
) const

◆ read() [3/7]

template<typename T >
void hdf5::node::Dataset::read ( T &  data,
const datatype::Datatype mem_type,
const dataspace::Dataspace mem_space,
const dataspace::Dataspace file_space,
const property::DatasetTransferList dtpl = property::DatasetTransferList::get() 
) const

This template function a very simple wrapper around the original HDF5 C-API function. The major difference is that a type trait is used to obtain a pointer to the data passed as the first argument. This template is provided for maximum flexibility as it allows virtually to do everything which could be done with the C-API.

Exceptions
std::runtime_errorin case of a failure
Template Parameters
Ttype from which to write data
Parameters
dataconst reference to the data source
mem_typereference to the memory data type
mem_spacereference to the memory data space
file_spacereference to the dataspace in the file
dtpldata transfer property list

◆ read() [4/7]

template<typename T >
void hdf5::node::Dataset::read ( T &  data,
const datatype::Datatype mem_type,
const dataspace::Dataspace mem_space,
const property::DatasetTransferList dtpl = property::DatasetTransferList::get() 
) const

◆ read() [5/7]

template<typename T >
void hdf5::node::Dataset::read ( T &  data,
const datatype::Datatype memory_type,
const dataspace::Dataspace memory_space,
const dataspace::Selection file_selection,
const property::DatasetTransferList dtpl = property::DatasetTransferList::get() 
) const
Exceptions
std::runtime_errorin case of a failure
Parameters
datareference to the target to which to read the data
memory_typereference to the memory data type of the target
memory_spacereference to the memory data space of the target
file_selectionreference to the selection for the file dataspace
dtploptional reference to a dataset transfer property list

◆ read() [6/7]

template<typename T >
void hdf5::node::Dataset::read ( T &  data,
const property::DatasetTransferList dtpl = property::DatasetTransferList::get() 
)

Read the entire data from a dataset to an instance of T.

Exceptions
std::runtime_errorin case of a failre
Template Parameters
Tdestination type
Parameters
datareference to the destination
dtplreference to a dataset transfer property list

◆ read() [7/7]

template<typename T >
void hdf5::node::Dataset::read ( T &  data,
const property::DatasetTransferList dtpl = property::DatasetTransferList::get() 
) const

◆ read_chunk() [1/2]

template<typename T >
std::uint32_t hdf5::node::Dataset::read_chunk ( T &  data,
const datatype::Datatype mem_type,
std::vector< unsigned long long > &  offset,
const property::DatasetTransferList dtpl = property::DatasetTransferList::get() 
) const

Read a chunk from a dataset to an instance of T.

Exceptions
std::runtime_errorin case of a failure
Template Parameters
Tsource type
Parameters
datareference to the source instance of T
mem_typereference to the memory data type
offsetlogical position of the first element of the chunk in the dataset's dataspace
dtplreference to a dataset transfer property list
Returns
filter_mask mask of which filters are used with the chunk

◆ read_chunk() [2/2]

template<typename T >
std::uint32_t hdf5::node::Dataset::read_chunk ( T &  data,
std::vector< unsigned long long >  offset,
const property::DatasetTransferList dtpl = property::DatasetTransferList::get() 
) const

Read a chunk from a dataset to an instance of T.

Exceptions
std::runtime_errorin case of a failure
Template Parameters
Tsource type
Parameters
datareference to the source instance of T
offsetlogical position of the first element of the chunk in the dataset's dataspace
dtplreference to a dataset transfer property list
Returns
filter_mask mask of which filters are used with the chunk

◆ read_reshape() [1/2]

template<typename T >
void hdf5::node::Dataset::read_reshape ( T &  data,
const datatype::Datatype mem_type,
const dataspace::Dataspace mem_space,
const dataspace::Selection selection,
const property::DatasetTransferList dtpl = property::DatasetTransferList::get() 
) const

Reading data to an instance of T from a selection of a dataset. This template method tries to deduce the memory type and memory space for the target type (where to write the data to) automatically using the appropriate type traits.

Exceptions
std::runtime_errorin case of a failure
Template Parameters
Ttype of the destination object
Parameters
datareference to the destination object
mem_typereference to the memory data type
mem_spacereference to the memory data space
selectionreference to the selection
dtplreference to a dataset transfer property list

◆ read_reshape() [2/2]

template<typename T >
void hdf5::node::Dataset::read_reshape ( T &  data,
const datatype::Datatype mem_type,
const dataspace::Dataspace mem_space,
const property::DatasetTransferList dtpl = property::DatasetTransferList::get() 
) const

◆ refresh()

void hdf5::node::Dataset::refresh ( ) const
Exceptions
std::runtime_errorin case of a failure

◆ resize()

void hdf5::node::Dataset::resize ( const Dimensions dims) const

Allows to change the shape (number of elements along each dimensions) of a dataset. It is important to note that in such a case a previously requested dataspace though remaining a valid object does no longer describe the datasets layout correctly. The number of elements can be increased or decreased within the limits of the dataspace originally used to create the dataset.

Exceptions
std::runtime_errorin case of a failure
Parameters
dimsvector with new number of elements along each dimension

◆ write() [1/8]

void hdf5::node::Dataset::write ( const char *  data,
const property::DatasetTransferList dtpl = property::DatasetTransferList::get() 
)

Write the entire dataset from an instance of const char *

Exceptions
std::runtime_errorin caes of a failure
Parameters
datapointer to the source instance of const char *
dtplreference to a dataset transfer property list

◆ write() [2/8]

void hdf5::node::Dataset::write ( const char *  data,
const property::DatasetTransferList dtpl = property::DatasetTransferList::get() 
) const

◆ write() [3/8]

template<typename T >
void hdf5::node::Dataset::write ( const T &  data,
const dataspace::Selection selection,
const property::DatasetTransferList dtpl = property::DatasetTransferList::get() 
)

Write data from an instance of T to a selection of the dataset.

Exceptions
std::runtime_errorin case of a failure
Template Parameters
Ttype of the source
Parameters
datareference to the source
selectionreference to the selection
dtplreference to a dataset transfer property list

◆ write() [4/8]

template<typename T >
void hdf5::node::Dataset::write ( const T &  data,
const dataspace::Selection selection,
const property::DatasetTransferList dtpl = property::DatasetTransferList::get() 
) const

◆ write() [5/8]

template<typename T >
void hdf5::node::Dataset::write ( const T &  data,
const datatype::Datatype mem_type,
const dataspace::Dataspace mem_space,
const dataspace::Dataspace file_space,
const property::DatasetTransferList dtpl = property::DatasetTransferList::get() 
) const

This template function a very simple wrapper around the original HDF5 C-API function. The major difference is that a type trait is used to obtain a pointer to the data passed as the first argument. This template is provided for maximum flexibility as it allows virtually to do everything which could be done with the C-API.

Exceptions
std::runtime_errorin case of a failure
Template Parameters
Ttype from which to write data
Parameters
dataconst reference to the data source
mem_typereference to the memory data type
mem_spacereference to the memory data space
file_spacereference to the dataspace in the file
dtpldata transfer property list

◆ write() [6/8]

template<typename T >
void hdf5::node::Dataset::write ( const T &  data,
const datatype::Datatype mem_type,
const dataspace::Dataspace mem_space,
const property::DatasetTransferList dtpl = property::DatasetTransferList::get() 
) const

This function allows specification of the memory dataspace and dataspace and optionally the dataset transfer property list.

◆ write() [7/8]

template<typename T >
void hdf5::node::Dataset::write ( const T &  data,
const property::DatasetTransferList dtpl = property::DatasetTransferList::get() 
)

Write the entire dataset from an instance of T.

Exceptions
std::runtime_errorin caes of a failure
Template Parameters
Tsource type
Parameters
datareference to the source instance of T
dtplreference to a dataset transfer property list

◆ write() [8/8]

template<typename T >
void hdf5::node::Dataset::write ( const T &  data,
const property::DatasetTransferList dtpl = property::DatasetTransferList::get() 
) const

◆ write_chunk() [1/3]

template<typename T >
void hdf5::node::Dataset::write_chunk ( const T &  data,
const datatype::Datatype mem_type,
const dataspace::Dataspace mem_space,
std::vector< unsigned long long > &  offset,
std::uint32_t  filter_mask = 0,
const property::DatasetTransferList dtpl = property::DatasetTransferList::get() 
) const

Write a dataset chunk from an instance of T.

Exceptions
std::runtime_errorin case of a failure
Template Parameters
Tsource type
Parameters
datareference to the source instance of T
mem_typereference to the memory data type
mem_spacereference to the memory data space
offsetlogical position of the first element of the chunk in the dataset's dataspace
filter_maskmask of which filters are used with the chunk
dtplreference to a dataset transfer property list

◆ write_chunk() [2/3]

template<typename T >
void hdf5::node::Dataset::write_chunk ( const T &  data,
std::vector< unsigned long long >  offset,
std::uint32_t  filter_mask = 0,
const property::DatasetTransferList dtpl = property::DatasetTransferList::get() 
)

Write a dataset chunk from an instance of T.

Exceptions
std::runtime_errorin case of a failure
Template Parameters
Tsource type
Parameters
datareference to the source instance of T
offsetlogical position of the first element of the chunk in the dataset's dataspace
filter_maskmask of which filters are used with the chunk
dtplreference to a dataset transfer property list

◆ write_chunk() [3/3]

template<typename T >
void hdf5::node::Dataset::write_chunk ( const T &  data,
std::vector< unsigned long long >  offset,
std::uint32_t  filter_mask = 0,
const property::DatasetTransferList dtpl = property::DatasetTransferList::get() 
) const

◆ write_reshape() [1/2]

template<typename T >
void hdf5::node::Dataset::write_reshape ( const T &  data,
const datatype::Datatype mem_type,
const dataspace::Dataspace mem_space,
const dataspace::Selection selection,
const property::DatasetTransferList dtpl = property::DatasetTransferList::get() 
) const

Write data from an instance of T to a selection of the dataset. It reshapes the mem_space if its rank does not match to the selection rank

Exceptions
std::runtime_errorin case of a failure
Template Parameters
Ttype of the source
Parameters
datareference to the source
mem_typereference to the memory data type
mem_spacereference to the memory data space
selectionreference to the selection
dtplreference to a dataset transfer property list

◆ write_reshape() [2/2]

template<typename T >
void hdf5::node::Dataset::write_reshape ( const T &  data,
const datatype::Datatype mem_type,
const dataspace::Dataspace mem_space,
const property::DatasetTransferList dtpl = property::DatasetTransferList::get() 
) const

Write the entire dataset from an instance of T. It reshapes the mem_space if its rank does not match to the selection rank

Exceptions
std::runtime_errorin caes of a failure
Template Parameters
Tsource type
Parameters
datareference to the source instance of T
mem_typereference to the memory data type
mem_spacereference to the memory data space
dtplreference to a dataset transfer property list

The documentation for this class was generated from the following file: