|
Gaudi Framework, version v23r4 |
| Home | Generated: Mon Sep 17 2012 |
Implementation of the AIDA IAnnotation interface class. More...
#include <Annotation.h>


Classes | |
| class | AnnotationItem |
| Internal private annotation item class. More... | |
Public Member Functions | |
| Annotation () | |
| Constructor. | |
| virtual | ~Annotation () |
| Destructor. | |
| bool | addItem (const std::string &key, const std::string &value, bool sticky=false) |
| Add a key/value pair with a given sticky. | |
| bool | removeItem (const std::string &key) |
| Remove the item indicated by a given key. | |
| std::string | value (const std::string &key) const |
| Retrieve the value for a given key. | |
| void | setValue (const std::string &key, const std::string &value) |
| Set value for a given key. | |
| void | setSticky (const std::string &key, bool sticky) |
| Set sticky for a given key. | |
| int | size () const |
| Get the number of items in the Annotation. | |
| std::string | key (int index) const |
| Individual access to the Annotation-items. | |
| std::string | value (int index) const |
| void | reset () |
| Remove all the non-sticky items. | |
Private Attributes | |
| std::vector< AnnotationItem > | m_annotationItems |
| The vector of the annotation items. | |
| std::map< std::string, unsigned int > | m_identifiers |
| The map of strings to identifiers. | |
| std::string | emptyString |
Implementation of the AIDA IAnnotation interface class.
Definition at line 18 of file Annotation.h.
| AIDA::Annotation::Annotation | ( | ) | [inline] |
| virtual AIDA::Annotation::~Annotation | ( | ) | [inline, virtual] |
| bool AIDA::Annotation::addItem | ( | const std::string & | key, |
| const std::string & | value, | ||
| bool | sticky = false |
||
| ) | [inline] |
Add a key/value pair with a given sticky.
Definition at line 83 of file Annotation.h.
{
if ( m_identifiers.find( key ) != m_identifiers.end() ) return false;
m_annotationItems.push_back( AnnotationItem( key, value, sticky ) );
m_identifiers.insert( std::make_pair( key, m_annotationItems.size() - 1 ) );
return true;
}
| std::string AIDA::Annotation::key | ( | int | index ) | const [inline] |
Individual access to the Annotation-items.
Definition at line 145 of file Annotation.h.
{
if ( index < 0 || index >= static_cast<int>(m_annotationItems.size()) ) return emptyString;
return ( m_annotationItems[ index ] ).m_key;
}
| bool AIDA::Annotation::removeItem | ( | const std::string & | key ) | [inline] |
Remove the item indicated by a given key.
Definition at line 93 of file Annotation.h.
{
std::map< std::string, unsigned int >::const_iterator iKey = m_identifiers.find( key );
if ( iKey == m_identifiers.end() ) return false;
unsigned int indexToBeRemoved = iKey->second;
// check stickness
if ( m_annotationItems[indexToBeRemoved].m_sticky ) return false;
// why rebuilding ?
m_identifiers.clear();
std::vector< AnnotationItem > m_annotationItemsNew;
if ( m_annotationItems.size() > 1 ) m_annotationItemsNew.reserve( m_annotationItems.size() - 1 );
for ( unsigned int iItem = 0; iItem < m_annotationItems.size(); ++iItem ) {
if ( iItem == indexToBeRemoved ) continue;
const AnnotationItem& item = m_annotationItems[ iItem ];
m_annotationItemsNew.push_back( AnnotationItem( item.m_key, item.m_value, item.m_sticky ) );
m_identifiers.insert( std::make_pair( item.m_key, m_annotationItemsNew.size() - 1 ) );
}
m_annotationItems = m_annotationItemsNew;
return true;
}
| void AIDA::Annotation::reset | ( | ) | [inline] |
Remove all the non-sticky items.
Definition at line 157 of file Annotation.h.
{
// Collect the non-sticky items
std::vector< std::string > itemsToRemove;
itemsToRemove.reserve( size() );
for ( int item = 0; item < size(); ++item ) {
if ( ! ( m_annotationItems[ item ] ).m_sticky ) {
itemsToRemove.push_back( ( m_annotationItems[ item ] ).m_key );
}
}
for ( unsigned int i = 0; i < itemsToRemove.size(); ++i ) removeItem( itemsToRemove[i] );
}
| void AIDA::Annotation::setSticky | ( | const std::string & | key, |
| bool | sticky | ||
| ) | [inline] |
Set sticky for a given key.
Definition at line 134 of file Annotation.h.
{
std::map< std::string, unsigned int >::const_iterator iKey = m_identifiers.find( key );
if ( iKey == m_identifiers.end() ) return;
( m_annotationItems[ iKey->second ] ).m_sticky = sticky;
}
| void AIDA::Annotation::setValue | ( | const std::string & | key, |
| const std::string & | value | ||
| ) | [inline] |
Set value for a given key.
Definition at line 124 of file Annotation.h.
{
std::map< std::string, unsigned int >::const_iterator iKey = m_identifiers.find( key );
if ( iKey == m_identifiers.end() )
// not found then add it
addItem(key,value);
else
( m_annotationItems[ iKey->second ] ).m_value = value;
}
| int AIDA::Annotation::size | ( | ) | const [inline] |
Get the number of items in the Annotation.
Definition at line 141 of file Annotation.h.
{
return m_annotationItems.size();
}
| std::string AIDA::Annotation::value | ( | const std::string & | key ) | const [inline] |
Retrieve the value for a given key.
Definition at line 117 of file Annotation.h.
{
std::map< std::string, unsigned int >::const_iterator iKey = m_identifiers.find( key );
if ( iKey == m_identifiers.end() ) return emptyString;
return ( m_annotationItems[ iKey->second ] ).m_value;
}
| std::string AIDA::Annotation::value | ( | int | index ) | const [inline] |
Definition at line 151 of file Annotation.h.
{
if ( index < 0 || index >= static_cast<int>(m_annotationItems.size()) ) return emptyString;
return ( m_annotationItems[ index ] ).m_value;
}
std::string AIDA::Annotation::emptyString [private] |
Definition at line 79 of file Annotation.h.
std::vector< AnnotationItem > AIDA::Annotation::m_annotationItems [private] |
The vector of the annotation items.
Definition at line 74 of file Annotation.h.
std::map< std::string, unsigned int > AIDA::Annotation::m_identifiers [private] |
The map of strings to identifiers.
Definition at line 77 of file Annotation.h.