#include <KeyValueTyped.h>
Public Member Functions | |
virtual int | set (const char *key, enum RawData::Type type, void *value) CLASSIC_CCA_PURE |
Defines a new single-valued property or changes the value of an existing one. | |
virtual int | get (const char *key, enum RawData::Type type, void *valuePtr) CLASSIC_CCA_PURE |
virtual void | unset (const char *propName) CLASSIC_CCA_PURE |
Remove a key from the properties. | |
virtual int | setString (const char *key, const char *value) CLASSIC_CCA_PURE |
Defines a new string property or changes its value. | |
virtual const char * | getString (const char *key) CLASSIC_CCA_PURE |
Fetch a string value. | |
virtual void | getKeys (Argv *keylist) CLASSIC_CCA_PURE |
Produce a list of all the keys in an abstract container. |
This is a generic properties input/output Port. It may be backed by a shared database, a private database, or an instance of some numerical object, or anything else for that matter.
This is a Closed hash -- one value (and value type) per key. Setting a new value and type for a key which has a value of another type already is an error.
As an example: If you have a solver that cares about the properties of a Matrix or Operator, simply : esi::Properties *p; err = mtx->getInterface("esi::Properties", (void *)p,msg); bool is_psym = false; if (err >= 0) { // <0 means no properties interface p. err2 = p->getBool("esi.P-Symmetric",psym); // ignore err2 is ok if esi.P-Symmetric unknown, nothing psym is returned unchanged. }
Implementation notes:
Since this version uses an enum-based type-checking scheme, access functions may return errors for data with types not supported on the given platform. It is probable that no 100% complete and native C compiler supported implementation will exist due to the breadth of possible types defined in RawData.h
virtual int classic::gov::cca::KeyValueTyped::set | ( | const char * | key, | |
enum RawData::Type | type, | |||
void * | value | |||
) | [virtual] |
Defines a new single-valued property or changes the value of an existing one.
key | The property name, which will be copied. | |
type | The singleton types from the Type enum in RawData.h. String values are supported but not with this function. Ptr* types from RawData are not supported. | |
value | Pointer to the property value to be copied. A 0 pointer value will cause the key to remain with a NULL value. Use 'unset' to delete key. |
virtual int classic::gov::cca::KeyValueTyped::get | ( | const char * | key, | |
enum RawData::Type | type, | |||
void * | valuePtr | |||
) | [virtual] |
virtual void classic::gov::cca::KeyValueTyped::unset | ( | const char * | propName | ) | [virtual] |
Remove a key from the properties.
All errors are silently ignored.
propName | key. otherwise pointerOut is 0. |
virtual int classic::gov::cca::KeyValueTyped::setString | ( | const char * | key, | |
const char * | value | |||
) | [virtual] |
Defines a new string property or changes its value.
key | The property name, which will be copied. | |
value | The property value to be set. |
virtual const char* classic::gov::cca::KeyValueTyped::getString | ( | const char * | key | ) | [virtual] |
Fetch a string value.
key | The name of the string value to be fetched. |
virtual void classic::gov::cca::KeyValueTyped::getKeys | ( | Argv * | keylist | ) | [virtual] |
Produce a list of all the keys in an abstract container.
keylist | input/output Argv that should be supplied empty (containing no keys). The names of keys in the KeyValueTyped are appended. |