# saga::detail::attribute< Derived > Struct Template Reference

The SAGA attribute interface. More...

`#include <attribute.hpp>`

Inheritance diagram for saga::detail::attribute< Derived >:

[legend]

List of all members.

## Public Types
typedef std::vector< std::string > | strvec_type
| Attribute string vector type.
typedef std::map< std::string, std::string > | strmap_type
| Attribute string map type.
## Public Member Functions
std::string | get_attribute (std::string const &key) const
| Gets an attribute value.
void | set_attribute (std::string const &key, std::string const &value)
| Sets an attribute to a value.
strvec_type | get_vector_attribute (std::string const &key) const
| Gets the array of values associated with an attribute.
void | set_vector_attribute (std::string const &key, strvec_type const &value)
| Sets an attribute to an array of values.
void | remove_attribute (std::string const &key)
| Removes an attribute.
strvec_type | list_attributes () const
| Gets the list of attribute keys.
strvec_type | find_attributes (std::string const &pattern) const
| Finds matching attributes.
bool | attribute_exists (std::string const &key) const
| Checks if the attribute exists.
bool | attribute_is_readonly (std::string const &key) const
| Checks the attribute mode.
bool | attribute_is_writable (std::string const &key) const
| Checks the attribute mode.
bool | attribute_is_vector (std::string const &key) const
| Checks if it is vector.
bool | attribute_is_removable (std::string const &key) const
| Checks the attribute mode.

## Detailed Description

### template<typename Derived>
struct saga::detail::attribute< Derived >

The SAGA attribute interface.

Classes implementing this interface maintain a set of attributes. These attributes can be considered as a pair of string-based key-value pairs attached to the object. This interface provies methods for querying, adding, and removing attributes.
Usage example:
`saga::url lfn("rls://localhost//lfn.dat");
//logical_file implements the attribute interface
logical_file::logical_file lf (lfn);
`

`std::vector<std::string> keys(lf.list_attributes());
std::vector<std::string>::const_iterator end = keys.end();
std::vector<std::string>::const_iterator key_it = keys.begin();
`

`for(; key_it != end; ++key_it) { std::cout << lf.get_attribute(*key_it) << std::endl };`

``

## Member Typedef Documentation

template<typename Derived>

typedef std::vector<std::string> saga::detail::attribute< Derived >::strvec_type

Attribute string vector type.

template<typename Derived>

typedef std::map<std::string, std::string> saga::detail::attribute< Derived >::strmap_type

Attribute string map type.

## Member Function Documentation

template<typename Derived>

std::string saga::detail::attribute< Derived >::get_attribute | ( | std::string const & | key | ) | const`[inline]`

Gets an attribute value.

Parameters:

  | key | Attribute key name

Returns:
  String value of the attribute.

Referenced by saga::metric::fire(), saga::sd::service_description::get_related_services(), and saga::sd::service_description::get_url().

template<typename Derived>

void saga::detail::attribute< Derived >::set_attribute | ( | std::string const & | key,
|  | std::string const & | value |
| ) |  |  | `[inline]`

Sets an attribute to a value.

Parameters:

  | key | Attribute key name
  | value | String value to set the attribute to

Referenced by saga::sd::service_description::service_description().

template<typename Derived>

strvec_type saga::detail::attribute< Derived >::get_vector_attribute | ( | std::string const & | key | ) | const`[inline]`

Gets the array of values associated with an attribute.

Parameters:

  | key | Attribute key name

Returns:
  String array of attribute values

Referenced by saga::sd::service_description::get_related_services().

template<typename Derived>

void saga::detail::attribute< Derived >::set_vector_attribute | ( | std::string const & | key,
|  | strvec_type const & | value |
| ) |  |  | `[inline]`

Sets an attribute to an array of values.

Parameters:

  | key | Attribute key name
  | values | String array of attribute values

template<typename Derived>

void saga::detail::attribute< Derived >::remove_attribute | ( | std::string const & | key | ) | `[inline]`

Removes an attribute.

Parameters:

  | key | Attribute key to be removed

template<typename Derived>

strvec_type saga::detail::attribute< Derived >::list_attributes | ( |  | ) | const`[inline]`

Gets the list of attribute keys.

Returns:
  Existing attribute keys

template<typename Derived>

strvec_type saga::detail::attribute< Derived >::find_attributes | ( | std::string const & | pattern | ) | const`[inline]`

Finds matching attributes.

Parameters:

  | pattern | Key name search pattern

Returns:
  Matching attribute keys

template<typename Derived>

bool saga::detail::attribute< Derived >::attribute_exists | ( | std::string const & | key | ) | const`[inline]`

Checks if the attribute exists.

Parameters:

  | key | Attribute key name

Returns:
  true if the attribute exists, false otherwise

Referenced by saga::sd::service_description::get_related_services(), and saga::sd::service_description::get_url().

template<typename Derived>

bool saga::detail::attribute< Derived >::attribute_is_readonly | ( | std::string const & | key | ) | const`[inline]`

Checks the attribute mode.

Parameters:

  | key | Attribute key name.

Returns:
  true if the attribute is read-only, false otherwise

template<typename Derived>

bool saga::detail::attribute< Derived >::attribute_is_writable | ( | std::string const & | key | ) | const`[inline]`

Checks the attribute mode.

Parameters:

  | key | Attribute key name.

Returns:
  true if the attribute is writeable, false otherwise

template<typename Derived>

bool saga::detail::attribute< Derived >::attribute_is_vector | ( | std::string const & | key | ) | const`[inline]`

Checks if it is vector.

Parameters:

  | key | Attribute key name.

Returns:
  true if the attribute is a vector, false otherwise

template<typename Derived>

bool saga::detail::attribute< Derived >::attribute_is_removable | ( | std::string const & | key | ) | const`[inline]`

Checks the attribute mode.

Parameters:

  | key | Attribute key.

Returns:
  true if the attribute is removable, false otherwise

The documentation for this struct was generated from the following file:

- detail/attribute.hpp