| The Gaudi Framework v32r1 (f65d50dc)

Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
Containers::KeyedObjectManager< SETUP > Class Template Reference

KeyedObjectManager Class to manage keyed objects. More...

`#include <GaudiKernel/KeyedObjectManager.h>`

Collaboration diagram for Containers::KeyedObjectManager< SETUP >:
[legend]

## Public Member Functions
| KeyedObjectManager ()
| Standard Constructor. More...
| KeyedObjectManager (KeyedObjectManager &&other)
virtual | ~KeyedObjectManager ()
| Standard Destructor. More...
void | clearDirect ()
| Clear all direct access fields. More...
long | insertDirect (ObjectContainerBase *b, ContainedObject *c, void *o, long k)
| Insert element into direct access map. More...
long | isDirect () const
| Check if the container is dirty. More...
void * | object (long key) const
| Retrieve object identified by a key from the container. More...
long | insert (ObjectContainerBase *b, ContainedObject *c, void *o, long *k)
| Insert new object into container. More...
long | insert (ObjectContainerBase *b, ContainedObject *c, void *o, long k)
| Insert new object into container. More...
void * | erase (long key, const void *obj)
| Remove object from container (very inefficient if key is invalid) More...
long | erase (seq_type::iterator beg, seq_type::iterator end)
| Remove object by sequential iterators. More...
void | reserve (long size)
| Reserve buffer space. More...
void | clear ()
| Clear content of the vector. More...
void | setup (void *seq, void **rndm)
| Setup of the Map and the parent object. More...
template<>
CLID | classID ()
template<>
CLID | classID ()
template<>
void * | object (long value) const
template<>
long | insert (ObjectContainerBase *b, ContainedObject *c, void *o, long *k)
template<>
long | insert (ObjectContainerBase *b, ContainedObject *c, void *o, long k)
template<>
long | insertDirect (ObjectContainerBase *b, ContainedObject *c, void *o, long k)
template<>
void | clearDirect ()
template<>
void * | erase (long key, const void *obj)
template<>
long | erase (seq_type::iterator beg, seq_type::iterator end)
template<>
CLID | classID ()
template<>
void * | object (long) const
template<>
long | insert (ObjectContainerBase *b, ContainedObject *c, void *o, long *k)
template<>
long | insert (ObjectContainerBase *b, ContainedObject *c, void *o, long k)
template<>
long | insertDirect (ObjectContainerBase *b, ContainedObject *c, void *o, long k)
template<>
void | clearDirect ()
template<>
void * | erase (long, const void *)
template<>
long | erase (seq_type::iterator beg, seq_type::iterator end)
template<>
CLID | classID ()

## Static Public Member Functions
static CLID | classID ()
| Access CLID for this type of container. More...

## Private Types
typedef std::vector< void * > | seq_type

## Private Member Functions
void | onDirty () const
| Callback when the container becomes dirty. More...
template<>
void | onDirty () const
template<>
void | onDirty () const

## Private Attributes
seq_type * | m_seq
| Container holding array like container. More...
long | m_direct
| Dirty flag. More...
long | m_keyCtxt
union {
char buffer [128]
| Buffer space to hold keyed container. More...
SETUP * s
} | m_setup

## Detailed Description

### template<class SETUP>
class Containers::KeyedObjectManager< SETUP >

KeyedObjectManager Class to manage keyed objects.

Object manager class.

This class is instantiated for two container types: map and hashmap. Other types are possible, but currently not supported. Other implementations may be achieved by specializing the SETUP class.

As an example below the specialization for a vector like implementation is shown.

Author
  M.Frank CERN/LHCb

Version
  1.0

Definition at line 45 of file KeyedObjectManager.h.

## Member Typedef Documentation

## ◆ seq_type

template<class SETUP >

typedef std::vector<void*> Containers::KeyedObjectManager< SETUP >::seq_type
| private

Definition at line 47 of file KeyedObjectManager.h.

## Constructor & Destructor Documentation

## ◆ KeyedObjectManager() [1/2]

template<class T >

Containers::KeyedObjectManager< T >::KeyedObjectManager | ( |  | ) |

Standard Constructor.

Definition at line 88 of file KeyedObjectManager.cpp.

88 : m_seq( nullptr ), m_direct( 0 ) {
89 if ( sizeof( typename T::map_type ) > sizeof( m_setup.buffer ) ) {
90 throw GaudiException( "Basic STL contaier sizes are incompatible", "KeyedContainer", StatusCode::FAILURE );
91 }
92 m_setup.s = ::new ( m_setup.buffer + sizeof( m_setup.s ) ) T();
93 m_keyCtxt = -1;
94 }
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:21
Containers::KeyedObjectManager::m_keyCtxt
long m_keyCtxt
Definition: KeyedObjectManager.h:52
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:86
Containers::KeyedObjectManager::m_direct
long m_direct
Dirty flag.
Definition: KeyedObjectManager.h:51
Containers::KeyedObjectManager::m_seq
seq_type * m_seq
Container holding array like container.
Definition: KeyedObjectManager.h:49
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@2 m_setup

## ◆ KeyedObjectManager() [2/2]

template<class T >

Containers::KeyedObjectManager< T >::KeyedObjectManager | ( | KeyedObjectManager< SETUP > && | other | ) |

Definition at line 97 of file KeyedObjectManager.cpp.

98 : m_seq( nullptr ), m_direct( other.m_direct ), m_keyCtxt( other.m_keyCtxt ) {
99 m_setup.s = ::new ( m_setup.buffer + sizeof( m_setup.s ) ) T( std::move( *other.m_setup.s ) );
100
101 other.m_keyCtxt = -1;
102 other.m_seq = nullptr;
103 other.m_direct = 0;
104 }
std
STL namespace.
Containers::KeyedObjectManager::s
SETUP * s
Definition: KeyedObjectManager.h:56
Containers::KeyedObjectManager::m_keyCtxt
long m_keyCtxt
Definition: KeyedObjectManager.h:52
Containers::KeyedObjectManager::m_direct
long m_direct
Dirty flag.
Definition: KeyedObjectManager.h:51
Containers::KeyedObjectManager::m_seq
seq_type * m_seq
Container holding array like container.
Definition: KeyedObjectManager.h:49
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@2 m_setup

## ◆ ~KeyedObjectManager()

template<class T >

Containers::KeyedObjectManager< T >::~KeyedObjectManager | ( |  | ) |
| virtual

Standard Destructor.

Definition at line 107 of file KeyedObjectManager.cpp.

107 {
108 m_setup.s->~T();
109 }
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@2 m_setup

## Member Function Documentation

## ◆ classID() [1/5]

template<class SETUP >

static CLID Containers::KeyedObjectManager< SETUP >::classID | ( |  | ) |
| static

Access CLID for this type of container.

## ◆ classID() [2/5]

template<>

CLID Containers::KeyedObjectManager< Containers::map >::classID | ( |  | ) |

Definition at line 283 of file KeyedObjectManager.cpp.

283 {
284 return CLID_ObjectVector + 0x00030000;
285 }

## ◆ classID() [3/5]

template<>

CLID Containers::KeyedObjectManager< Containers::hashmap >::classID | ( |  | ) |

Definition at line 287 of file KeyedObjectManager.cpp.

287 {
288 return CLID_ObjectVector + 0x00040000;
289 }

## ◆ classID() [4/5]

template<>

CLID Containers::KeyedObjectManager< __A >::classID | ( |  | ) |

Definition at line 477 of file KeyedObjectManager.cpp.

477 {
478 return CLID_ObjectVector + 0x00050000;
479 }

## ◆ classID() [5/5]

template<>

CLID Containers::KeyedObjectManager< __V >::classID | ( |  | ) |

Definition at line 561 of file KeyedObjectManager.cpp.

561 {
562 return CLID_ObjectVector + 0x00060000;
563 }

## ◆ clear()

template<class T >

void Containers::KeyedObjectManager< T >::clear | ( |  | ) |

Clear content of the vector.

Definition at line 230 of file KeyedObjectManager.cpp.

230 {
231 clearDirect();
232 m_seq->clear();
233 }
Containers::KeyedObjectManager::clearDirect
void clearDirect()
Clear all direct access fields.
Definition: KeyedObjectManager.cpp:236
std::vector::clear
T clear(T... args)
Containers::KeyedObjectManager::m_seq
seq_type * m_seq
Container holding array like container.
Definition: KeyedObjectManager.h:49

## ◆ clearDirect() [1/3]

template<class T >

void Containers::KeyedObjectManager< T >::clearDirect | ( |  | ) |

Clear all direct access fields.

Definition at line 236 of file KeyedObjectManager.cpp.

236 {
237 switch ( m_direct ) {
238 case 1:
239 m_setup.s->m.clear();
240 break;
241 case 0:
242 m_setup.s->v.clear();
243 break;
244 default:
245 break;
246 }
247 m_direct = 0;
248 m_keyCtxt = -1;
249 }
Containers::KeyedObjectManager::m_keyCtxt
long m_keyCtxt
Definition: KeyedObjectManager.h:52
Containers::KeyedObjectManager::m_direct
long m_direct
Dirty flag.
Definition: KeyedObjectManager.h:51
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@2 m_setup

## ◆ clearDirect() [2/3]

template<>

void Containers::KeyedObjectManager< __A >::clearDirect | ( |  | ) |

Definition at line 399 of file KeyedObjectManager.cpp.

399 {
400 m_setup.s->v.clear();
401 m_setup.s->m_idx.clear();
402 m_direct = 0;
403 m_keyCtxt = -1;
404 }
Containers::KeyedObjectManager::m_keyCtxt
long m_keyCtxt
Definition: KeyedObjectManager.h:52
Containers::KeyedObjectManager::m_direct
long m_direct
Dirty flag.
Definition: KeyedObjectManager.h:51
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@2 m_setup

## ◆ clearDirect() [3/3]

template<>

void Containers::KeyedObjectManager< __V >::clearDirect | ( |  | ) |

Definition at line 536 of file KeyedObjectManager.cpp.

536 {
537 m_setup.s->v.clear();
538 m_direct = 0;
539 m_keyCtxt = -1;
540 }
Containers::KeyedObjectManager::m_keyCtxt
long m_keyCtxt
Definition: KeyedObjectManager.h:52
Containers::KeyedObjectManager::m_direct
long m_direct
Dirty flag.
Definition: KeyedObjectManager.h:51
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@2 m_setup

## ◆ erase() [1/6]

template<class T >

void * Containers::KeyedObjectManager< T >::erase | ( | long | key,
|  | const void * | obj
| ) |  |

Remove object from container (very inefficient if key is invalid)

Definition at line 186 of file KeyedObjectManager.cpp.

186 {
187 typedef typename T::map_type MTYP;
188 typedef find<MTYP> FND;
189 if ( 1 == m_direct ) {
190 auto& m = m_setup.s->m;
191 auto i = ( obj ? std::find_if( m.begin(), m.end(), FND( obj ) ) : m_setup.s->m.find( key ) );
192 if ( i != m_setup.s->m.end() ) {
193 void* o = i->second;
194 auto j = std::find( m_seq->begin(), m_seq->end(), o );
195 if ( j != m_seq->end() ) {
196 m_seq->erase( j );
197 m_setup.s->m.erase( i );
198 return o;
199 }
200 }
201 containerIsInconsistent();
202 }
203 onDirty();
204 return erase( key, obj );
205 }
Containers::containerIsInconsistent
GAUDI_API void containerIsInconsistent()
Function to be called to indicate that the container is found to be inconsistent.
Definition: KeyedObjectManager.cpp:77
std::vector::end
T end(T... args)
Containers::KeyedObjectManager::erase
void * erase(long key, const void *obj)
Remove object from container (very inefficient if key is invalid)
Definition: KeyedObjectManager.cpp:186
Containers::KeyedObjectManager::onDirty
void onDirty() const
Callback when the container becomes dirty.
Definition: KeyedObjectManager.cpp:119
Gaudi::Units::m
constexpr double m
Definition: SystemOfUnits.h:92
std::vector::erase
T erase(T... args)
std::find_if
T find_if(T... args)
std::vector::begin
T begin(T... args)
Containers::KeyedObjectManager::m_direct
long m_direct
Dirty flag.
Definition: KeyedObjectManager.h:51
Containers::KeyedObjectManager::m_seq
seq_type * m_seq
Container holding array like container.
Definition: KeyedObjectManager.h:49
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@2 m_setup

## ◆ erase() [2/6]

template<class T >

long Containers::KeyedObjectManager< T >::erase | ( | seq_type::iterator | beg,
|  | seq_type::iterator | end
| ) |  |

Remove object by sequential iterators.

Definition at line 253 of file KeyedObjectManager.cpp.

253 {
254 typedef typename T::map_type MTYP;
255 typedef find<MTYP> FND;
256 if ( 0 == m_direct ) {
257 onDirty();
258 return erase( beg, end );
259 }
260 if ( beg == m_seq->begin() && end == m_seq->end() ) {
261 clear();
262 } else {
263 for ( auto j = beg; j != end; ++j ) {
264 // auto& m = m_setup.s->m;
265 auto i = std::find_if( m_setup.s->m.begin(), m_setup.s->m.end(), FND( *j ) );
266 if ( i != m_setup.s->m.end() ) {
267 m_setup.s->m.erase( i );
268 continue;
269 }
270 containerIsInconsistent();
271 }
272 m_seq->erase( beg, end );
273 }
274 return OBJ_ERASED;
275 }
Containers::KeyedObjectManager::clear
void clear()
Clear content of the vector.
Definition: KeyedObjectManager.cpp:230
Containers::containerIsInconsistent
GAUDI_API void containerIsInconsistent()
Function to be called to indicate that the container is found to be inconsistent.
Definition: KeyedObjectManager.cpp:77
std::vector::end
T end(T... args)
Containers::KeyedObjectManager::erase
void * erase(long key, const void *obj)
Remove object from container (very inefficient if key is invalid)
Definition: KeyedObjectManager.cpp:186
Containers::KeyedObjectManager::onDirty
void onDirty() const
Callback when the container becomes dirty.
Definition: KeyedObjectManager.cpp:119
std::vector::erase
T erase(T... args)
Containers::OBJ_ERASED
Object was removed, but not deleted.
Definition: KeyedTraits.h:25
IOTest.end
def end
Definition: IOTest.py:112
std::find_if
T find_if(T... args)
std::vector::begin
T begin(T... args)
Containers::KeyedObjectManager::m_direct
long m_direct
Dirty flag.
Definition: KeyedObjectManager.h:51
Containers::KeyedObjectManager::m_seq
seq_type * m_seq
Container holding array like container.
Definition: KeyedObjectManager.h:49
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@2 m_setup

## ◆ erase() [3/6]

template<>

void * Containers::KeyedObjectManager< __A >::erase | ( | long | key,
|  | const void * | obj
| ) |  |

Definition at line 408 of file KeyedObjectManager.cpp.

408 {
409 if ( 0 == m_direct ) {
410 onDirty();
411 return erase( key, obj );
412 }
413 if ( obj ) {
414 auto& idx = m_setup.s->m_idx;
415 for ( auto& elem : idx ) {
416 auto j = m_setup.s->v.begin() + ( elem );
417 auto k = std::find( m_seq->begin(), m_seq->end(), *j );
418 if ( *j == obj ) {
419 void* o = *j;
420 m_seq->erase( k );
421 m_setup.s->v.erase( j );
422 std::for_each( m_setup.s->m_idx.begin(), m_setup.s->m_idx.end(), array::decrement( elem ) );
423 elem = -1;
424 return o;
425 }
426 }
427 } else if ( key >= 0 && key < long( m_setup.s->m_idx.size() ) ) {
428 auto idx = m_setup.s->m_idx.begin() + key;
429 if ( *idx != -1 ) {
430 auto i = m_setup.s->v.begin() + ( *idx );
431 if ( i == m_setup.s->v.end() ) { containerIsInconsistent(); }
432 void* o = *i;
433 auto j = std::find( m_seq->begin(), m_seq->end(), o );
434 if ( j == m_seq->end() ) { containerIsInconsistent(); }
435 m_seq->erase( j );
436 m_setup.s->v.erase( i );
437 std::for_each( m_setup.s->m_idx.begin(), m_setup.s->m_idx.end(), array::decrement( *idx ) );
438 *idx = -1;
439 return o;
440 }
441 }
442 containerIsInconsistent();
443 return nullptr;
444 }
Containers::containerIsInconsistent
GAUDI_API void containerIsInconsistent()
Function to be called to indicate that the container is found to be inconsistent.
Definition: KeyedObjectManager.cpp:77
std::vector::end
T end(T... args)
Containers::KeyedObjectManager::erase
void * erase(long key, const void *obj)
Remove object from container (very inefficient if key is invalid)
Definition: KeyedObjectManager.cpp:186
Containers::KeyedObjectManager::onDirty
void onDirty() const
Callback when the container becomes dirty.
Definition: KeyedObjectManager.cpp:119
std::vector::erase
T erase(T... args)
std::find
T find(T... args)
std::vector::begin
T begin(T... args)
std::for_each
T for_each(T... args)
Containers::KeyedObjectManager::m_direct
long m_direct
Dirty flag.
Definition: KeyedObjectManager.h:51
Containers::KeyedObjectManager::m_seq
seq_type * m_seq
Container holding array like container.
Definition: KeyedObjectManager.h:49
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@2 m_setup

## ◆ erase() [4/6]

template<>

long Containers::KeyedObjectManager< __A >::erase | ( | seq_type::iterator | beg,
|  | seq_type::iterator | end
| ) |  |

Definition at line 448 of file KeyedObjectManager.cpp.

448 {
449 if ( beg == m_seq->begin() && end == m_seq->end() ) {
450 clear();
451 return OBJ_ERASED;
452 } else if ( 0 == m_direct ) {
453 onDirty();
454 return erase( beg, end );
455 } else {
456 long cnt = 0, nobj = end - beg;
457 auto& idx = m_setup.s->m_idx;
458 for ( auto& elem : idx ) {
459 auto j = m_setup.s->v.begin() + ( elem );
460 auto k = std::find( beg, end, *j );
461 if ( k != end ) {
462 m_setup.s->v.erase( j );
463 std::for_each( m_setup.s->m_idx.begin(), m_setup.s->m_idx.end(), array::decrement( elem ) );
464 elem = -1;
465 cnt++;
466 if ( cnt == nobj ) break;
467 }
468 }
469 m_seq->erase( beg, end );
470 if ( cnt != nobj ) { containerIsInconsistent(); }
471 return OBJ_ERASED;
472 }
473 // cannot reach this point
474 }
Containers::KeyedObjectManager::clear
void clear()
Clear content of the vector.
Definition: KeyedObjectManager.cpp:230
Containers::containerIsInconsistent
GAUDI_API void containerIsInconsistent()
Function to be called to indicate that the container is found to be inconsistent.
Definition: KeyedObjectManager.cpp:77
std::vector::end
T end(T... args)
Containers::KeyedObjectManager::erase
void * erase(long key, const void *obj)
Remove object from container (very inefficient if key is invalid)
Definition: KeyedObjectManager.cpp:186
Containers::KeyedObjectManager::onDirty
void onDirty() const
Callback when the container becomes dirty.
Definition: KeyedObjectManager.cpp:119
std::vector::erase
T erase(T... args)
Containers::OBJ_ERASED
Object was removed, but not deleted.
Definition: KeyedTraits.h:25
IOTest.end
def end
Definition: IOTest.py:112
std::find
T find(T... args)
std::vector::begin
T begin(T... args)
std::for_each
T for_each(T... args)
Containers::KeyedObjectManager::m_direct
long m_direct
Dirty flag.
Definition: KeyedObjectManager.h:51
Containers::KeyedObjectManager::m_seq
seq_type * m_seq
Container holding array like container.
Definition: KeyedObjectManager.h:49
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@2 m_setup

## ◆ erase() [5/6]

template<>

void * Containers::KeyedObjectManager< __V >::erase | ( | long | ,
|  | const void * |
| ) |  |

Definition at line 544 of file KeyedObjectManager.cpp.

544 {
545 invalidContainerOperation();
546 return nullptr;
547 }
Containers::invalidContainerOperation
GAUDI_API void invalidContainerOperation()
Function to be called to indicate that an operation should be performed on the container or it's cont...
Definition: KeyedObjectManager.cpp:82

## ◆ erase() [6/6]

template<>

long Containers::KeyedObjectManager< __V >::erase | ( | seq_type::iterator | beg,
|  | seq_type::iterator | end
| ) |  |

Definition at line 551 of file KeyedObjectManager.cpp.

551 {
552 if ( beg == m_seq->begin() && end == m_seq->end() ) {
553 clear();
554 return OBJ_ERASED;
555 }
556 invalidContainerOperation();
557 return OBJ_ERASED;
558 }
Containers::KeyedObjectManager::clear
void clear()
Clear content of the vector.
Definition: KeyedObjectManager.cpp:230
std::vector::end
T end(T... args)
Containers::invalidContainerOperation
GAUDI_API void invalidContainerOperation()
Function to be called to indicate that an operation should be performed on the container or it's cont...
Definition: KeyedObjectManager.cpp:82
Containers::OBJ_ERASED
Object was removed, but not deleted.
Definition: KeyedTraits.h:25
IOTest.end
def end
Definition: IOTest.py:112
std::vector::begin
T begin(T... args)
Containers::KeyedObjectManager::m_seq
seq_type * m_seq
Container holding array like container.
Definition: KeyedObjectManager.h:49

## ◆ insert() [1/6]

template<class T >

long Containers::KeyedObjectManager< T >::insert | ( | ObjectContainerBase * | b,
|  | ContainedObject * | c,
|  | void * | o,
|  | long * | k
| ) |  |

Insert new object into container.

Definition at line 128 of file KeyedObjectManager.cpp.

129 {
130 *key = ++m_keyCtxt;
131 return insert( pBase, pObject, obj, *key );
132 }
Containers::KeyedObjectManager::m_keyCtxt
long m_keyCtxt
Definition: KeyedObjectManager.h:52
Containers::KeyedObjectManager::insert
long insert(ObjectContainerBase *b, ContainedObject *c, void *o, long *k)
Insert new object into container.
Definition: KeyedObjectManager.cpp:128

## ◆ insert() [2/6]

template<class T >

long Containers::KeyedObjectManager< T >::insert | ( | ObjectContainerBase * | b,
|  | ContainedObject * | c,
|  | void * | o,
|  | long | k
| ) |  |

Insert new object into container.

Keep major key value

Definition at line 135 of file KeyedObjectManager.cpp.

136 {
138 if ( key > m_keyCtxt ) { m_keyCtxt = key; }
139 if ( 1 == m_direct ) {
140 if ( m_setup.s->insert( obj, key ) ) {
141 if ( !pObject->parent() ) { pObject->setParent( pBase ); }
142 m_seq->push_back( obj );
143 return OBJ_INSERTED;
144 }
145 } else if ( key == long( m_setup.s->v.size() ) ) {
146 m_setup.s->v.push_back( obj );
147 if ( !pObject->parent() ) { pObject->setParent( pBase ); }
148 m_seq->push_back( obj );
149 return OBJ_INSERTED;
150 } else {
151 // Document is dirty now...
152 // need to copy all pointers from the vector to the map
153 onDirty();
154 return insert( pBase, pObject, obj, key );
155 }
156 cannotInsertToContainer();
157 return OBJ_CANNOT_INSERT;
158 }
Containers::OBJ_INSERTED
Object was inserted into the container.
Definition: KeyedTraits.h:26
Containers::cannotInsertToContainer
GAUDI_API void cannotInsertToContainer()
Function to be called to indicate that an object cannot be inserted to the container.
Definition: KeyedObjectManager.cpp:73
Containers::KeyedObjectManager::onDirty
void onDirty() const
Callback when the container becomes dirty.
Definition: KeyedObjectManager.cpp:119
std::vector::push_back
T push_back(T... args)
Containers::KeyedObjectManager::m_keyCtxt
long m_keyCtxt
Definition: KeyedObjectManager.h:52
Containers::KeyedObjectManager::insert
long insert(ObjectContainerBase *b, ContainedObject *c, void *o, long *k)
Insert new object into container.
Definition: KeyedObjectManager.cpp:128
Containers::OBJ_CANNOT_INSERT
Cannot insert object into container.
Definition: KeyedTraits.h:27
Containers::KeyedObjectManager::m_direct
long m_direct
Dirty flag.
Definition: KeyedObjectManager.h:51
Containers::KeyedObjectManager::m_seq
seq_type * m_seq
Container holding array like container.
Definition: KeyedObjectManager.h:49
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@2 m_setup

## ◆ insert() [3/6]

template<>

long Containers::KeyedObjectManager< __A >::insert | ( | ObjectContainerBase * | b,
|  | ContainedObject * | c,
|  | void * | o,
|  | long * | k
| ) |  |

Definition at line 332 of file KeyedObjectManager.cpp.

332 {
333 // auto key creation only possible for direct access!
334 if ( 0 == m_direct ) {
335 m_seq->push_back( o );
336 m_setup.s->v.push_back( o );
337 if ( !c->parent() ) c->setParent( b );
338 *k = ++m_keyCtxt;
339 return OBJ_INSERTED;
340 }
341 cannotInsertToContainer();
342 return OBJ_CANNOT_INSERT;
343 }
gaudirun.c
c
Definition: gaudirun.py:487
Containers::OBJ_INSERTED
Object was inserted into the container.
Definition: KeyedTraits.h:26
Containers::cannotInsertToContainer
GAUDI_API void cannotInsertToContainer()
Function to be called to indicate that an object cannot be inserted to the container.
Definition: KeyedObjectManager.cpp:73
std::vector::push_back
T push_back(T... args)
Containers::KeyedObjectManager::m_keyCtxt
long m_keyCtxt
Definition: KeyedObjectManager.h:52
Containers::OBJ_CANNOT_INSERT
Cannot insert object into container.
Definition: KeyedTraits.h:27
Containers::KeyedObjectManager::m_direct
long m_direct
Dirty flag.
Definition: KeyedObjectManager.h:51
Containers::KeyedObjectManager::m_seq
seq_type * m_seq
Container holding array like container.
Definition: KeyedObjectManager.h:49
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@2 m_setup

## ◆ insert() [4/6]

template<>

long Containers::KeyedObjectManager< __A >::insert | ( | ObjectContainerBase * | b,
|  | ContainedObject * | c,
|  | void * | o,
|  | long | k
| ) |  |

Keep major key value

Extend redirection array and insert

Definition at line 347 of file KeyedObjectManager.cpp.

347 {
348 if ( 0 == m_direct ) {
349 if ( k == m_keyCtxt + 1 ) { return insert( b, c, o, &k ); }
350 onDirty();
351 return insert( b, c, o, k );
352 }
354 if ( k > m_keyCtxt ) m_keyCtxt = k;
356 if ( k + 1 > long( m_setup.s->m_idx.size() ) ) { m_setup.s->m_idx.resize( k + 1, -1 ); }
357 auto idx = m_setup.s->m_idx.begin() + k;
358 if ( *idx == -1 ) {
359 *idx = m_setup.s->v.size();
360 m_setup.s->v.push_back( o );
361 m_seq->push_back( o );
362 if ( !c->parent() ) c->setParent( b );
363 return OBJ_INSERTED;
364 }
365 cannotInsertToContainer();
366 return OBJ_CANNOT_INSERT;
367 }
gaudirun.c
c
Definition: gaudirun.py:487
Containers::OBJ_INSERTED
Object was inserted into the container.
Definition: KeyedTraits.h:26
Containers::cannotInsertToContainer
GAUDI_API void cannotInsertToContainer()
Function to be called to indicate that an object cannot be inserted to the container.
Definition: KeyedObjectManager.cpp:73
Containers::KeyedObjectManager::onDirty
void onDirty() const
Callback when the container becomes dirty.
Definition: KeyedObjectManager.cpp:119
std::vector::push_back
T push_back(T... args)
Containers::KeyedObjectManager::m_keyCtxt
long m_keyCtxt
Definition: KeyedObjectManager.h:52
Containers::KeyedObjectManager::insert
long insert(ObjectContainerBase *b, ContainedObject *c, void *o, long *k)
Insert new object into container.
Definition: KeyedObjectManager.cpp:128
Containers::OBJ_CANNOT_INSERT
Cannot insert object into container.
Definition: KeyedTraits.h:27
Containers::KeyedObjectManager::m_direct
long m_direct
Dirty flag.
Definition: KeyedObjectManager.h:51
Containers::KeyedObjectManager::m_seq
seq_type * m_seq
Container holding array like container.
Definition: KeyedObjectManager.h:49
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@2 m_setup

## ◆ insert() [5/6]

template<>

long Containers::KeyedObjectManager< __V >::insert | ( | ObjectContainerBase * | b,
|  | ContainedObject * | c,
|  | void * | o,
|  | long * | k
| ) |  |

Definition at line 506 of file KeyedObjectManager.cpp.

506 {
507 m_seq->push_back( o );
508 m_setup.s->v.push_back( o );
509 if ( !c->parent() ) c->setParent( b );
510 *k = ( m_setup.s->v.size() - 1 );
511 return OBJ_INSERTED;
512 }
gaudirun.c
c
Definition: gaudirun.py:487
Containers::OBJ_INSERTED
Object was inserted into the container.
Definition: KeyedTraits.h:26
std::vector::push_back
T push_back(T... args)
Containers::KeyedObjectManager::m_seq
seq_type * m_seq
Container holding array like container.
Definition: KeyedObjectManager.h:49
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@2 m_setup

## ◆ insert() [6/6]

template<>

long Containers::KeyedObjectManager< __V >::insert | ( | ObjectContainerBase * | b,
|  | ContainedObject * | c,
|  | void * | o,
|  | long | k
| ) |  |

Definition at line 516 of file KeyedObjectManager.cpp.

516 {
517 if ( k == long( m_setup.s->v.size() ) ) { return insert( b, c, o, &k ); }
518 cannotInsertToContainer();
519 return OBJ_CANNOT_INSERT;
520 }
gaudirun.c
c
Definition: gaudirun.py:487
Containers::cannotInsertToContainer
GAUDI_API void cannotInsertToContainer()
Function to be called to indicate that an object cannot be inserted to the container.
Definition: KeyedObjectManager.cpp:73
Containers::KeyedObjectManager::insert
long insert(ObjectContainerBase *b, ContainedObject *c, void *o, long *k)
Insert new object into container.
Definition: KeyedObjectManager.cpp:128
Containers::OBJ_CANNOT_INSERT
Cannot insert object into container.
Definition: KeyedTraits.h:27
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@2 m_setup

## ◆ insertDirect() [1/3]

template<class T >

long Containers::KeyedObjectManager< T >::insertDirect | ( | ObjectContainerBase * | b,
|  | ContainedObject * | c,
|  | void * | o,
|  | long | k
| ) |  |

Insert element into direct access map.

Keep major key value

Definition at line 161 of file KeyedObjectManager.cpp.

162 {
164 if ( key > m_keyCtxt ) { m_keyCtxt = key; }
165 if ( 1 == m_direct ) {
166 if ( m_setup.s->insert( obj, key ) ) {
167 if ( !pObject->parent() ) { pObject->setParent( pBase ); }
168 return OBJ_INSERTED;
169 }
170 } else if ( key == long( m_setup.s->v.size() ) ) {
171 m_setup.s->v.push_back( obj );
172 if ( !pObject->parent() ) { pObject->setParent( pBase ); }
173 return OBJ_INSERTED;
174 } else {
175 // Document is dirty now...
176 // need to copy all pointers from the vector to the map
177 onDirty();
178 return insertDirect( pBase, pObject, obj, key );
179 }
180 cannotInsertToContainer();
181 return OBJ_CANNOT_INSERT;
182 }
Containers::OBJ_INSERTED
Object was inserted into the container.
Definition: KeyedTraits.h:26
Containers::cannotInsertToContainer
GAUDI_API void cannotInsertToContainer()
Function to be called to indicate that an object cannot be inserted to the container.
Definition: KeyedObjectManager.cpp:73
Containers::KeyedObjectManager::onDirty
void onDirty() const
Callback when the container becomes dirty.
Definition: KeyedObjectManager.cpp:119
Containers::KeyedObjectManager::m_keyCtxt
long m_keyCtxt
Definition: KeyedObjectManager.h:52
Containers::OBJ_CANNOT_INSERT
Cannot insert object into container.
Definition: KeyedTraits.h:27
Containers::KeyedObjectManager::m_direct
long m_direct
Dirty flag.
Definition: KeyedObjectManager.h:51
Containers::KeyedObjectManager::insertDirect
long insertDirect(ObjectContainerBase *b, ContainedObject *c, void *o, long k)
Insert element into direct access map.
Definition: KeyedObjectManager.cpp:161
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@2 m_setup

## ◆ insertDirect() [2/3]

template<>

long Containers::KeyedObjectManager< __A >::insertDirect | ( | ObjectContainerBase * | b,
|  | ContainedObject * | c,
|  | void * | o,
|  | long | k
| ) |  |

Keep major key value

Extend redirection array and insert

Definition at line 371 of file KeyedObjectManager.cpp.

371 {
372 if ( 0 == m_direct ) {
373 if ( k == m_keyCtxt + 1 ) {
374 m_setup.s->v.push_back( o );
375 if ( !c->parent() ) c->setParent( b );
376 ++m_keyCtxt;
377 return OBJ_INSERTED;
378 }
379 onDirty();
380 return insertDirect( b, c, o, k );
381 }
383 if ( k > m_keyCtxt ) m_keyCtxt = k;
385 if ( k + 1 > long( m_setup.s->m_idx.size() ) ) { m_setup.s->m_idx.resize( k + 1, -1 ); }
386 auto idx = m_setup.s->m_idx.begin() + k;
387 if ( *idx == -1 ) {
388 *idx = m_setup.s->v.size();
389 m_setup.s->v.push_back( o );
390 if ( !c->parent() ) c->setParent( b );
391 return OBJ_INSERTED;
392 }
393 cannotInsertToContainer();
394 return OBJ_CANNOT_INSERT;
395 }
gaudirun.c
c
Definition: gaudirun.py:487
Containers::OBJ_INSERTED
Object was inserted into the container.
Definition: KeyedTraits.h:26
Containers::cannotInsertToContainer
GAUDI_API void cannotInsertToContainer()
Function to be called to indicate that an object cannot be inserted to the container.
Definition: KeyedObjectManager.cpp:73
Containers::KeyedObjectManager::onDirty
void onDirty() const
Callback when the container becomes dirty.
Definition: KeyedObjectManager.cpp:119
Containers::KeyedObjectManager::m_keyCtxt
long m_keyCtxt
Definition: KeyedObjectManager.h:52
Containers::OBJ_CANNOT_INSERT
Cannot insert object into container.
Definition: KeyedTraits.h:27
Containers::KeyedObjectManager::m_direct
long m_direct
Dirty flag.
Definition: KeyedObjectManager.h:51
Containers::KeyedObjectManager::insertDirect
long insertDirect(ObjectContainerBase *b, ContainedObject *c, void *o, long k)
Insert element into direct access map.
Definition: KeyedObjectManager.cpp:161
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@2 m_setup

## ◆ insertDirect() [3/3]

template<>

long Containers::KeyedObjectManager< __V >::insertDirect | ( | ObjectContainerBase * | b,
|  | ContainedObject * | c,
|  | void * | o,
|  | long | k
| ) |  |

Definition at line 524 of file KeyedObjectManager.cpp.

524 {
525 if ( k == long( m_setup.s->v.size() ) ) {
526 m_setup.s->v.push_back( o );
527 if ( !c->parent() ) c->setParent( b );
528 return OBJ_INSERTED;
529 }
530 cannotInsertToContainer();
531 return OBJ_CANNOT_INSERT;
532 }
gaudirun.c
c
Definition: gaudirun.py:487
Containers::OBJ_INSERTED
Object was inserted into the container.
Definition: KeyedTraits.h:26
Containers::cannotInsertToContainer
GAUDI_API void cannotInsertToContainer()
Function to be called to indicate that an object cannot be inserted to the container.
Definition: KeyedObjectManager.cpp:73
Containers::OBJ_CANNOT_INSERT
Cannot insert object into container.
Definition: KeyedTraits.h:27
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@2 m_setup

## ◆ isDirect()

template<class SETUP >

long Containers::KeyedObjectManager< SETUP >::isDirect | ( |  | ) | const
| inline

Check if the container is dirty.

Definition at line 73 of file KeyedObjectManager.h.

73 { return m_direct; }
Containers::KeyedObjectManager::m_direct
long m_direct
Dirty flag.
Definition: KeyedObjectManager.h:51

## ◆ object() [1/3]

template<class T >

void * Containers::KeyedObjectManager< T >::object | ( | long | key | ) | const

Retrieve object identified by a key from the container.

Definition at line 208 of file KeyedObjectManager.cpp.

208 {
209 if ( 0 == m_direct ) onDirty();
210 auto i = m_setup.s->m.find( key );
211 if ( i != m_setup.s->m.end() ) return ( *i ).second;
212 return nullptr;
213 }
Containers::KeyedObjectManager::onDirty
void onDirty() const
Callback when the container becomes dirty.
Definition: KeyedObjectManager.cpp:119
Containers::KeyedObjectManager::m_direct
long m_direct
Dirty flag.
Definition: KeyedObjectManager.h:51
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@2 m_setup

## ◆ object() [2/3]

template<>

void * Containers::KeyedObjectManager< __A >::object | ( | long | value | ) | const

Definition at line 307 of file KeyedObjectManager.cpp.

307 {
308 #ifdef CHECK_KEYED_CONTAINER
309 unsigned long siz = m_setup.s->m_idx.size();
310 if ( value >= 0 && size_t( value ) < siz ) {
311 long ent = *( m_setup.s->m_idx.begin() + value );
312 if ( ent >= 0 ) { return *( m_setup.s->v.begin() + ent ); }
313 }
314 return nullptr;
315 #else
316 return *( m_setup.s->v.begin() + ( *( m_setup.s->m_idx.begin() + value ) ) );
317 #endif
318 }
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@2 m_setup

## ◆ object() [3/3]

template<>

void * Containers::KeyedObjectManager< __V >::object | ( | long |  | ) | const

Definition at line 494 of file KeyedObjectManager.cpp.

494 {
495 invalidContainerOperation();
496 return nullptr;
497 }
Containers::invalidContainerOperation
GAUDI_API void invalidContainerOperation()
Function to be called to indicate that an operation should be performed on the container or it's cont...
Definition: KeyedObjectManager.cpp:82

## ◆ onDirty() [1/3]

template<class T >

void Containers::KeyedObjectManager< T >::onDirty | ( |  | ) | const
| private

Callback when the container becomes dirty.

Definition at line 119 of file KeyedObjectManager.cpp.

119 {
120 m_direct = 1;
121 auto& s = *m_setup.s;
122 long i = 0;
123 for ( auto p : s.v ) s.insert( p, i++ );
124 s.v.clear();
125 }
Containers::KeyedObjectManager::s
SETUP * s
Definition: KeyedObjectManager.h:56
Containers::KeyedObjectManager::m_direct
long m_direct
Dirty flag.
Definition: KeyedObjectManager.h:51
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@2 m_setup

## ◆ onDirty() [2/3]

template<>

void Containers::KeyedObjectManager< __A >::onDirty | ( |  | ) | const
| private

Definition at line 321 of file KeyedObjectManager.cpp.

321 {
322 m_direct = 1;
323 m_setup.s->m_idx.reserve( m_setup.s->v.size() + 1 );
324 for ( int i = 0, stop = m_setup.s->v.size(); i < stop; ++i ) {
325 if ( !m_setup.s->v[i] ) { containerIsInconsistent(); }
326 m_setup.s->m_idx.push_back( i );
327 }
328 }
Containers::containerIsInconsistent
GAUDI_API void containerIsInconsistent()
Function to be called to indicate that the container is found to be inconsistent.
Definition: KeyedObjectManager.cpp:77
Containers::KeyedObjectManager::m_direct
long m_direct
Dirty flag.
Definition: KeyedObjectManager.h:51
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@2 m_setup

## ◆ onDirty() [3/3]

template<>

void Containers::KeyedObjectManager< __V >::onDirty | ( |  | ) | const
| private

Definition at line 500 of file KeyedObjectManager.cpp.

500 {
501 invalidContainerOperation();
502 }
Containers::invalidContainerOperation
GAUDI_API void invalidContainerOperation()
Function to be called to indicate that an operation should be performed on the container or it's cont...
Definition: KeyedObjectManager.cpp:82

## ◆ reserve()

template<class T >

void Containers::KeyedObjectManager< T >::reserve | ( | long | size | ) |

Reserve buffer space.

Definition at line 216 of file KeyedObjectManager.cpp.

216 {
217 switch ( m_direct ) {
218 case 1:
219 break;
220 case 0:
221 m_setup.s->v.reserve( len );
222 break;
223 default:
224 break;
225 }
226 m_seq->reserve( len );
227 }
Containers::KeyedObjectManager::m_direct
long m_direct
Dirty flag.
Definition: KeyedObjectManager.h:51
Containers::KeyedObjectManager::m_seq
seq_type * m_seq
Container holding array like container.
Definition: KeyedObjectManager.h:49
std::vector::reserve
T reserve(T... args)
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@2 m_setup

## ◆ setup()

template<class T >

void Containers::KeyedObjectManager< T >::setup | ( | void * | seq,
|  | void ** | rndm
| ) |  |

Setup of the Map and the parent object.

Definition at line 113 of file KeyedObjectManager.cpp.

113 {
114 m_seq = (seq_type*)seq;
115 *rndm = &m_setup.s->v;
116 }
ManySmallAlgs.seq
seq
Definition: ManySmallAlgs.py:89
Containers::KeyedObjectManager::seq_type
std::vector< void * > seq_type
Definition: KeyedObjectManager.h:47
Containers::KeyedObjectManager::m_seq
seq_type * m_seq
Container holding array like container.
Definition: KeyedObjectManager.h:49
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@2 m_setup

## Member Data Documentation

## ◆ buffer

template<class SETUP >

char Containers::KeyedObjectManager< SETUP >::buffer[128]

Buffer space to hold keyed container.

Definition at line 55 of file KeyedObjectManager.h.

## ◆ m_direct

template<class SETUP >

long Containers::KeyedObjectManager< SETUP >::m_direct
| mutable private

Dirty flag.

Definition at line 51 of file KeyedObjectManager.h.

## ◆ m_keyCtxt

template<class SETUP >

long Containers::KeyedObjectManager< SETUP >::m_keyCtxt
| mutable private

Definition at line 52 of file KeyedObjectManager.h.

## ◆ m_seq

template<class SETUP >

seq_type* Containers::KeyedObjectManager< SETUP >::m_seq
| private

Container holding array like container.

Definition at line 49 of file KeyedObjectManager.h.

## ◆ m_setup

union { ... } Containers::KeyedObjectManager< SETUP >::m_setup

## ◆ s

template<class SETUP >

SETUP* Containers::KeyedObjectManager< SETUP >::s

Definition at line 56 of file KeyedObjectManager.h.

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

- GaudiKernel/GaudiKernel/KeyedObjectManager.h
- GaudiKernel/src/Lib/KeyedObjectManager.cpp