#include <Hdf4Attribute.h>
Public Member Functions | |
| virtual const std::string & | getName () const |
| 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 | |
| Hdf4Attribute (const std::string &name, const DataVariant &value) | |
| virtual | ~Hdf4Attribute () |
Attributes are small metadata elements that are associated with an Hdf4Dataset.
The Hdf4Attribute class CANNOT be created by itself. Only an Hdf4Element 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 Hdf4Group // create a complex attribute Hdf4Attribute* 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 Hdf4Group // create a vector<int> attribute // since this is a built-in type, the attribute allocates the memory for us Hdf4Attribute* 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 47 of file Hdf4Attribute.h.
| Hdf4Attribute::Hdf4Attribute | ( | 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 Hdf4Element::addAttribute() to add an attribute to an Hdf4Element.
| name | The name of the attribute. | |
| value | The current value of the attribute. |
| virtual Hdf4Attribute::~Hdf4Attribute | ( | ) | [protected, virtual] |
Destroys an Hdf4Attribute object.
Use Hdf4Element::removeAttribute() to delete an Hdf4Attribute from an Hdf4Element.
| virtual const std::string& Hdf4Attribute::getName | ( | ) | const [virtual] |
Gets the attribute name.
| virtual void Hdf4Attribute::setVariant | ( | const DataVariant & | var | ) | [virtual] |
Sets the value of the attribute.
| var | A variant holding the attribute value. |
| virtual const DataVariant& Hdf4Attribute::getVariant | ( | ) | const [virtual] |
Returns a reference to the object.
| virtual DataVariant& Hdf4Attribute::getVariant | ( | ) | [virtual] |
Returns a reference to the object.
| bool Hdf4Attribute::getValueAs | ( | T & | value | ) | const |
Retrieves the value.
Definition at line 85 of file Hdf4Attribute.h.
| const T* Hdf4Attribute::getValueAsPointer | ( | ) | const |
Returns a pointer to the value or NULL if the type does not match.
Definition at line 96 of file Hdf4Attribute.h.