| The Gaudi Framework v29r0 (ff2e7097)

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

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

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 46 of file KeyedObjectManager.h.

## Member Typedef Documentation

template<class SETUP >

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

Definition at line 49 of file KeyedObjectManager.h.

## Constructor & Destructor Documentation

template<class T >

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

Standard Constructor.

Definition at line 94 of file KeyedObjectManager.cpp.

94 : m_seq( nullptr ), m_direct( 0 )
95 {
96 if ( sizeof( typename T::map_type ) > sizeof( m_setup.buffer ) ) {
97 throw GaudiException( "Basic STL contaier sizes are incompatible", "KeyedContainer", 0 );
98 }
99 m_setup.s = ::new ( m_setup.buffer + sizeof( m_setup.s ) ) T();
100 m_keyCtxt = -1;
101 }
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:22
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@6 m_setup
Containers::KeyedObjectManager::m_keyCtxt
long m_keyCtxt
Definition: KeyedObjectManager.h:54
Containers::KeyedObjectManager::m_direct
long m_direct
Dirty flag.
Definition: KeyedObjectManager.h:53
Containers::KeyedObjectManager::m_seq
seq_type * m_seq
Container holding array like container.
Definition: KeyedObjectManager.h:51
template<class T >

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

Definition at line 104 of file KeyedObjectManager.cpp.

105 : m_seq( nullptr ), m_direct( other.m_direct ), m_keyCtxt( other.m_keyCtxt )
106 {
107 m_setup.s = ::new ( m_setup.buffer + sizeof( m_setup.s ) ) T( std::move( *other.m_setup.s ) );
108
109 other.m_keyCtxt = -1;
110 other.m_seq = nullptr;
111 other.m_direct = 0;
112 }
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@6 m_setup
std
STL namespace.
Containers::KeyedObjectManager::s
SETUP * s
Definition: KeyedObjectManager.h:58
Containers::KeyedObjectManager::m_keyCtxt
long m_keyCtxt
Definition: KeyedObjectManager.h:54
Containers::KeyedObjectManager::m_direct
long m_direct
Dirty flag.
Definition: KeyedObjectManager.h:53
Containers::KeyedObjectManager::m_seq
seq_type * m_seq
Container holding array like container.
Definition: KeyedObjectManager.h:51
template<class T >

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

Standard Destructor.

Definition at line 115 of file KeyedObjectManager.cpp.

116 {
117 m_setup.s->~T();
118 }
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@6 m_setup

## Member Function Documentation

template<class SETUP >

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

Access CLID for this type of container.

template<>

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

Definition at line 316 of file KeyedObjectManager.cpp.

317 {
318 return CLID_ObjectVector + 0x00030000;
319 }
template<>

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

Definition at line 321 of file KeyedObjectManager.cpp.

322 {
323 return CLID_ObjectVector + 0x00040000;
324 }
template<>

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

Definition at line 539 of file KeyedObjectManager.cpp.

540 {
541 return CLID_ObjectVector + 0x00050000;
542 }
template<>

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

Definition at line 635 of file KeyedObjectManager.cpp.

636 {
637 return CLID_ObjectVector + 0x00060000;
638 }
template<class T >

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

Clear content of the vector.

Definition at line 259 of file KeyedObjectManager.cpp.

260 {
261 clearDirect();
262 m_seq->clear();
263 }
Containers::KeyedObjectManager::clearDirect
void clearDirect()
Clear all direct access fields.
Definition: KeyedObjectManager.cpp:266
std::vector::clear
T clear(T...args)
Containers::KeyedObjectManager::m_seq
seq_type * m_seq
Container holding array like container.
Definition: KeyedObjectManager.h:51
template<class T >

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

Clear all direct access fields.

Definition at line 266 of file KeyedObjectManager.cpp.

267 {
268 switch ( m_direct ) {
269 case 1:
270 m_setup.s->m.clear();
271 break;
272 case 0:
273 m_setup.s->v.clear();
274 break;
275 default:
276 break;
277 }
278 m_direct = 0;
279 m_keyCtxt = -1;
280 }
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@6 m_setup
Containers::KeyedObjectManager::m_keyCtxt
long m_keyCtxt
Definition: KeyedObjectManager.h:54
Containers::KeyedObjectManager::m_direct
long m_direct
Dirty flag.
Definition: KeyedObjectManager.h:53
template<>

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

Definition at line 450 of file KeyedObjectManager.cpp.

451 {
452 m_setup.s->v.clear();
453 m_setup.s->m_idx.clear();
454 m_direct = 0;
455 m_keyCtxt = -1;
456 }
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@6 m_setup
Containers::KeyedObjectManager::m_keyCtxt
long m_keyCtxt
Definition: KeyedObjectManager.h:54
Containers::KeyedObjectManager::m_direct
long m_direct
Dirty flag.
Definition: KeyedObjectManager.h:53
template<>

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

Definition at line 607 of file KeyedObjectManager.cpp.

608 {
609 m_setup.s->v.clear();
610 m_direct = 0;
611 m_keyCtxt = -1;
612 }
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@6 m_setup
Containers::KeyedObjectManager::m_keyCtxt
long m_keyCtxt
Definition: KeyedObjectManager.h:54
Containers::KeyedObjectManager::m_direct
long m_direct
Dirty flag.
Definition: KeyedObjectManager.h:53
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 212 of file KeyedObjectManager.cpp.

213 {
214 typedef typename T::map_type MTYP;
215 typedef find<MTYP> FND;
216 if ( 1 == m_direct ) {
217 auto& m = m_setup.s->m;
218 auto i = ( obj ? std::find_if( m.begin(), m.end(), FND( obj ) ) : m_setup.s->m.find( key ) );
219 if ( i != m_setup.s->m.end() ) {
220 void* o = i->second;
221 auto j = std::find( m_seq->begin(), m_seq->end(), o );
222 if ( j != m_seq->end() ) {
223 m_seq->erase( j );
224 m_setup.s->m.erase( i );
225 return o;
226 }
227 }
228 containerIsInconsistent();
229 }
230 onDirty();
231 return erase( key, obj );
232 }
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@6 m_setup
Containers::containerIsInconsistent
GAUDI_API void containerIsInconsistent()
Function to be called to indicate that the container is found to be inconsistent. ...
Definition: KeyedObjectManager.cpp:83
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:212
Gaudi::Units::m
constexpr double m
Definition: SystemOfUnits.h:94
std::vector::erase
T erase(T...args)
Containers::KeyedObjectManager::onDirty
void onDirty() const
Callback when the container becomes dirty.
Definition: KeyedObjectManager.cpp:129
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:53
Containers::KeyedObjectManager::m_seq
seq_type * m_seq
Container holding array like container.
Definition: KeyedObjectManager.h:51
template<class T >

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

Remove object by sequential iterators.

Definition at line 284 of file KeyedObjectManager.cpp.

285 {
286 typedef typename T::map_type MTYP;
287 typedef find<MTYP> FND;
288 if ( 0 == m_direct ) {
289 onDirty();
290 return erase( beg, end );
291 }
292 if ( beg == m_seq->begin() && end == m_seq->end() ) {
293 clear();
294 } else {
295 for ( auto j = beg; j != end; ++j ) {
296 // auto& m = m_setup.s->m;
297 auto i = std::find_if( m_setup.s->m.begin(), m_setup.s->m.end(), FND( *j ) );
298 if ( i != m_setup.s->m.end() ) {
299 m_setup.s->m.erase( i );
300 continue;
301 }
302 containerIsInconsistent();
303 }
304 m_seq->erase( beg, end );
305 }
306 return OBJ_ERASED;
307 }
Containers::KeyedObjectManager::clear
void clear()
Clear content of the vector.
Definition: KeyedObjectManager.cpp:259
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@6 m_setup
Containers::containerIsInconsistent
GAUDI_API void containerIsInconsistent()
Function to be called to indicate that the container is found to be inconsistent. ...
Definition: KeyedObjectManager.cpp:83
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:212
std::vector::erase
T erase(T...args)
Containers::KeyedObjectManager::onDirty
void onDirty() const
Callback when the container becomes dirty.
Definition: KeyedObjectManager.cpp:129
end
auto end(reverse_wrapper< T > &w)
Definition: reverse.h:64
Containers::OBJ_ERASED
Object was removed, but not deleted.
Definition: KeyedTraits.h:26
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:53
Containers::KeyedObjectManager::m_seq
seq_type * m_seq
Container holding array like container.
Definition: KeyedObjectManager.h:51
template<>

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

Definition at line 460 of file KeyedObjectManager.cpp.

461 {
462 typedef std::vector<long> id_type;
463 if ( 0 == m_direct ) {
464 onDirty();
465 return erase( key, obj );
466 }
467 if ( obj ) {
468 id_type& idx = m_setup.s->m_idx;
469 for ( auto& elem : idx ) {
470 auto j = m_setup.s->v.begin() + ( elem );
471 auto k = std::find( m_seq->begin(), m_seq->end(), *j );
472 if ( *j == obj ) {
473 void* o = *j;
474 m_seq->erase( k );
475 m_setup.s->v.erase( j );
476 std::for_each( m_setup.s->m_idx.begin(), m_setup.s->m_idx.end(), array::decrement( elem ) );
477 elem = -1;
478 return o;
479 }
480 }
481 } else if ( key >= 0 && key < long( m_setup.s->m_idx.size() ) ) {
482 auto idx = m_setup.s->m_idx.begin() + key;
483 if ( *idx != -1 ) {
484 auto i = m_setup.s->v.begin() + ( *idx );
485 if ( i == m_setup.s->v.end() ) {
486 containerIsInconsistent();
487 }
488 void* o = *i;
489 auto j = std::find( m_seq->begin(), m_seq->end(), o );
490 if ( j == m_seq->end() ) {
491 containerIsInconsistent();
492 }
493 m_seq->erase( j );
494 m_setup.s->v.erase( i );
495 std::for_each( m_setup.s->m_idx.begin(), m_setup.s->m_idx.end(), array::decrement( *idx ) );
496 *idx = -1;
497 return o;
498 }
499 }
500 containerIsInconsistent();
501 return nullptr;
502 }
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@6 m_setup
Containers::containerIsInconsistent
GAUDI_API void containerIsInconsistent()
Function to be called to indicate that the container is found to be inconsistent. ...
Definition: KeyedObjectManager.cpp:83
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:212
std::vector::erase
T erase(T...args)
Containers::KeyedObjectManager::onDirty
void onDirty() const
Callback when the container becomes dirty.
Definition: KeyedObjectManager.cpp:129
std::find
T find(T...args)
std::vector< long >
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:53
Containers::KeyedObjectManager::m_seq
seq_type * m_seq
Container holding array like container.
Definition: KeyedObjectManager.h:51
template<>

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

Definition at line 506 of file KeyedObjectManager.cpp.

507 {
508 typedef std::vector<long> id_type;
509 if ( beg == m_seq->begin() && end == m_seq->end() ) {
510 clear();
511 return OBJ_ERASED;
512 } else if ( 0 == m_direct ) {
513 onDirty();
514 return erase( beg, end );
515 } else {
516 long cnt = 0, nobj = end - beg;
517 id_type& idx = m_setup.s->m_idx;
518 for ( auto& elem : idx ) {
519 auto j = m_setup.s->v.begin() + ( elem );
520 auto k = std::find( beg, end, *j );
521 if ( k != end ) {
522 m_setup.s->v.erase( j );
523 std::for_each( m_setup.s->m_idx.begin(), m_setup.s->m_idx.end(), array::decrement( elem ) );
524 elem = -1;
525 cnt++;
526 if ( cnt == nobj ) break;
527 }
528 }
529 m_seq->erase( beg, end );
530 if ( cnt != nobj ) {
531 containerIsInconsistent();
532 }
533 return OBJ_ERASED;
534 }
535 // cannot reach this point
536 }
Containers::KeyedObjectManager::clear
void clear()
Clear content of the vector.
Definition: KeyedObjectManager.cpp:259
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@6 m_setup
Containers::containerIsInconsistent
GAUDI_API void containerIsInconsistent()
Function to be called to indicate that the container is found to be inconsistent. ...
Definition: KeyedObjectManager.cpp:83
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:212
std::vector::erase
T erase(T...args)
Containers::KeyedObjectManager::onDirty
void onDirty() const
Callback when the container becomes dirty.
Definition: KeyedObjectManager.cpp:129
end
auto end(reverse_wrapper< T > &w)
Definition: reverse.h:64
Containers::OBJ_ERASED
Object was removed, but not deleted.
Definition: KeyedTraits.h:26
std::find
T find(T...args)
std::vector< long >
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:53
Containers::KeyedObjectManager::m_seq
seq_type * m_seq
Container holding array like container.
Definition: KeyedObjectManager.h:51
template<>

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

Definition at line 616 of file KeyedObjectManager.cpp.

617 {
618 invalidContainerOperation();
619 return nullptr;
620 }
Containers::invalidContainerOperation
GAUDI_API void invalidContainerOperation()
Function to be called to indicate that an operation should be performed on the container or it&#39;s cont...
Definition: KeyedObjectManager.cpp:88
template<>

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

Definition at line 624 of file KeyedObjectManager.cpp.

625 {
626 if ( beg == m_seq->begin() && end == m_seq->end() ) {
627 clear();
628 return OBJ_ERASED;
629 }
630 invalidContainerOperation();
631 return OBJ_ERASED;
632 }
Containers::KeyedObjectManager::clear
void clear()
Clear content of the vector.
Definition: KeyedObjectManager.cpp:259
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&#39;s cont...
Definition: KeyedObjectManager.cpp:88
end
auto end(reverse_wrapper< T > &w)
Definition: reverse.h:64
Containers::OBJ_ERASED
Object was removed, but not deleted.
Definition: KeyedTraits.h:26
std::vector::begin
T begin(T...args)
Containers::KeyedObjectManager::m_seq
seq_type * m_seq
Container holding array like container.
Definition: KeyedObjectManager.h:51
template<class T >

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

Insert new object into container.

Definition at line 139 of file KeyedObjectManager.cpp.

141 {
142 *key = ++m_keyCtxt;
143 return insert( pBase, pObject, obj, *key );
144 }
Containers::KeyedObjectManager::m_keyCtxt
long m_keyCtxt
Definition: KeyedObjectManager.h:54
Containers::KeyedObjectManager::insert
long insert(ObjectContainerBase *b, ContainedObject *c, void *o, long *k)
Insert new object into container.
Definition: KeyedObjectManager.cpp:139
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 147 of file KeyedObjectManager.cpp.

149 {
151 if ( key > m_keyCtxt ) {
152 m_keyCtxt = key;
153 }
154 if ( 1 == m_direct ) {
155 if ( m_setup.s->insert( obj, key ) ) {
156 if ( !pObject->parent() ) {
157 pObject->setParent( pBase );
158 }
159 m_seq->push_back( obj );
160 return OBJ_INSERTED;
161 }
162 } else if ( key == long( m_setup.s->v.size() ) ) {
163 m_setup.s->v.push_back( obj );
164 if ( !pObject->parent() ) {
165 pObject->setParent( pBase );
166 }
167 m_seq->push_back( obj );
168 return OBJ_INSERTED;
169 } else {
170 // Document is dirty now...
171 // need to copy all pointers from the vector to the map
172 onDirty();
173 return insert( pBase, pObject, obj, key );
174 }
175 cannotInsertToContainer();
176 return OBJ_CANNOT_INSERT;
177 }
Containers::OBJ_INSERTED
Object was inserted into the container.
Definition: KeyedTraits.h:27
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@6 m_setup
Containers::cannotInsertToContainer
GAUDI_API void cannotInsertToContainer()
Function to be called to indicate that an object cannot be inserted to the container.
Definition: KeyedObjectManager.cpp:78
std::vector::push_back
T push_back(T...args)
Containers::OBJ_CANNOT_INSERT
Cannot insert object into container.
Definition: KeyedTraits.h:28
Containers::KeyedObjectManager::m_keyCtxt
long m_keyCtxt
Definition: KeyedObjectManager.h:54
Containers::KeyedObjectManager::onDirty
void onDirty() const
Callback when the container becomes dirty.
Definition: KeyedObjectManager.cpp:129
Containers::KeyedObjectManager::insert
long insert(ObjectContainerBase *b, ContainedObject *c, void *o, long *k)
Insert new object into container.
Definition: KeyedObjectManager.cpp:139
Containers::KeyedObjectManager::m_direct
long m_direct
Dirty flag.
Definition: KeyedObjectManager.h:53
Containers::KeyedObjectManager::m_seq
seq_type * m_seq
Container holding array like container.
Definition: KeyedObjectManager.h:51
template<>

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

Definition at line 374 of file KeyedObjectManager.cpp.

375 {
376 // auto key creation only possible for direct access!
377 if ( 0 == m_direct ) {
378 m_seq->push_back( o );
379 m_setup.s->v.push_back( o );
380 if ( !c->parent() ) c->setParent( b );
381 *k = ++m_keyCtxt;
382 return OBJ_INSERTED;
383 }
384 cannotInsertToContainer();
385 return OBJ_CANNOT_INSERT;
386 }
Containers::OBJ_INSERTED
Object was inserted into the container.
Definition: KeyedTraits.h:27
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@6 m_setup
ContainedObject::parent
const ObjectContainerBase * parent() const
Access to parent object.
Definition: ContainedObject.h:52
Containers::cannotInsertToContainer
GAUDI_API void cannotInsertToContainer()
Function to be called to indicate that an object cannot be inserted to the container.
Definition: KeyedObjectManager.cpp:78
std::vector::push_back
T push_back(T...args)
Containers::OBJ_CANNOT_INSERT
Cannot insert object into container.
Definition: KeyedTraits.h:28
Containers::KeyedObjectManager::m_keyCtxt
long m_keyCtxt
Definition: KeyedObjectManager.h:54
ContainedObject::setParent
void setParent(ObjectContainerBase *value)
Update parent member.
Definition: ContainedObject.h:54
Containers::KeyedObjectManager::m_direct
long m_direct
Dirty flag.
Definition: KeyedObjectManager.h:53
Containers::KeyedObjectManager::m_seq
seq_type * m_seq
Container holding array like container.
Definition: KeyedObjectManager.h:51
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 390 of file KeyedObjectManager.cpp.

391 {
392 if ( 0 == m_direct ) {
393 if ( k == m_keyCtxt + 1 ) {
394 return insert( b, c, o, &k );
395 }
396 onDirty();
397 return insert( b, c, o, k );
398 }
400 if ( k > m_keyCtxt ) m_keyCtxt = k;
402 if ( k + 1 > long( m_setup.s->m_idx.size() ) ) {
403 m_setup.s->m_idx.resize( k + 1, -1 );
404 }
405 auto idx = m_setup.s->m_idx.begin() + k;
406 if ( *idx == -1 ) {
407 *idx = m_setup.s->v.size();
408 m_setup.s->v.push_back( o );
409 m_seq->push_back( o );
410 if ( !c->parent() ) c->setParent( b );
411 return OBJ_INSERTED;
412 }
413 cannotInsertToContainer();
414 return OBJ_CANNOT_INSERT;
415 }
Containers::OBJ_INSERTED
Object was inserted into the container.
Definition: KeyedTraits.h:27
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@6 m_setup
ContainedObject::parent
const ObjectContainerBase * parent() const
Access to parent object.
Definition: ContainedObject.h:52
Containers::cannotInsertToContainer
GAUDI_API void cannotInsertToContainer()
Function to be called to indicate that an object cannot be inserted to the container.
Definition: KeyedObjectManager.cpp:78
std::vector::push_back
T push_back(T...args)
Containers::OBJ_CANNOT_INSERT
Cannot insert object into container.
Definition: KeyedTraits.h:28
Containers::KeyedObjectManager::m_keyCtxt
long m_keyCtxt
Definition: KeyedObjectManager.h:54
Containers::KeyedObjectManager::onDirty
void onDirty() const
Callback when the container becomes dirty.
Definition: KeyedObjectManager.cpp:129
Containers::KeyedObjectManager::insert
long insert(ObjectContainerBase *b, ContainedObject *c, void *o, long *k)
Insert new object into container.
Definition: KeyedObjectManager.cpp:139
ContainedObject::setParent
void setParent(ObjectContainerBase *value)
Update parent member.
Definition: ContainedObject.h:54
Containers::KeyedObjectManager::m_direct
long m_direct
Dirty flag.
Definition: KeyedObjectManager.h:53
Containers::KeyedObjectManager::m_seq
seq_type * m_seq
Container holding array like container.
Definition: KeyedObjectManager.h:51
template<>

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

Definition at line 572 of file KeyedObjectManager.cpp.

573 {
574 m_seq->push_back( o );
575 m_setup.s->v.push_back( o );
576 if ( !c->parent() ) c->setParent( b );
577 *k = ( m_setup.s->v.size() - 1 );
578 return OBJ_INSERTED;
579 }
Containers::OBJ_INSERTED
Object was inserted into the container.
Definition: KeyedTraits.h:27
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@6 m_setup
ContainedObject::parent
const ObjectContainerBase * parent() const
Access to parent object.
Definition: ContainedObject.h:52
std::vector::push_back
T push_back(T...args)
ContainedObject::setParent
void setParent(ObjectContainerBase *value)
Update parent member.
Definition: ContainedObject.h:54
Containers::KeyedObjectManager::m_seq
seq_type * m_seq
Container holding array like container.
Definition: KeyedObjectManager.h:51
template<>

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

Definition at line 583 of file KeyedObjectManager.cpp.

584 {
585 if ( k == long( m_setup.s->v.size() ) ) {
586 return insert( b, c, o, &k );
587 }
588 cannotInsertToContainer();
589 return OBJ_CANNOT_INSERT;
590 }
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@6 m_setup
Containers::cannotInsertToContainer
GAUDI_API void cannotInsertToContainer()
Function to be called to indicate that an object cannot be inserted to the container.
Definition: KeyedObjectManager.cpp:78
Containers::OBJ_CANNOT_INSERT
Cannot insert object into container.
Definition: KeyedTraits.h:28
Containers::KeyedObjectManager::insert
long insert(ObjectContainerBase *b, ContainedObject *c, void *o, long *k)
Insert new object into container.
Definition: KeyedObjectManager.cpp:139
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 180 of file KeyedObjectManager.cpp.

182 {
184 if ( key > m_keyCtxt ) {
185 m_keyCtxt = key;
186 }
187 if ( 1 == m_direct ) {
188 if ( m_setup.s->insert( obj, key ) ) {
189 if ( !pObject->parent() ) {
190 pObject->setParent( pBase );
191 }
192 return OBJ_INSERTED;
193 }
194 } else if ( key == long( m_setup.s->v.size() ) ) {
195 m_setup.s->v.push_back( obj );
196 if ( !pObject->parent() ) {
197 pObject->setParent( pBase );
198 }
199 return OBJ_INSERTED;
200 } else {
201 // Document is dirty now...
202 // need to copy all pointers from the vector to the map
203 onDirty();
204 return insertDirect( pBase, pObject, obj, key );
205 }
206 cannotInsertToContainer();
207 return OBJ_CANNOT_INSERT;
208 }
Containers::OBJ_INSERTED
Object was inserted into the container.
Definition: KeyedTraits.h:27
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@6 m_setup
Containers::cannotInsertToContainer
GAUDI_API void cannotInsertToContainer()
Function to be called to indicate that an object cannot be inserted to the container.
Definition: KeyedObjectManager.cpp:78
Containers::OBJ_CANNOT_INSERT
Cannot insert object into container.
Definition: KeyedTraits.h:28
Containers::KeyedObjectManager::m_keyCtxt
long m_keyCtxt
Definition: KeyedObjectManager.h:54
Containers::KeyedObjectManager::onDirty
void onDirty() const
Callback when the container becomes dirty.
Definition: KeyedObjectManager.cpp:129
Containers::KeyedObjectManager::m_direct
long m_direct
Dirty flag.
Definition: KeyedObjectManager.h:53
Containers::KeyedObjectManager::insertDirect
long insertDirect(ObjectContainerBase *b, ContainedObject *c, void *o, long k)
Insert element into direct access map.
Definition: KeyedObjectManager.cpp:180
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 419 of file KeyedObjectManager.cpp.

420 {
421 if ( 0 == m_direct ) {
422 if ( k == m_keyCtxt + 1 ) {
423 m_setup.s->v.push_back( o );
424 if ( !c->parent() ) c->setParent( b );
425 ++m_keyCtxt;
426 return OBJ_INSERTED;
427 }
428 onDirty();
429 return insertDirect( b, c, o, k );
430 }
432 if ( k > m_keyCtxt ) m_keyCtxt = k;
434 if ( k + 1 > long( m_setup.s->m_idx.size() ) ) {
435 m_setup.s->m_idx.resize( k + 1, -1 );
436 }
437 auto idx = m_setup.s->m_idx.begin() + k;
438 if ( *idx == -1 ) {
439 *idx = m_setup.s->v.size();
440 m_setup.s->v.push_back( o );
441 if ( !c->parent() ) c->setParent( b );
442 return OBJ_INSERTED;
443 }
444 cannotInsertToContainer();
445 return OBJ_CANNOT_INSERT;
446 }
Containers::OBJ_INSERTED
Object was inserted into the container.
Definition: KeyedTraits.h:27
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@6 m_setup
ContainedObject::parent
const ObjectContainerBase * parent() const
Access to parent object.
Definition: ContainedObject.h:52
Containers::cannotInsertToContainer
GAUDI_API void cannotInsertToContainer()
Function to be called to indicate that an object cannot be inserted to the container.
Definition: KeyedObjectManager.cpp:78
Containers::OBJ_CANNOT_INSERT
Cannot insert object into container.
Definition: KeyedTraits.h:28
Containers::KeyedObjectManager::m_keyCtxt
long m_keyCtxt
Definition: KeyedObjectManager.h:54
Containers::KeyedObjectManager::onDirty
void onDirty() const
Callback when the container becomes dirty.
Definition: KeyedObjectManager.cpp:129
ContainedObject::setParent
void setParent(ObjectContainerBase *value)
Update parent member.
Definition: ContainedObject.h:54
Containers::KeyedObjectManager::m_direct
long m_direct
Dirty flag.
Definition: KeyedObjectManager.h:53
Containers::KeyedObjectManager::insertDirect
long insertDirect(ObjectContainerBase *b, ContainedObject *c, void *o, long k)
Insert element into direct access map.
Definition: KeyedObjectManager.cpp:180
template<>

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

Definition at line 594 of file KeyedObjectManager.cpp.

595 {
596 if ( k == long( m_setup.s->v.size() ) ) {
597 m_setup.s->v.push_back( o );
598 if ( !c->parent() ) c->setParent( b );
599 return OBJ_INSERTED;
600 }
601 cannotInsertToContainer();
602 return OBJ_CANNOT_INSERT;
603 }
Containers::OBJ_INSERTED
Object was inserted into the container.
Definition: KeyedTraits.h:27
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@6 m_setup
ContainedObject::parent
const ObjectContainerBase * parent() const
Access to parent object.
Definition: ContainedObject.h:52
Containers::cannotInsertToContainer
GAUDI_API void cannotInsertToContainer()
Function to be called to indicate that an object cannot be inserted to the container.
Definition: KeyedObjectManager.cpp:78
Containers::OBJ_CANNOT_INSERT
Cannot insert object into container.
Definition: KeyedTraits.h:28
ContainedObject::setParent
void setParent(ObjectContainerBase *value)
Update parent member.
Definition: ContainedObject.h:54
template<class SETUP >

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

Check if the container is dirty.

Definition at line 75 of file KeyedObjectManager.h.

75 { return m_direct; }
Containers::KeyedObjectManager::m_direct
long m_direct
Dirty flag.
Definition: KeyedObjectManager.h:53
template<class T >

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

Retrieve object identified by a key from the container.

Definition at line 235 of file KeyedObjectManager.cpp.

236 {
237 if ( 0 == m_direct ) onDirty();
238 auto i = m_setup.s->m.find( key );
239 if ( i != m_setup.s->m.end() ) return ( *i ).second;
240 return nullptr;
241 }
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@6 m_setup
Containers::KeyedObjectManager::onDirty
void onDirty() const
Callback when the container becomes dirty.
Definition: KeyedObjectManager.cpp:129
Containers::KeyedObjectManager::m_direct
long m_direct
Dirty flag.
Definition: KeyedObjectManager.h:53
template<>

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

Definition at line 343 of file KeyedObjectManager.cpp.

344 {
345 #ifdef CHECK_KEYED_CONTAINER
346 unsigned long siz = m_setup.s->m_idx.size();
347 if ( value >= 0 && size_t( value ) < siz ) {
348 long ent = *( m_setup.s->m_idx.begin() + value );
349 if ( ent >= 0 ) {
350 return *( m_setup.s->v.begin() + ent );
351 }
352 }
353 return nullptr;
354 #else
355 return *( m_setup.s->v.begin() + ( *( m_setup.s->m_idx.begin() + value ) ) );
356 #endif
357 }
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@6 m_setup
template<>

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

Definition at line 558 of file KeyedObjectManager.cpp.

559 {
560 invalidContainerOperation();
561 return nullptr;
562 }
Containers::invalidContainerOperation
GAUDI_API void invalidContainerOperation()
Function to be called to indicate that an operation should be performed on the container or it&#39;s cont...
Definition: KeyedObjectManager.cpp:88
template<class T >

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

Callback when the container becomes dirty.

Definition at line 129 of file KeyedObjectManager.cpp.

130 {
131 m_direct = 1;
132 auto& s = *m_setup.s;
133 long i = 0;
134 for ( auto p : s.v ) s.insert( p, i++ );
135 s.v.clear();
136 }
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@6 m_setup
Containers::KeyedObjectManager::s
SETUP * s
Definition: KeyedObjectManager.h:58
Containers::KeyedObjectManager::m_direct
long m_direct
Dirty flag.
Definition: KeyedObjectManager.h:53
template<>

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

Definition at line 360 of file KeyedObjectManager.cpp.

361 {
362 m_direct = 1;
363 m_setup.s->m_idx.reserve( m_setup.s->v.size() + 1 );
364 for ( int i = 0, stop = m_setup.s->v.size(); i < stop; ++i ) {
365 if ( !m_setup.s->v[i] ) {
366 containerIsInconsistent();
367 }
368 m_setup.s->m_idx.push_back( i );
369 }
370 }
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@6 m_setup
Containers::containerIsInconsistent
GAUDI_API void containerIsInconsistent()
Function to be called to indicate that the container is found to be inconsistent. ...
Definition: KeyedObjectManager.cpp:83
Containers::KeyedObjectManager::m_direct
long m_direct
Dirty flag.
Definition: KeyedObjectManager.h:53
template<>

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

Definition at line 565 of file KeyedObjectManager.cpp.

566 {
567 invalidContainerOperation();
568 }
Containers::invalidContainerOperation
GAUDI_API void invalidContainerOperation()
Function to be called to indicate that an operation should be performed on the container or it&#39;s cont...
Definition: KeyedObjectManager.cpp:88
template<class T >

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

Reserve buffer space.

Definition at line 244 of file KeyedObjectManager.cpp.

245 {
246 switch ( m_direct ) {
247 case 1:
248 break;
249 case 0:
250 m_setup.s->v.reserve( len );
251 break;
252 default:
253 break;
254 }
255 m_seq->reserve( len );
256 }
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@6 m_setup
Containers::KeyedObjectManager::m_direct
long m_direct
Dirty flag.
Definition: KeyedObjectManager.h:53
Containers::KeyedObjectManager::m_seq
seq_type * m_seq
Container holding array like container.
Definition: KeyedObjectManager.h:51
std::vector::reserve
T reserve(T...args)
template<class T >

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

Setup of the Map and the parent object.

Definition at line 122 of file KeyedObjectManager.cpp.

123 {
124 m_seq = (seq_type*)seq;
125 *rndm = &m_setup.s->v;
126 }
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@6 m_setup
SequentialAlgSequencerTest.seq
seq
Definition: SequentialAlgSequencerTest.py:76
Containers::KeyedObjectManager::seq_type
std::vector< void * > seq_type
Definition: KeyedObjectManager.h:49
Containers::KeyedObjectManager::m_seq
seq_type * m_seq
Container holding array like container.
Definition: KeyedObjectManager.h:51

## Member Data Documentation

template<class SETUP >

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

Buffer space to hold keyed container.

Definition at line 57 of file KeyedObjectManager.h.

template<class SETUP >

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

Dirty flag.

Definition at line 53 of file KeyedObjectManager.h.

template<class SETUP >

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

Definition at line 54 of file KeyedObjectManager.h.

template<class SETUP >

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

Container holding array like container.

Definition at line 51 of file KeyedObjectManager.h.

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

template<class SETUP >

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

Definition at line 58 of file KeyedObjectManager.h.

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

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