#include <Hdf5Attribute.h>

Public Member Functions | |
| virtual void | setVariant (const DataVariant &var) |
| virtual const DataVariant & | getVariant () const |
| virtual DataVariant & | getVariant () |
| template<class T> | |
| bool | getValueAs (T &value) const |
| template<class T> | |
| const T * | getValueAsPointer () const |
Protected Member Functions | |
| Hdf5Attribute (Hdf5Node *pParent, const std::string &name, const DataVariant &value) | |
| ~Hdf5Attribute () | |
| Hdf5Data::DataReader * | createReader () const |
Attributes are small metadata elements that are associated with an Hdf5Dataset.
The Hdf5Attribute class CANNOT be created by itself. Only an Hdf5Element can create or destroy them. Currently supported are all basic types and vectors of basic types. Any other types must have their memory allocated manually. Examples:
// assume pDataset exists and is a member of some Hdf5Group // create a complex attribute Hdf5Attribute* pAttr = pDataset->addAttribute("complex", 2); IntegerComplex* pCompl = new IntegerComplex[2]; // set pCompl pAttr->setValue(pCompl); // pAttr now owns this memory
// assume pDataset exists and is a member of some Hdf5Group // create a vector<int> attribute // since this is a built-in type, the attribute allocates the memory for us Hdf5Attribute* pAttr = pDataset->addAttribute("vector<int>", 2); int* pVector = pAttr->getFirstValue(); // get a pointer to the first value in the vector and start writing fread(pVector, sizeof(int), 2, pInputFile); // read directly from file into attribute
Definition at line 49 of file Hdf5Attribute.h.
| Hdf5Attribute::Hdf5Attribute | ( | Hdf5Node * | pParent, | |
| const std::string & | name, | |||
| const DataVariant & | value | |||
| ) | [protected] |
Creates an attribute with a given type and number of elements.
This method cannot be called directly. Use Hdf5Element::addAttribute() to add an attribute to an Hdf5Element.
| pParent | The Hdf5Node that this attribute belongs to. | |
| name | The name of the attribute. | |
| value | The current value of the attribute. |
| Hdf5Attribute::~Hdf5Attribute | ( | ) | [protected] |
Destroys an Hdf5Attribute object.
Use Hdf5Element::removeAttribute() to delete an Hdf5Attribute from an Hdf5Element.
| virtual void Hdf5Attribute::setVariant | ( | const DataVariant & | var | ) | [virtual] |
Sets the value of the attribute.
| var | A variant holding the attribute value. |
| virtual const DataVariant& Hdf5Attribute::getVariant | ( | ) | const [virtual] |
Returns a reference to the object.
| virtual DataVariant& Hdf5Attribute::getVariant | ( | ) | [virtual] |
Returns a reference to the object.
| bool Hdf5Attribute::getValueAs | ( | T & | value | ) | const |
Retrieves the value.
Definition at line 80 of file Hdf5Attribute.h.
| const T* Hdf5Attribute::getValueAsPointer | ( | ) | const |
Returns a pointer to the value or NULL if the type does not match.
Definition at line 92 of file Hdf5Attribute.h.
| Hdf5Data::DataReader* Hdf5Attribute::createReader | ( | ) | const [protected, virtual] |
Implements Hdf5Data.