Back to index

nordugrid-arc-nox  1.1.0~rc6
Public Member Functions | Protected Attributes
Arc::MessageAttributes Class Reference

A class for storage of attribute values. More...

#include <MessageAttributes.h>

Collaboration diagram for Arc::MessageAttributes:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 MessageAttributes ()
 The default constructor.
void set (const std::string &key, const std::string &value)
 Sets a unique value of an attribute.
void add (const std::string &key, const std::string &value)
 Adds a value to an attribute.
void removeAll (const std::string &key)
 Removes all attributes with a certain key.
void remove (const std::string &key, const std::string &value)
 Removes one value of an attribute.
int count (const std::string &key) const
 Returns the number of values of an attribute.
const std::string & get (const std::string &key) const
 Returns the value of a single-valued attribute.
AttributeIterator getAll (const std::string &key) const
 Access the value(s) of an attribute.
AttributeIterator getAll (void) const
 Access all value and attributes.

Protected Attributes

AttrMap attributes_
 Internal storage of attributes.

Detailed Description

A class for storage of attribute values.

This class is used to store attributes of messages. All attribute keys and their corresponding values are stored as strings. Any key or value that is not a string must thus be represented as a string during storage. Furthermore, an attribute is usually a key-value pair with a unique key, but there may also be multiple such pairs with equal keys.

The key of an attribute is composed by the name of the Message Chain Component (MCC) which produce it and the name of the attribute itself with a colon (:) in between, i.e. MCC_Name:Attribute_Name. For example, the key of the "Content-Length" attribute of the HTTP MCC is thus "HTTP:Content-Length".

There are also "global attributes", which may be produced by different MCCs depending on the configuration. The keys of such attributes are NOT prefixed by the name of the producing MCC. Before any new global attribute is introduced, it must be agreed upon by the core development team and added below. The global attributes decided so far are:

Definition at line 168 of file MessageAttributes.h.


Constructor & Destructor Documentation

The default constructor.

This is the default constructor of the MessageAttributes class. It constructs an empty object that initially contains no attributes.

Definition at line 45 of file MessageAttributes.cpp.

                                       {
  }

Member Function Documentation

void Arc::MessageAttributes::add ( const std::string &  key,
const std::string &  value 
)

Adds a value to an attribute.

This method adds a new value to an attribute. Any previous value will be preserved, i.e. the attribute may become multiple valued.

Parameters:
keyThe key of the attribute.
valueThe (new) value of the attribute.

Definition at line 54 of file MessageAttributes.cpp.

                                                   {
    attributes_.insert(make_pair(key, value));
  }

Here is the caller graph for this function:

int Arc::MessageAttributes::count ( const std::string &  key) const

Returns the number of values of an attribute.

Returns the number of values of an attribute that matches a certain key.

Parameters:
keyThe key of the attribute for which to count values.
Returns:
The number of values that corresponds to the key.

Definition at line 72 of file MessageAttributes.cpp.

                                                         {
    return attributes_.count(key);
  }

Here is the caller graph for this function:

const std::string & Arc::MessageAttributes::get ( const std::string &  key) const

Returns the value of a single-valued attribute.

This method returns the value of a single-valued attribute. If the attribute is not single valued (i.e. there is no such attribute or it is a multiple-valued attribute) an empty string is returned.

Parameters:
keyThe key of the attribute for which to return the value.
Returns:
The value of the attribute.

Definition at line 76 of file MessageAttributes.cpp.

                                                                    {
    static std::string emptyString="";
    if (count(key)==1)
      return attributes_.find(key)->second;
    else
      return emptyString; // Throw an exception?
  }

Here is the call graph for this function:

Here is the caller graph for this function:

AttributeIterator Arc::MessageAttributes::getAll ( const std::string &  key) const

Access the value(s) of an attribute.

This method returns an AttributeIterator that can be used to access the values of an attribute.

Parameters:
keyThe key of the attribute for which to return the values.
Returns:
An AttributeIterator for access of the values of the attribute.

Definition at line 84 of file MessageAttributes.cpp.

                                                                        {
    return AttributeIterator(attributes_.lower_bound(key),
                          attributes_.upper_bound(key));
  }

Here is the caller graph for this function:

Access all value and attributes.

Definition at line 89 of file MessageAttributes.cpp.

                                                        {
    return AttributeIterator(attributes_.begin(),
                          attributes_.end());
  }
void Arc::MessageAttributes::remove ( const std::string &  key,
const std::string &  value 
)

Removes one value of an attribute.

This method removes a certain value from the attribute that matches a certain key.

Parameters:
keyThe key of the attribute from which the value shall be removed.
valueThe value to remove.

Definition at line 63 of file MessageAttributes.cpp.

                                                     {
    AttrIter begin = attributes_.lower_bound(key);
    AttrIter end   = attributes_.upper_bound(key);
    for (AttrIter i=begin; i!=end; i++)
      if (i->second==value)
       attributes_.erase(i);
  }
void Arc::MessageAttributes::removeAll ( const std::string &  key)

Removes all attributes with a certain key.

This method removes all attributes that match a certain key.

Parameters:
keyThe key of the attributes to remove.

Definition at line 59 of file MessageAttributes.cpp.

                                                        {
    attributes_.erase(key);
  }

Here is the caller graph for this function:

void Arc::MessageAttributes::set ( const std::string &  key,
const std::string &  value 
)

Sets a unique value of an attribute.

This method removes any previous value of an attribute and sets the new value as the only value.

Parameters:
keyThe key of the attribute.
valueThe (new) value of the attribute.

Definition at line 48 of file MessageAttributes.cpp.

                                                   {
    removeAll(key);
    add(key, value);
  }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Internal storage of attributes.

An AttrMap (multimap) in which all attributes (key-value pairs) are stored.

Definition at line 248 of file MessageAttributes.h.


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