Read a non-sharable attribute¶
saf_get_attribute is a function defined in utils.c.
Synopsis:
-
int
saf_get_attribute(SAF_ParMode pmode, ss_pers_t *obj, const char *name, hid_t *type, int *count, void **value)¶
Formal Arguments:
pmode: One of the parallel modes.obj: The handle to the object from which the attribute will be read.name: The name of the attribute. SeeSAF__ATT_NAMESand other reserved attribute names for special kinds of attribute queries.type:IN``[``OUT] IftypeisNULL, this argument will be ignored. Iftypepoints to a valid datatype, then the attribute will be converted to the specified type as it is read. If it does not, there will be no data conversion and the output value will be the datatype of the data returned (the caller should invokeH5Tclose).count: [OUT] The number of items in the attribute. IfcountisNULL, then the value ofcountwill not be returned.value:IN``[``OUT] Points to an array ofcountvalues each having datatypetype. IfvalueisNULL, then no attribute values will be returned. Ifvaluepoints toNULL, then the library will allocate the array of values which is returned. Otherwise the library assumes thatvaluepoints to an array whose size is sufficient for storingcountvalues of datatypetype. That is, ifvalueis pointing to non-NULL, then so mustcountpoint to non-NULLand the value pointed to bycountwill be used by SAF as the size, in items of typetype, of the block of memory pointed to byvalue. For aSAF__ATT_NAMESquery if the caller supplies a buffer for this argument then it should be a buffer ofcharpointers, the values of which will be allocated by this function.
Description: This function provides a method by which existing, generic, non-sharable attributes may be read from an object. Attributes are pieces of meta data which fall outside the scope of the sharable data model (i.e., things which are not fields) but which are often useful for conveying additional information. The meaning of a particular attribute is determined by convention, requiring additional communication between the writer and the reader (often in the form of documentation or word of mouth).
Preconditions:
pmodemust be valid. (low-cost)namemust not be null. (low-cost)countandvaluemust be compatible for return value allocation. (low-cost)objmust not be null. (low-cost)
Return Value: The constant SAF__SUCCESS is returned when this function is successful. Otherwise this function either returns
an error number or throws an exception, depending on the value of the library’s error handling property.
Parallel Notes: Depends on pmode
Issues: On error, the argument return values are undefined.
If the attribute name is SAF__ATT_NAMES then the client must not preallocate space for the value return value,
but must allow the library to handle the allocation. That is, if the arg passed for name is SAF__ATT_NAMES, the
client must not pass value such that it points to a non-null pointer.
The reserved attribute name queries, SAF__ATT_FIRST and SAF__ATT_NEXT, are not yet implemented.
This is a weird interface. There should be a separate function to obtain the datatype and count of an
attribute so that this function doesn’t need to return those values. The type and count arguments should
instead specify what value is returned by this function. And the value should be just an optional `void*’
buffer which if not supplied is allocated and which is the successful return value of this function.
[rpm 2004-08-25]
If the pool allocation is being used then we’ll have a problem if there are more attributes than what the string pool can store.
See Also:
- Attributes: Introduction for current chapter