Utopia  2
Framework for studying models of complex & adaptive systems.
Public Types | Public Member Functions | Private Attributes | List of all members
Utopia::DataIO::HDFType Class Referencefinal

Class which handles the conversion of C-types into hdf5types. More...

#include <hdftype.hh>

Inheritance diagram for Utopia::DataIO::HDFType:
Inheritance graph
[legend]
Collaboration diagram for Utopia::DataIO::HDFType:
Collaboration graph
[legend]

Public Types

using Base = HDFObject< HDFCategory::datatype >
 
using Variant = std::variant< float, double, long double, int, short int, long int, long long int, unsigned int, unsigned short int, std::size_t, unsigned long long, bool, char, std::vector< float >, std::vector< double >, std::vector< long double >, std::vector< int >, std::vector< short int >, std::vector< long int >, std::vector< long long int >, std::vector< unsigned int >, std::vector< unsigned short int >, std::vector< std::size_t >, std::vector< unsigned long long >, std::vector< char >, std::vector< std::string >, std::string, const char * >
 

Public Member Functions

bool is_mutable () const
 Get if the type is mutable or not. More...
 
auto type_category () const
 Get the type category of the held type, i.e., scala, string, varlen,... More...
 
std::size_t size () const
 Size of the type held in bytes. More...
 
template<typename T >
void open (T &&object)
 Open the HDF5 type associated with an HDFObject, i.e., a dataset or an attribute. More...
 
template<typename T >
void open (std::string name, hsize_t typesize)
 Create an HDF datatype corresponding to the C datatype given as template argument. More...
 
void close ()
 Construct close from the given arguments. More...
 
virtual bool is_valid () const override
 Check if the held type identifier is still valid. Primitive types are valid by definition, because we have no control over them and hence they cannot be invalidated. More...
 
 HDFType (HDFType &&other)
 Construct HDFType from the given arguments by move, deleted, because apparently incompatible with HDF5 C backend. More...
 
HDFTypeoperator= (HDFType &&other)
 Move assign the type. More...
 
 HDFType (const HDFType &other)=default
 Construct HDFType from the given arguments by copy. More...
 
HDFTypeoperator= (const HDFType &other)=default
 Copy assign type. More...
 
virtual ~HDFType ()
 Destroy the HDFType object. More...
 
 HDFType ()
 Construct HDFType from by default. More...
 
template<typename T >
 HDFType (T &&object_or_size, std::enable_if_t< not std::is_same_v< HDFType, std::decay_t< T > >, int >=0)
 Construct HDFType from the given arguments. More...
 
- Public Member Functions inherited from Utopia::DataIO::HDFObject< HDFCategory::datatype >
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...
 
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...
 
HDFObjectoperator= (const HDFObject &other)
 Copy assignment operator. More...
 
HDFObjectoperator= (HDFObject &&other)
 move assignment operator More...
 
virtual ~HDFObject ()
 Destroy the HDFObject object. Has to be implemented in subclass! More...
 

Private Attributes

bool _mutable = false
 
H5T_class_t _classid
 

Additional Inherited Members

- Static Public Attributes inherited from Utopia::DataIO::HDFObject< HDFCategory::datatype >
static constexpr HDFCategory category
 Named variable for template arg. More...
 
- Protected Attributes inherited from Utopia::DataIO::HDFObject< HDFCategory::datatype >
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...
 

Detailed Description

Class which handles the conversion of C-types into hdf5types.

Member Typedef Documentation

◆ Base

◆ Variant

using Utopia::DataIO::HDFType::Variant = std::variant< float, double, long double, int, short int, long int, long long int, unsigned int, unsigned short int, std::size_t, unsigned long long, bool, char, std::vector< float >, std::vector< double >, std::vector< long double >, std::vector< int >, std::vector< short int >, std::vector< long int >, std::vector< long long int >, std::vector< unsigned int >, std::vector< unsigned short int >, std::vector< std::size_t >, std::vector< unsigned long long >, std::vector< char >, std::vector< std::string >, std::string, const char* >

Constructor & Destructor Documentation

◆ HDFType() [1/4]

Utopia::DataIO::HDFType::HDFType ( HDFType &&  other)
inline

Construct HDFType from the given arguments by move, deleted, because apparently incompatible with HDF5 C backend.

◆ HDFType() [2/4]

Utopia::DataIO::HDFType::HDFType ( const HDFType other)
default

Construct HDFType from the given arguments by copy.

◆ ~HDFType()

virtual Utopia::DataIO::HDFType::~HDFType ( )
inlinevirtual

Destroy the HDFType object.

◆ HDFType() [3/4]

Utopia::DataIO::HDFType::HDFType ( )
inline

Construct HDFType from by default.

◆ HDFType() [4/4]

template<typename T >
Utopia::DataIO::HDFType::HDFType ( T &&  object_or_size,
std::enable_if_t< not std::is_same_v< HDFType, std::decay_t< T > >, int >  = 0 
)
inline

Construct HDFType from the given arguments.

Parameters
sizeSize of the type underlying the type to be created, or an HDFdataset or attribute to determine the held datatype of

Member Function Documentation

◆ close()

void Utopia::DataIO::HDFType::close ( )
inline

Construct close from the given arguments.

◆ is_mutable()

bool Utopia::DataIO::HDFType::is_mutable ( ) const
inline

Get if the type is mutable or not.

Returns
true
false

◆ is_valid()

virtual bool Utopia::DataIO::HDFType::is_valid ( ) const
inlineoverridevirtual

Check if the held type identifier is still valid. Primitive types are valid by definition, because we have no control over them and hence they cannot be invalidated.

Returns
true
false

Reimplemented from Utopia::DataIO::HDFObject< HDFCategory::datatype >.

◆ open() [1/2]

template<typename T >
void Utopia::DataIO::HDFType::open ( std::string  name,
hsize_t  typesize 
)
inline

Create an HDF datatype corresponding to the C datatype given as template argument.

Template Parameters
T
Parameters
object_or_sizesize of the datatype in bytes, if not given, automatically determined: containers and strings become variable length size, everything else becomes scalar

◆ open() [2/2]

template<typename T >
void Utopia::DataIO::HDFType::open ( T &&  object)
inline

Open the HDF5 type associated with an HDFObject, i.e., a dataset or an attribute.

Template Parameters
T
Parameters
object

◆ operator=() [1/2]

HDFType& Utopia::DataIO::HDFType::operator= ( const HDFType other)
default

Copy assign type.

Returns
HDFType&

◆ operator=() [2/2]

HDFType& Utopia::DataIO::HDFType::operator= ( HDFType &&  other)
inline

Move assign the type.

Returns
HDFType&

◆ size()

std::size_t Utopia::DataIO::HDFType::size ( ) const
inline

Size of the type held in bytes.

Returns
std::size_t

◆ type_category()

auto Utopia::DataIO::HDFType::type_category ( ) const
inline

Get the type category of the held type, i.e., scala, string, varlen,...

Returns
auto type category of held type

Member Data Documentation

◆ _classid

H5T_class_t Utopia::DataIO::HDFType::_classid
private

◆ _mutable

bool Utopia::DataIO::HDFType::_mutable = false
private

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