2 #ifndef GAUDISVC_ANNOTATION_H
3 #define GAUDISVC_ANNOTATION_H 1
12 #include "AIDA/IAnnotation.h"
29 const std::string &
value,
36 std::string
value(
const std::string &
key)
const;
40 const std::string&
value);
50 std::string
key(
int index)
const;
51 std::string
value(
int index)
const;
84 const std::string & value,
94 std::map< std::string, unsigned int >::const_iterator iKey = m_identifiers.find( key );
95 if ( iKey == m_identifiers.end() )
return false;
97 unsigned int indexToBeRemoved = iKey->second;
100 if ( m_annotationItems[indexToBeRemoved].m_sticky )
return false;
104 m_identifiers.clear();
105 std::vector< AnnotationItem > m_annotationItemsNew;
106 if ( m_annotationItems.size() > 1 ) m_annotationItemsNew.reserve( m_annotationItems.size() - 1 );
107 for (
unsigned int iItem = 0; iItem < m_annotationItems.size(); ++iItem ) {
108 if ( iItem == indexToBeRemoved )
continue;
111 m_identifiers.insert( std::make_pair( item.
m_key, m_annotationItemsNew.size() - 1 ) );
113 m_annotationItems = m_annotationItemsNew;
119 std::map< std::string, unsigned int >::const_iterator iKey = m_identifiers.find( key );
120 if ( iKey == m_identifiers.end() )
return emptyString;
121 return ( m_annotationItems[ iKey->second ] ).m_value;
126 std::map< std::string, unsigned int >::const_iterator iKey = m_identifiers.find( key );
127 if ( iKey == m_identifiers.end() )
131 ( m_annotationItems[ iKey->second ] ).m_value = value;
136 std::map< std::string, unsigned int >::const_iterator iKey = m_identifiers.find( key );
137 if ( iKey == m_identifiers.end() )
return;
138 ( m_annotationItems[ iKey->second ] ).m_sticky = sticky;
142 return m_annotationItems.size();
147 if ( index < 0 || index >= static_cast<int>(m_annotationItems.size()) )
return emptyString;
148 return ( m_annotationItems[ index ] ).m_key;
153 if ( index < 0 || index >= static_cast<int>(m_annotationItems.size()) )
return emptyString;
154 return ( m_annotationItems[ index ] ).m_value;
160 std::vector< std::string > itemsToRemove;
161 itemsToRemove.reserve( size() );
163 if ( ! ( m_annotationItems[
item ] ).m_sticky ) {
164 itemsToRemove.push_back( ( m_annotationItems[ item ] ).m_key );
168 for (
unsigned int i = 0;
i < itemsToRemove.size(); ++
i ) removeItem( itemsToRemove[
i] );