libSplash
Public Member Functions | Friends | List of all members
splash::AttributeInfo Class Reference

#include <AttributeInfo.hpp>

Public Member Functions

 AttributeInfo (hid_t attr)
 
 AttributeInfo (H5AttributeId &attr)
 
 AttributeInfo (const AttributeInfo &other)
 
AttributeInfooperator= (const AttributeInfo &other)
 
size_t getMemSize () throw (DCException)
 
const CollectionTypegetType () throw (DCException)
 
Dimensions getDims () throw (DCException)
 
uint32_t getNDims () throw (DCException)
 
bool isScalar () throw (DCException)
 
bool isVarSize () throw (DCException)
 
std::string readName ()
 
void read (const CollectionType &colType, void *buf) throw (DCException)
 
bool readNoThrow (const CollectionType &colType, void *buf)
 
void read (void *buf, size_t bufSize) throw (DCException)
 
void close ()
 

Friends

void swap (AttributeInfo &lhs, AttributeInfo &rhs)
 

Detailed Description

Class holding information about an attribute.

Usage example:

AttributeInfo info = dc.readAttribute(iterationId, "groupName", "attrName");
// Check that extents are as expected
if(!info.isScalar()) throw error(...);
// Optionally further checks
...
int result;
info.read(ColTypeInt(), &result);

Definition at line 50 of file AttributeInfo.hpp.

Constructor & Destructor Documentation

◆ AttributeInfo()

splash::AttributeInfo::AttributeInfo ( H5AttributeId attr)
explicit

Construct from an attribute id, takes over ownership!

Definition at line 36 of file AttributeInfo.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ close()

void splash::AttributeInfo::close ( )

Closes the attribute invalidating all future calls to this object Note: If there are multiple instances relating to the same HDF5-Attribute all of them must be closed or destroyed

Definition at line 196 of file AttributeInfo.cpp.

Here is the caller graph for this function:

◆ getDims()

Dimensions splash::AttributeInfo::getDims ( )
throw (DCException
)

Return the size in each dimension

Definition at line 141 of file AttributeInfo.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getMemSize()

size_t splash::AttributeInfo::getMemSize ( )
throw (DCException
)

Return the size of the required memory in bytes when querying the value

Definition at line 115 of file AttributeInfo.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getNDims()

uint32_t splash::AttributeInfo::getNDims ( )
throw (DCException
)

Return the number of dimensions

Definition at line 159 of file AttributeInfo.cpp.

Here is the caller graph for this function:

◆ getType()

const CollectionType & splash::AttributeInfo::getType ( )
throw (DCException
)

Return the CollectionType. Might be ColTypeUnknown

Definition at line 131 of file AttributeInfo.cpp.

Here is the call graph for this function:

◆ isScalar()

bool splash::AttributeInfo::isScalar ( )
throw (DCException
)
inline

Return whether this is a scalar value

Definition at line 72 of file AttributeInfo.hpp.

Here is the call graph for this function:

◆ isVarSize()

bool splash::AttributeInfo::isVarSize ( )
throw (DCException
)

Return true, if the attribute has a variable size in which case reading it will only return its pointer

Definition at line 166 of file AttributeInfo.cpp.

Here is the caller graph for this function:

◆ read() [1/2]

void splash::AttributeInfo::read ( const CollectionType colType,
void *  buf 
)
throw (DCException
)

Read the data of this attribute into the buffer of the given type. Data conversion may occur, if required. See the HDF5 manual for details (6.10. Data Transfer: Datatype Conversion and Selection) Throws an exception if the attribute could not be read or converted

Parameters
colTypeType of the buffer
bufPointer to buffer. Size must be equal to getMemSize

Definition at line 172 of file AttributeInfo.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ read() [2/2]

void splash::AttributeInfo::read ( void *  buf,
size_t  bufSize 
)
throw (DCException
)

Read the data of this attribute into the buffer of the given size. No data conversion occurs, so the type as found in the file is used. Throws an exception if the attribute could not be read or the buffer is to small. Warning: Might be unsafe if you are not the author of the HDF5 file or the data type differs from the expected one. Check the meta-data and/or pass the CollectionType to make sure you get what you expect.

Parameters
bufPointer to buffer
bufSizeSize of the buffer

Definition at line 183 of file AttributeInfo.cpp.

Here is the call graph for this function:

◆ readName()

std::string splash::AttributeInfo::readName ( )

Read the name of the attribute. Returns an empty string on error

Definition at line 101 of file AttributeInfo.cpp.

Here is the caller graph for this function:

◆ readNoThrow()

bool splash::AttributeInfo::readNoThrow ( const CollectionType colType,
void *  buf 
)

Read the data of this attribute into the buffer of the given type. Data conversion may occur, if required. See the HDF5 manual for details (6.10. Data Transfer: Datatype Conversion and Selection) Does not throw exception, so it can be used for trying different types

Parameters
colTypeType of the buffer
bufPointer to buffer. Size must be equal to getMemSize
Returns
True on success, else false

Definition at line 178 of file AttributeInfo.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

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