iopc::MetadataHolder Class Reference
[iopccommon]

A dictionary-like container class used for class metadata storage. More...

#include <metadataHolder.h>

Inheritance diagram for iopc::MetadataHolder:

Inheritance graph
[legend]

List of all members.

Public Member Functions

virtual const MetadatagetMeta (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.
Metadataoperator[] (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 MetadataHoldergetDefaultsMeta ()
 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.


Detailed Description

A dictionary-like container class used for class metadata storage.

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:

  1. Current MetadataHolder instance
  2. Secondary metadata location specified by the setSecondaryMetadataLocation() method
  3. Default metadata location in getDefaultsMeta()

Usage:

 mholder[key] = "stringVal";
 mholder[key].setStringValue("stringVal");
 stringVal = mholder[key];
 stringVal = mholder[key].getStringValue();

The class is not thread-safe.

See also:
Metadata

Member Function Documentation

const Metadata & iopc::MetadataHolder::getMeta ( const std::string &  key,
bool  searchDefaults = true,
bool  searchSecondary = true 
) const [virtual]

Returns Metadata of the specified key.

Parameters:
key Key of the requested metadata
searchDefaults Allows to skip the default metadata search
searchSecondary Allows to skip the secondary location metadata search
Returns:
A Metadata instance found under the specified key
Exceptions:
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.

Parameters:
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.

Parameters:
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


The documentation for this class was generated from the following files:

Generated on Tue Apr 14 16:46:35 2009 for IOPC 2 by  doxygen 1.5.6