#include <metadataHolder.h>
Public Member Functions | |
virtual const Metadata & | getMeta (const std::string &key, bool searchDefaults=true, bool searchSecondary=true) const |
Returns Metadata of the specified key. | |
void | setMeta (const std::string &key, const Metadata &value) const |
Sets metadata for a specified key. | |
void | setSecondaryMetadataLocation (const MetadataHolder *secondaryMeta) |
Sets a secondary search location. | |
virtual bool | hasMeta (const std::string &key, bool searchDefaults=true, bool searchSecondary=true) const |
Asks the MetadataHolder if it contains metadata of the specified key. | |
bool | hasFeature (const std::string &key) const |
Shortcut for hasMeta(key) and getMeta(key).getBoolValue(). | |
void | setFeature (const std::string &key) const |
Shortcut for setting a boolean metadata (true) under the specified key. | |
bool | hasSecondaryMetadataLocation () const |
Asks the MetadataHolder if the secondary metadata location was specified. | |
Metadata & | operator[] (const std::string &key) const |
A dictionary-like access to the metadata. | |
std::string | toString () const |
Returns a string representation of the metadata value. | |
Static Public Member Functions | |
static MetadataHolder & | getDefaultsMeta () |
Returns the solitary default MetadataHolder instance. | |
static bool | hasDefaultMeta (const std::string &key) |
Asks the default MetadataHolder instance if it contains metadata of the specified key. |
MetadataHolder can be used in a similar way as STL map container. It overrides the [] operator. Keys are string values, items are Metadata objects.
Other MetadataHolder instance can be attached using setSecondaryMetadataLocation() to provide a secondary search location for meatadata key lookup.
A global MetadataHolder instance called 'defaults' is searched if the requested metadata is not found in the current instance or in the secondary metadata location (if specified). This MetadataHolder instance can be obtained by calling the getDefaultsMeta() method.
If a metadata is requested, the default search order is:
Usage:
mholder[key] = "stringVal"; mholder[key].setStringValue("stringVal"); stringVal = mholder[key]; stringVal = mholder[key].getStringValue();
The class is not thread-safe.
const Metadata & iopc::MetadataHolder::getMeta | ( | const std::string & | key, | |
bool | searchDefaults = true , |
|||
bool | searchSecondary = true | |||
) | const [virtual] |
Returns Metadata of the specified key.
key | Key of the requested metadata | |
searchDefaults | Allows to skip the default metadata search | |
searchSecondary | Allows to skip the secondary location metadata search |
IopcIncorrectUsageException | if no metadata of such key is found |
Reimplemented in iopc::AdditionalMetadataHolder.
void iopc::MetadataHolder::setMeta | ( | const std::string & | key, | |
const Metadata & | value | |||
) | const |
Sets metadata for a specified key.
If specified metadata already exist, the metadata value is overwritten.
key | Metadata key | |
value | New metadata value |
void iopc::MetadataHolder::setSecondaryMetadataLocation | ( | const MetadataHolder * | secondaryMeta | ) |
Sets a secondary search location.
See the MetadataHolder description
bool iopc::MetadataHolder::hasMeta | ( | const std::string & | key, | |
bool | searchDefaults = true , |
|||
bool | searchSecondary = true | |||
) | const [virtual] |
Asks the MetadataHolder if it contains metadata of the specified key.
key | Key of the requested metadata | |
searchDefaults | Allows to skip the default metadata search | |
searchSecondary | Allows to skip the secondary location metadata search |
Reimplemented in iopc::AdditionalMetadataHolder.
Metadata& iopc::MetadataHolder::operator[] | ( | const std::string & | key | ) | const [inline] |
A dictionary-like access to the metadata.
This operator doesn't access the default values and secondary metadata location when looking up the metadata value!
string iopc::MetadataHolder::toString | ( | ) | const |
Returns a string representation of the metadata value.
Lists all Metadata::INT, Metadata::STRING and Metadata::BOOL values