libpniio
Public Types | Public Member Functions | Private Member Functions | Private Attributes
pni::io::nx::h5::h5dataspace Class Reference

dataspace object More...

#include <h5dataspace.hpp>

Collaboration diagram for pni::io::nx::h5::h5dataspace:
Collaboration graph
[legend]

Public Types

typedef type_imp::index_type value_type
 value type for buffers More...
 
typedef
type_imp::index_vector_type::const_iterator 
iterator
 buffer iterator More...
 

Public Member Functions

 h5dataspace ()
 default constructor More...
 
 h5dataspace (object_imp &&o)
 constructor More...
 
 h5dataspace (const type_imp::index_vector_type &shape)
 constructor More...
 
 h5dataspace (type_imp::index_vector_type &&shape)
 constructor More...
 
size_t rank () const
 rank of dataset More...
 
hid_t id () const noexcept
 get object reference More...
 
bool is_valid () const
 check validity status More...
 
size_t size () const
 total number of elements More...
 
bool has_selection () const
 true if selection is set on this dataspace More...
 
const type_imp::index_vector_typeshape () const noexcept
 return reference to the current dimensions buffer More...
 
void grow (size_t dim=0, size_t ext=1)
 grow dataspace More...
 
void apply_selection (const selection &s) const
 apply selection More...
 
void reset_selection () const noexcept
 reset selection More...
 
const object_impobject () const noexcept
 get reference to object More...
 

Private Member Functions

void __init_buffers () noexcept
 initialize buffers More...
 
void __update_dataspace ()
 setup dataspace More...
 
void __update_buffers ()
 update the buffers More...
 

Private Attributes

object_imp _object
 The HDF5 object representing the dataspace. More...
 
type_imp::index_vector_type _dims
 number of elements More...
 
type_imp::index_vector_type _maxdims
 maximum number of elements dimensions More...
 

Detailed Description

This class encapsulates an HDF5 dataspace. A dataspace describes the organization of dataelements within a dataset in the file or of data stored in memory. A dataspace in HDF5 can either be

A dataspace object provides information items which are necessary to describe the data organization

The object encapsulates two buffers (instances of std::vector) which provide this information. (not a dataspace) can grow. This number can be a finite one or can be set to H5Dataspace::UNLIMITED which allows the dataset to grow infinitely along this dimension.

At any time during the lifetime of a H5Dataspace object the dataspace it describes can be resized to any required shape (see the resize() and grow() methods). This makes it easy to adopt the object to your needs. There are many possibilities how to construct a dataspace.

A dataspace representing a scalar value has a rank of 0 and a size of 1.

Member Typedef Documentation

typedef type_imp::index_vector_type::const_iterator pni::io::nx::h5::h5dataspace::iterator

Constructor & Destructor Documentation

pni::io::nx::h5::h5dataspace::h5dataspace ( )
explicit

By default a scalar dataspace is constructed. This constructor can always be used in order to store a scalar value. Consequently even a default constructed H5Dataspace is always a valid HDF5 object.

Exceptions
object_errorin case of default construction problems
pni::io::nx::h5::h5dataspace::h5dataspace ( object_imp &&  o)

Construct a dataspace from an instance of object_imp.

Exceptions
type_errorin case that the object is not a dataspace
invalid_object_errorif the object is not valid
object_errorin case of any other error
Parameters
orvalue reference to an instance of object_imp
pni::io::nx::h5::h5dataspace::h5dataspace ( const type_imp::index_vector_type shape)
explicit

This constructor takes a const reference to a container with the current shape of the dataspace. The maximum shape will be equal to the current shape.

Exceptions
object_errorin case of failure
Parameters
shapevector with shape data
pni::io::nx::h5::h5dataspace::h5dataspace ( type_imp::index_vector_type &&  shape)
explicit

The constructors takes an rvalue reference to the current shape of the dataspace. The maximum shape will have the same value as the current shape.

Exceptions
object_errorin case of any failure
Parameters
shapervalue reference to the current shape

Member Function Documentation

void pni::io::nx::h5::h5dataspace::__init_buffers ( )
privatenoexcept
void pni::io::nx::h5::h5dataspace::__update_buffers ( )
private
void pni::io::nx::h5::h5dataspace::__update_dataspace ( )
private

This method will update a dataspace according to the values stored in the two internal buffers.

Exceptions
object_errorif dataspace extent could not have been set
void pni::io::nx::h5::h5dataspace::apply_selection ( const selection s) const

Apply a selection on this dataspace

Exceptions
invalid_object_errorif dataspace is not valid
object_errorif applying the selection fails
Parameters
sreference to a selection object
void pni::io::nx::h5::h5dataspace::grow ( size_t  dim = 0,
size_t  ext = 1 
)

Grow the dataspace along dimension dim by ext elements. This is a very simple method to enlarge a dataspace along a particular dimension. If dim is larger than the rank of the dataspace an exception will be thrown.

Exceptions
index_errorif dim exceeds rank of dataspace
invalid_object_errorif the dataspace is not valid
object_errorif dataspace update fails
Parameters
dimdimension along which to grow
extextend by which to grow
bool pni::io::nx::h5::h5dataspace::has_selection ( ) const

Return true if a selection is applied to this dataspace.

Exceptions
object_errorif selection space cannot be determined
Returns
true if dataspace has selection
hid_t pni::io::nx::h5::h5dataspace::id ( ) const
noexcept
bool pni::io::nx::h5::h5dataspace::is_valid ( ) const

Returns true if the dataspace instance is valid, false otherwise.

Exceptions
object_errorif validity status cannot be obtained
Returns
true if valid, false otherwise
const object_imp & pni::io::nx::h5::h5dataspace::object ( ) const
noexcept

Return a const reference to the object instance holding the HDF5 identifier of the dataset.

Returns
reference to object instance
size_t pni::io::nx::h5::h5dataspace::rank ( ) const

Returns the rank (the number of dimensions) of the dataset. This method always returns the total number of dimensions even if a selection is set.

Exceptions
invalid_object_errorif dataspace is not valid
object_errorin case of any other error
Returns
number of dimension
void pni::io::nx::h5::h5dataspace::reset_selection ( ) const
noexcept
const type_imp::index_vector_type & pni::io::nx::h5::h5dataspace::shape ( ) const
noexcept
size_t pni::io::nx::h5::h5dataspace::size ( ) const

Returns the total number of elemenets that can be stored in the dataspace. For a scalar dataspace this method returns 1.

Exceptions
invalid_object_errorif dataspace not valid
object_errorif size could not be determined
Returns
total number of elements

Field Documentation

type_imp::index_vector_type pni::io::nx::h5::h5dataspace::_dims
private
type_imp::index_vector_type pni::io::nx::h5::h5dataspace::_maxdims
private
object_imp pni::io::nx::h5::h5dataspace::_object
private

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