| The Gaudi Framework v27r1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Classes | Public Member Functions | Private Attributes | List of all members
AIDA::Annotation Class Reference

Implementation of the AIDA IAnnotation interface class. More...

`#include <src/HistogramSvc/Annotation.h>`

Inheritance diagram for AIDA::Annotation:
[legend]
Collaboration diagram for AIDA::Annotation:
[legend]

## Classes
struct | AnnotationItem
| Internal private annotation item class. More...

## Public Member Functions
| Annotation ()=default
| Constructor. More...
| ~Annotation () override=default
| Destructor. More...
bool | addItem (const std::string &key, const std::string &value, bool sticky=false) override
| Add a key/value pair with a given sticky. More...
bool | removeItem (const std::string &key) override
| Remove the item indicated by a given key. More...
std::string | value (const std::string &key) const override
| Retrieve the value for a given key. More...
void | setValue (const std::string &key, const std::string &value) override
| Set value for a given key. More...
void | setSticky (const std::string &key, bool sticky) override
| Set sticky for a given key. More...
int | size () const override
| Get the number of items in the Annotation. More...
std::string | key (int index) const override
| Individual access to the Annotation-items. More...
std::string | value (int index) const override
void | reset () override
| Remove all the non-sticky items. More...

## Private Attributes
std::vector< AnnotationItem > | m_annotationItems
| The vector of the annotation items. More...
std::map< std::string, unsigned int > | m_identifiers
| The map of strings to identifiers. More...
std::string | emptyString

## Detailed Description

Implementation of the AIDA IAnnotation interface class.

Definition at line 18 of file Annotation.h.

## Constructor & Destructor Documentation

AIDA::Annotation::Annotation | ( |  | ) |
| default

Constructor.

AIDA::Annotation::~Annotation | ( |  | ) |
| override default

Destructor.

## Member Function Documentation

bool AIDA::Annotation::addItem | ( | const std::string & | key,
|  | const std::string & | value,
|  | bool | sticky = `false`
| ) |  |
| inline override

Add a key/value pair with a given sticky.

Definition at line 80 of file Annotation.h.

83 {
84 if ( m_identifiers.find( key ) != m_identifiers.end() ) return false;
85 m_annotationItems.emplace_back( key, value, sticky );
86 m_identifiers.emplace( key, m_annotationItems.size() - 1 );
87 return true;
88 }
AIDA::Annotation::m_identifiers
std::map< std::string, unsigned int > m_identifiers
The map of strings to identifiers.
Definition: Annotation.h:74
std::map::end
T end(T...args)
std::map::find
T find(T...args)
std::map::emplace
T emplace(T...args)
AIDA::Annotation::m_annotationItems
std::vector< AnnotationItem > m_annotationItems
The vector of the annotation items.
Definition: Annotation.h:71

std::string AIDA::Annotation::key | ( | int | index | ) | const
| inline override

Individual access to the Annotation-items.

Definition at line 141 of file Annotation.h.

142 {
143 if ( index < 0 || index >= static_cast<int>(m_annotationItems.size()) ) return emptyString;
144 return m_annotationItems[ index ].m_key;
145 }
AIDA::Annotation::emptyString
std::string emptyString
Definition: Annotation.h:76
AIDA::Annotation::m_annotationItems
std::vector< AnnotationItem > m_annotationItems
The vector of the annotation items.
Definition: Annotation.h:71

bool AIDA::Annotation::removeItem | ( | const std::string & | key | ) |
| inline override

Remove the item indicated by a given key.

Definition at line 90 of file Annotation.h.

90 {
91 auto iKey = m_identifiers.find( key );
92 if ( iKey == m_identifiers.end() ) return false;
93
94 unsigned int indexToBeRemoved = iKey->second;
95 // check stickness
96
97 if ( m_annotationItems[indexToBeRemoved].m_sticky ) return false;
98
99 // why rebuilding ?
100
101 m_identifiers.clear();
102 std::vector< AnnotationItem > annotationItemsNew;
103 if ( m_annotationItems.size() > 1 ) annotationItemsNew.reserve( m_annotationItems.size() - 1 );
104 for ( unsigned int iItem = 0; iItem < m_annotationItems.size(); ++iItem ) {
105 if ( iItem == indexToBeRemoved ) continue;
106 const auto& item = m_annotationItems[ iItem ];
107 annotationItemsNew.emplace_back( item.m_key, item.m_value, item.m_sticky );
108 m_identifiers.emplace( item.m_key, annotationItemsNew.size() - 1 );
109 }
110 m_annotationItems = std::move(annotationItemsNew);
111 return true;
112 }
AIDA::Annotation::m_identifiers
std::map< std::string, unsigned int > m_identifiers
The map of strings to identifiers.
Definition: Annotation.h:74
std::map::end
T end(T...args)
std::map::clear
T clear(T...args)
std::move
T move(T...args)
std::map::find
T find(T...args)
std::vector::size
T size(T...args)
std::vector
STL class.
std::map::emplace
T emplace(T...args)
ana.item
tuple item
print s1,s2
Definition: ana.py:146
AIDA::Annotation::m_annotationItems
std::vector< AnnotationItem > m_annotationItems
The vector of the annotation items.
Definition: Annotation.h:71
std::vector::reserve
T reserve(T...args)
std::vector::emplace_back
T emplace_back(T...args)

void AIDA::Annotation::reset | ( |  | ) |
| inline override

Remove all the non-sticky items.

Definition at line 153 of file Annotation.h.

154 {
155 // Collect the non-sticky items
156 std::vector< std::string > itemsToRemove;
157 itemsToRemove.reserve( size() );
158 for ( const auto& item : m_annotationItems ) {
159 if ( !item.m_sticky ) itemsToRemove.push_back( item.m_key );
160 }
161 for ( const auto& i : itemsToRemove ) removeItem(i);
162 }
AIDA::Annotation::size
int size() const override
Get the number of items in the Annotation.
Definition: Annotation.h:137
std::vector::push_back
T push_back(T...args)
std::vector< std::string >
ana.item
tuple item
print s1,s2
Definition: ana.py:146
ana.i
list i
Definition: ana.py:128
AIDA::Annotation::removeItem
bool removeItem(const std::string &key) override
Remove the item indicated by a given key.
Definition: Annotation.h:90
AIDA::Annotation::m_annotationItems
std::vector< AnnotationItem > m_annotationItems
The vector of the annotation items.
Definition: Annotation.h:71
std::vector::reserve
T reserve(T...args)

void AIDA::Annotation::setSticky | ( | const std::string & | key,
|  | bool | sticky
| ) |  |
| inline override

Set sticky for a given key.

Definition at line 131 of file Annotation.h.

132 {
133 auto iKey = m_identifiers.find( key );
134 if ( iKey != m_identifiers.end() ) m_annotationItems[ iKey->second ].m_sticky = sticky;
135 }
AIDA::Annotation::m_identifiers
std::map< std::string, unsigned int > m_identifiers
The map of strings to identifiers.
Definition: Annotation.h:74
std::map::end
T end(T...args)
std::map::find
T find(T...args)
AIDA::Annotation::m_annotationItems
std::vector< AnnotationItem > m_annotationItems
The vector of the annotation items.
Definition: Annotation.h:71

void AIDA::Annotation::setValue | ( | const std::string & | key,
|  | const std::string & | value
| ) |  |
| inline override

Set value for a given key.

Definition at line 121 of file Annotation.h.

122 {
123 auto iKey = m_identifiers.find( key );
124 if ( iKey == m_identifiers.end() )
125 // if not found, then add it
126 addItem(key,value);
127 else
128 m_annotationItems[ iKey->second ].m_value = value;
129 }
AIDA::Annotation::m_identifiers
std::map< std::string, unsigned int > m_identifiers
The map of strings to identifiers.
Definition: Annotation.h:74
std::map::end
T end(T...args)
AIDA::Annotation::addItem
bool addItem(const std::string &key, const std::string &value, bool sticky=false) override
Add a key/value pair with a given sticky.
Definition: Annotation.h:80
std::map::find
T find(T...args)
AIDA::Annotation::value
std::string value(const std::string &key) const override
Retrieve the value for a given key.
Definition: Annotation.h:114
AIDA::Annotation::m_annotationItems
std::vector< AnnotationItem > m_annotationItems
The vector of the annotation items.
Definition: Annotation.h:71

int AIDA::Annotation::size | ( |  | ) | const
| inline override

Get the number of items in the Annotation.

Definition at line 137 of file Annotation.h.

137 {
138 return m_annotationItems.size();
139 }
AIDA::Annotation::m_annotationItems
std::vector< AnnotationItem > m_annotationItems
The vector of the annotation items.
Definition: Annotation.h:71

std::string AIDA::Annotation::value | ( | const std::string & | key | ) | const
| inline override

Retrieve the value for a given key.

Definition at line 114 of file Annotation.h.

115 {
116 auto iKey = m_identifiers.find( key );
117 return iKey != m_identifiers.end() ? m_annotationItems[ iKey->second ].m_value
118 : emptyString;
119 }
AIDA::Annotation::m_identifiers
std::map< std::string, unsigned int > m_identifiers
The map of strings to identifiers.
Definition: Annotation.h:74
std::map::end
T end(T...args)
AIDA::Annotation::emptyString
std::string emptyString
Definition: Annotation.h:76
std::map::find
T find(T...args)
AIDA::Annotation::m_annotationItems
std::vector< AnnotationItem > m_annotationItems
The vector of the annotation items.
Definition: Annotation.h:71

std::string AIDA::Annotation::value | ( | int | index | ) | const
| inline override

Definition at line 147 of file Annotation.h.

148 {
149 if ( index < 0 || index >= static_cast<int>(m_annotationItems.size()) ) return emptyString;
150 return m_annotationItems[ index ].m_value;
151 }
AIDA::Annotation::emptyString
std::string emptyString
Definition: Annotation.h:76
AIDA::Annotation::m_annotationItems
std::vector< AnnotationItem > m_annotationItems
The vector of the annotation items.
Definition: Annotation.h:71

## Member Data Documentation

std::string AIDA::Annotation::emptyString
| private

Definition at line 76 of file Annotation.h.

std::vector< AnnotationItem > AIDA::Annotation::m_annotationItems
| private

The vector of the annotation items.

Definition at line 71 of file Annotation.h.

std::map< std::string, unsigned int > AIDA::Annotation::m_identifiers
| private

The map of strings to identifiers.

Definition at line 74 of file Annotation.h.

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

- GaudiCommonSvc/src/HistogramSvc/Annotation.h