12 #ifndef GAUDISVC_ANNOTATION_H
13 #define GAUDISVC_ANNOTATION_H 1
20 #include "AIDA/IAnnotation.h"
45 int size()
const override;
52 void reset()
override;
85 auto iKey = m_identifiers.find(
key );
86 if ( iKey == m_identifiers.end() )
return false;
88 unsigned int indexToBeRemoved = iKey->second;
91 if ( m_annotationItems[indexToBeRemoved].m_sticky )
return false;
95 m_identifiers.clear();
97 if ( m_annotationItems.size() > 1 ) annotationItemsNew.
reserve( m_annotationItems.size() - 1 );
98 for (
unsigned int iItem = 0; iItem < m_annotationItems.size(); ++iItem ) {
99 if ( iItem == indexToBeRemoved )
continue;
100 const auto& item = m_annotationItems[iItem];
101 annotationItemsNew.
emplace_back( item.m_key, item.m_value, item.m_sticky );
102 m_identifiers.emplace( item.m_key, annotationItemsNew.
size() - 1 );
104 m_annotationItems =
std::move( annotationItemsNew );
109 auto iKey = m_identifiers.
find(
key );
110 return iKey != m_identifiers.end() ? m_annotationItems[iKey->second].m_value : emptyString;
114 auto iKey = m_identifiers.find(
key );
115 if ( iKey == m_identifiers.end() )
117 addItem(
key, value );
119 m_annotationItems[iKey->second].m_value = value;
123 auto iKey = m_identifiers.find(
key );
124 if ( iKey != m_identifiers.end() ) m_annotationItems[iKey->second].m_sticky = sticky;
130 if ( index < 0 || index >=
static_cast<int>( m_annotationItems.size() ) )
return emptyString;
131 return m_annotationItems[index].m_key;
135 if ( index < 0 || index >=
static_cast<int>( m_annotationItems.size() ) )
return emptyString;
136 return m_annotationItems[index].m_value;
143 for (
const auto& item : m_annotationItems ) {
144 if ( !item.m_sticky ) itemsToRemove.
push_back( item.m_key );
146 for (
const auto& i : itemsToRemove ) removeItem( i );