Utopia
2
Framework for studying models of complex & adaptive systems.
|
Class for hdf5 attribute, which can be attached to groups and datasets. More...
#include <hdfattribute.hh>
Public Types | |
using | Base = HDFObject< HDFCategory::attribute > |
alias base class More... | |
Public Member Functions | |
void | swap (HDFAttribute &other) |
Exchange states between caller and argument. More... | |
HDFDataspace | get_filespace () |
Get the file-dataspace object. More... | |
auto | get_type () |
Get the type object. More... | |
HDFIdentifier | get_parent_id () |
Get the hdf5 identifier to which the attribute belongs. More... | |
void | close () |
closes the attribute More... | |
auto | get_shape () |
Get the shape object. More... | |
template<HDFCategory cat> | |
void | open (const HDFObject< cat > &parent, std::string name) |
Open a new attribute on HDFObject 'parent' with name 'name'. More... | |
void | open (const HDFIdentifier &parent, std::string name) |
Open a new attribute on HDFObject 'parent' with name 'name'. More... | |
template<typename Type > | |
auto | read () |
Reads data from attribute, and returns the data and its shape in the form of a hsize_t vector. More... | |
template<typename Type > | |
void | read (Type &buffer) |
Reads data from attribute into a predefined buffer, and returns the data and its shape in the form of a hsize_t vector. User is responsible for providing a buffer which can hold the data and has the correct shape! More... | |
template<typename Type > | |
void | write (Type attribute_data, std::vector< hsize_t > shape={}) |
Function for writing data to the attribute. More... | |
template<typename Iter , typename Adaptor > | |
void | write (Iter begin, Iter end, Adaptor adaptor=[](auto &value) { return value;}, [[maybe_unused]] std::vector< hsize_t > shape={}) |
Function for writing data to the attribute. More... | |
HDFAttribute ()=default | |
Default constructor, deleted because of reference member. More... | |
HDFAttribute (const HDFAttribute &other)=default | |
Copy constructor. More... | |
HDFAttribute (HDFAttribute &&other)=default | |
Move constructor. More... | |
HDFAttribute & | operator= (const HDFAttribute &other)=default |
Copy assignment operator. More... | |
HDFAttribute & | operator= (HDFAttribute &&other)=default |
Attribute move assignment operator. More... | |
virtual | ~HDFAttribute () |
Destructor. More... | |
template<HDFCategory cat> | |
HDFAttribute (const HDFObject< cat > &object, std::string name) | |
Constructor for attribute. More... | |
Public Member Functions inherited from Utopia::DataIO::HDFObject< HDFCategory::attribute > | |
void | swap (HDFObject &other) |
swap the state of the caller with the state of the argument More... | |
std::string | get_path () const |
Get the name or path object. More... | |
auto | get_id_object () const |
Get the id object. More... | |
auto | get_logger () const |
Get the logger object. More... | |
hid_t | get_C_id () const |
Get the C id object. More... | |
auto | get_refcount () |
Get the reference count of object. More... | |
virtual bool | is_valid () const |
Check if the object is still valid. More... | |
void | close () |
Close function which takes care of correctly closing the object and managing the reference counter. More... | |
void | bind_to (hid_t id, std::function< herr_t(hid_t) > closing_func, std::string path={}) |
Open the object and bind it to a HDF5 object identified by 'id' with name 'path'. Object should be created beforehand. More... | |
HDFObject () | |
Construct HDFObject from the given arguments. More... | |
HDFObject (HDFObject &&other) | |
Construct HDFObject by moving. More... | |
HDFObject (const HDFObject &other)=default | |
Construct HDFObject by copying another object. More... | |
HDFObject (hid_t id, std::function< herr_t(hid_t) > closing_func, std::string path={}) | |
Construct HDFObject from the given argument. More... | |
HDFObject & | operator= (const HDFObject &other) |
Copy assignment operator. More... | |
HDFObject & | operator= (HDFObject &&other) |
move assignment operator More... | |
virtual | ~HDFObject () |
Destroy the HDFObject object. Has to be implemented in subclass! More... | |
Private Member Functions | |
template<typename result_type > | |
void | __create_attribute__ (hsize_t typesize=0) |
private helper function for creation of attribute More... | |
template<typename Type > | |
herr_t | __write_container__ (Type attribute_data) |
Function for writing containers as attribute. More... | |
template<typename Type > | |
herr_t | __write_stringtype__ (Type attribute_data) |
template<typename Type > | |
herr_t | __write_pointertype__ (Type attribute_data) |
template<typename Type > | |
herr_t | __write_scalartype__ (Type attribute_data) |
template<typename Type > | |
herr_t | __read_container__ (Type &buffer) |
template<typename Type > | |
auto | __read_stringtype__ (Type &buffer) |
template<typename Type > | |
auto | __read_pointertype__ (Type buffer) |
template<typename Type > | |
auto | __read_scalartype__ (Type &buffer) |
Private Attributes | |
std::vector< hsize_t > | _shape |
size of the attributes dataspace More... | |
HDFIdentifier | _parent_identifier |
Identifier of the parent object. More... | |
HDFDataspace | _dataspace |
Dataspace object that manages topology of data written and read. More... | |
HDFType | _type |
type done in the HDFAttribute More... | |
Additional Inherited Members | |
Static Public Attributes inherited from Utopia::DataIO::HDFObject< HDFCategory::attribute > | |
static constexpr HDFCategory | category |
Named variable for template arg. More... | |
Protected Attributes inherited from Utopia::DataIO::HDFObject< HDFCategory::attribute > | |
HDFIdentifier | _id |
Identifier object that binds an instance of this class to an HDF5 object. More... | |
std::string | _path |
Name of the object. More... | |
std::shared_ptr< spdlog::logger > | _log |
pointer to the logger for dataio More... | |
Class for hdf5 attribute, which can be attached to groups and datasets.
HDFObject | the object class |
alias base class
|
default |
Default constructor, deleted because of reference member.
|
default |
Copy constructor.
other | The other |
|
default |
Move constructor.
other | The other |
|
inlinevirtual |
Destructor.
|
inline |
Constructor for attribute.
object | the object to create the attribute at |
name | the name of the attribute |
size | the size of the attribute if known, else 1 |
|
inlineprivate |
private helper function for creation of attribute
[in] | typesize | The typesize |
result_type | Type of the resulting attribute |
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
Function for writing containers as attribute.
Only buffers if necessary, i.e. if non-vector containers or nested containers or containers of strings have to be written.
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
|
inline |
closes the attribute
|
inline |
Get the file-dataspace object.
|
inline |
Get the hdf5 identifier to which the attribute belongs.
|
inline |
Get the shape object.
|
inline |
Get the type object.
|
inline |
Open a new attribute on HDFObject 'parent' with name 'name'.
parent | HDFIdentifier to open the attribute on |
name | The attribute's name |
|
inline |
|
default |
|
default |
|
inline |
Reads data from attribute, and returns the data and its shape in the form of a hsize_t vector.
This function has a quirk:
Depending on the type 'Type', the data will be returned as:
Type | which can hold elements in the attribute and which will be returned |
|
inline |
Reads data from attribute into a predefined buffer, and returns the data and its shape in the form of a hsize_t vector. User is responsible for providing a buffer which can hold the data and has the correct shape!
Type | which can hold elements in the attribute and which will be returned |
|
inline |
Exchange states between caller and argument.
other |
|
inline |
Function for writing data to the attribute.
Iter | Iterator type |
Adaptor | Adaptor which allows for extraction of a value from compound types, i.e. classes or structs |
begin | Start of iterator range |
end | End of iterator range |
adaptor | Function which turns the elements of the iterator into the objects to be written. Should (auto&) argument (simplest), but else must have (typename Iter::value_type&) argument |
|
inline |
Function for writing data to the attribute.
Type | Automatically determined type of the data to write |
attribute_data | Data to write |
shape | Layout of the data, i.e. {20, 50} would indicate a 2d array like int a[20][50]; The parameter has only to be given if the data to be written is given as plain pointers, because the shape cannot be determined automatically then. |
typelen | If the elements of the data to be written are arrays of equal length, and the data should be written as 1d attribute, then we can give the length of the arrays in order to speed up the memory allocation and avoid unecessary buffering. This can be useful for grids for instance. |
|
private |
Dataspace object that manages topology of data written and read.
|
private |
Identifier of the parent object.
|
private |
size of the attributes dataspace
|
private |
type done in the HDFAttribute