| The Gaudi Framework v28r2p1 (f1a77ff4)

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

## Member Typedef Documentation

template<class SETUP >

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

Definition at line 47 of file KeyedObjectManager.h.

## Constructor & Destructor Documentation

template<class T >

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

Standard Constructor.

Definition at line 96 of file KeyedObjectManager.cpp.

97 : m_seq(nullptr), m_direct(0)
98 {
99 if ( sizeof(typename T::map_type) > sizeof(m_setup.buffer) ) {
100 throw GaudiException("Basic STL contaier sizes are incompatible",
101 "KeyedContainer",
102 0);
103 }
104 m_setup.s = ::new(m_setup.buffer+sizeof(m_setup.s)) T();
105 m_keyCtxt = -1;
106 }
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:23
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@6 m_setup
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
template<class T >

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

Definition at line 109 of file KeyedObjectManager.cpp.

109 :
110 m_seq(nullptr),
111 m_direct(other.m_direct),
112 m_keyCtxt(other.m_keyCtxt)
113 {
114 m_setup.s = ::new(m_setup.buffer + sizeof(m_setup.s)) T(std::move(*other.m_setup.s));
115
116 other.m_keyCtxt = -1;
117 other.m_seq = nullptr;
118 other.m_direct = 0;
119 }
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@6 m_setup
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
template<class T >

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

Standard Destructor.

Definition at line 122 of file KeyedObjectManager.cpp.

123 {
124 m_setup.s->~T();
125 }
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 337 of file KeyedObjectManager.cpp.

337 {
338 return CLID_ObjectVector+0x00030000;
339 }
template<>

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

Definition at line 341 of file KeyedObjectManager.cpp.

341 {
342 return CLID_ObjectVector+0x00040000;
343 }
template<>

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

Definition at line 577 of file KeyedObjectManager.cpp.

577 {
578 return CLID_ObjectVector+0x00050000;
579 }
template<>

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

Definition at line 680 of file KeyedObjectManager.cpp.

680 {
681 return CLID_ObjectVector+0x00060000;
682 }
template<class T >

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

Clear content of the vector.

Definition at line 279 of file KeyedObjectManager.cpp.

280 {
281 clearDirect();
282 m_seq->clear();
283 }
Containers::KeyedObjectManager::clearDirect
void clearDirect()
Clear all direct access fields.
Definition: KeyedObjectManager.cpp:286
std::vector::clear
T clear(T...args)
Containers::KeyedObjectManager::m_seq
seq_type * m_seq
Container holding array like container.
Definition: KeyedObjectManager.h:49
template<class T >

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

Clear all direct access fields.

Definition at line 286 of file KeyedObjectManager.cpp.

287 {
288 switch( m_direct ) {
289 case 1:
290 m_setup.s->m.clear();
291 break;
292 case 0:
293 m_setup.s->v.clear();
294 break;
295 default:
296 break;
297 }
298 m_direct = 0;
299 m_keyCtxt = -1;
300 }
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@6 m_setup
Containers::KeyedObjectManager::m_keyCtxt
long m_keyCtxt
Definition: KeyedObjectManager.h:52
Containers::KeyedObjectManager::m_direct
long m_direct
Dirty flag.
Definition: KeyedObjectManager.h:51
template<>

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

Definition at line 476 of file KeyedObjectManager.cpp.

476 {
477 m_setup.s->v.clear();
478 m_setup.s->m_idx.clear();
479 m_direct = 0;
480 m_keyCtxt = -1;
481 }
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@6 m_setup
Containers::KeyedObjectManager::m_keyCtxt
long m_keyCtxt
Definition: KeyedObjectManager.h:52
Containers::KeyedObjectManager::m_direct
long m_direct
Dirty flag.
Definition: KeyedObjectManager.h:51
template<>

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

Definition at line 651 of file KeyedObjectManager.cpp.

651 {
652 m_setup.s->v.clear();
653 m_direct = 0;
654 m_keyCtxt = -1;
655 }
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@6 m_setup
Containers::KeyedObjectManager::m_keyCtxt
long m_keyCtxt
Definition: KeyedObjectManager.h:52
Containers::KeyedObjectManager::m_direct
long m_direct
Dirty flag.
Definition: KeyedObjectManager.h:51
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 231 of file KeyedObjectManager.cpp.

232 {
233 typedef typename T::map_type MTYP;
234 typedef find<MTYP> FND;
235 if ( 1 == m_direct ) {
236 auto& m = m_setup.s->m;
237 auto i = (obj ? std::find_if(m.begin(),m.end(),FND(obj))
238 : m_setup.s->m.find(key) );
239 if ( i != m_setup.s->m.end() ) {
240 void* o = i->second;
241 auto j = std::find(m_seq->begin(),m_seq->end(),o);
242 if ( j != m_seq->end() ) {
243 m_seq->erase(j);
244 m_setup.s->m.erase(i);
245 return o;
246 }
247 }
248 containerIsInconsistent();
249 }
250 onDirty();
251 return erase(key, obj);
252 }
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:231
Gaudi::Units::m
constexpr double m
Definition: SystemOfUnits.h:93
std::vector::erase
T erase(T...args)
Containers::KeyedObjectManager::onDirty
void onDirty() const
Callback when the container becomes dirty.
Definition: KeyedObjectManager.cpp:136
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
template<class T >

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

Remove object by sequential iterators.

Definition at line 304 of file KeyedObjectManager.cpp.

306 {
307 typedef typename T::map_type MTYP;
308 typedef find<MTYP> FND;
309 if ( 0 == m_direct ) {
310 onDirty();
311 return erase(beg, end);
312 }
313 if ( beg == m_seq->begin() && end == m_seq->end() ) {
314 clear();
315 }
316 else {
317 for ( auto j=beg; j != end; ++j) {
318 auto& m = m_setup.s->m;
319 auto i = std::find_if(m.begin(),m.end(),FND(*j));
320 if ( i != m_setup.s->m.end() ) {
321 m_setup.s->m.erase(i);
322 continue;
323 }
324 containerIsInconsistent();
325 }
326 m_seq->erase(beg, end);
327 }
328 return OBJ_ERASED;
329 }
Containers::KeyedObjectManager::clear
void clear()
Clear content of the vector.
Definition: KeyedObjectManager.cpp:279
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:231
Gaudi::Units::m
constexpr double m
Definition: SystemOfUnits.h:93
std::vector::erase
T erase(T...args)
Containers::KeyedObjectManager::onDirty
void onDirty() const
Callback when the container becomes dirty.
Definition: KeyedObjectManager.cpp:136
end
auto end(reverse_wrapper< T > &w)
Definition: reverse.h:50
Containers::OBJ_ERASED
Object was removed, but not deleted.
Definition: KeyedTraits.h:22
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
template<>

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

Definition at line 485 of file KeyedObjectManager.cpp.

487 {
488 typedef std::vector<long> id_type;
489 typedef id_type::iterator id_iter;
490 if ( 0 == m_direct ) {
491 onDirty();
492 return erase(key, obj);
493 }
494 if ( obj ) {
495 id_type& idx = m_setup.s->m_idx;
496 for (auto & elem : idx) {
497 auto j = m_setup.s->v.begin()+(elem);
498 auto k = std::find(m_seq->begin(),m_seq->end(),*j);
499 if ( *j == obj ) {
500 void* o = *j;
501 m_seq->erase(k);
502 m_setup.s->v.erase(j);
503 std::for_each(m_setup.s->m_idx.begin(),
504 m_setup.s->m_idx.end(),
505 array::decrement(elem));
506 elem = -1;
507 return o;
508 }
509 }
510 }
511 else if ( key >= 0 && key < long(m_setup.s->m_idx.size()) ) {
512 auto idx = m_setup.s->m_idx.begin()+key;
513 if ( *idx != -1 ) {
514 auto i = m_setup.s->v.begin()+(*idx);
515 if ( i == m_setup.s->v.end() ) {
516 containerIsInconsistent();
517 }
518 void* o = *i;
519 auto j=std::find(m_seq->begin(),m_seq->end(),o);
520 if ( j == m_seq->end() ) {
521 containerIsInconsistent();
522 }
523 m_seq->erase(j);
524 m_setup.s->v.erase(i);
525 std::for_each(m_setup.s->m_idx.begin(),
526 m_setup.s->m_idx.end(),
527 array::decrement(*idx));
528 *idx = -1;
529 return o;
530 }
531 }
532 containerIsInconsistent();
533 return nullptr;
534 }
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:231
std::vector::erase
T erase(T...args)
Containers::KeyedObjectManager::onDirty
void onDirty() const
Callback when the container becomes dirty.
Definition: KeyedObjectManager.cpp:136
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:51
Containers::KeyedObjectManager::m_seq
seq_type * m_seq
Container holding array like container.
Definition: KeyedObjectManager.h:49
template<>

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

Definition at line 538 of file KeyedObjectManager.cpp.

540 {
541 typedef std::vector<long> id_type;
542 typedef id_type::iterator id_iter;
543 if ( beg == m_seq->begin() && end == m_seq->end() ) {
544 clear();
545 return OBJ_ERASED;
546 }
547 else if ( 0 == m_direct ) {
548 onDirty();
549 return erase(beg, end);
550 }
551 else {
552 long cnt = 0, nobj = end-beg;
553 id_type& idx = m_setup.s->m_idx;
554 for (auto & elem : idx) {
555 auto j = m_setup.s->v.begin()+(elem);
556 auto k = std::find(beg,end,*j);
557 if ( k != end ) {
558 m_setup.s->v.erase(j);
559 std::for_each(m_setup.s->m_idx.begin(),
560 m_setup.s->m_idx.end(),
561 array::decrement(elem));
562 elem = -1;
563 cnt++;
564 if ( cnt == nobj ) break;
565 }
566 }
567 m_seq->erase(beg, end);
568 if ( cnt != nobj ) {
569 containerIsInconsistent();
570 }
571 return OBJ_ERASED;
572 }
573 // cannot reach this point
574 }
Containers::KeyedObjectManager::clear
void clear()
Clear content of the vector.
Definition: KeyedObjectManager.cpp:279
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:231
std::vector::erase
T erase(T...args)
Containers::KeyedObjectManager::onDirty
void onDirty() const
Callback when the container becomes dirty.
Definition: KeyedObjectManager.cpp:136
end
auto end(reverse_wrapper< T > &w)
Definition: reverse.h:50
Containers::OBJ_ERASED
Object was removed, but not deleted.
Definition: KeyedTraits.h:22
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:51
Containers::KeyedObjectManager::m_seq
seq_type * m_seq
Container holding array like container.
Definition: KeyedObjectManager.h:49
template<>

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

Definition at line 659 of file KeyedObjectManager.cpp.

661 {
662 invalidContainerOperation();
663 return nullptr;
664 }
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:89
template<>

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

Definition at line 668 of file KeyedObjectManager.cpp.

670 {
671 if ( beg == m_seq->begin() && end == m_seq->end() ) {
672 clear();
673 return OBJ_ERASED;
674 }
675 invalidContainerOperation();
676 return OBJ_ERASED;
677 }
Containers::KeyedObjectManager::clear
void clear()
Clear content of the vector.
Definition: KeyedObjectManager.cpp:279
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:89
end
auto end(reverse_wrapper< T > &w)
Definition: reverse.h:50
Containers::OBJ_ERASED
Object was removed, but not deleted.
Definition: KeyedTraits.h:22
std::vector::begin
T begin(T...args)
Containers::KeyedObjectManager::m_seq
seq_type * m_seq
Container holding array like container.
Definition: KeyedObjectManager.h:49
template<class T >

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

Insert new object into container.

Definition at line 145 of file KeyedObjectManager.cpp.

150 {
151 *key = ++m_keyCtxt;
152 return insert(pBase, pObject, obj, *key);
153 }
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:145
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 156 of file KeyedObjectManager.cpp.

161 {
163 if ( key > m_keyCtxt ) {
164 m_keyCtxt = key;
165 }
166 if ( 1==m_direct ) {
167 if ( m_setup.s->insert(obj, key) ) {
168 if ( !pObject->parent() ) {
169 pObject->setParent(pBase);
170 }
171 m_seq->push_back(obj);
172 return OBJ_INSERTED;
173 }
174 }
175 else if ( key == long(m_setup.s->v.size()) ) {
176 m_setup.s->v.push_back(obj);
177 if ( !pObject->parent() ) {
178 pObject->setParent(pBase);
179 }
180 m_seq->push_back(obj);
181 return OBJ_INSERTED;
182 }
183 else {
184 // Document is dirty now...
185 // need to copy all pointers from the vector to the map
186 onDirty();
187 return insert(pBase, pObject, obj, key);
188 }
189 cannotInsertToContainer();
190 return OBJ_CANNOT_INSERT;
191 }
Containers::OBJ_INSERTED
Object was inserted into the container.
Definition: KeyedTraits.h:23
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:77
std::vector::push_back
T push_back(T...args)
Containers::OBJ_CANNOT_INSERT
Cannot insert object into container.
Definition: KeyedTraits.h:24
Containers::KeyedObjectManager::m_keyCtxt
long m_keyCtxt
Definition: KeyedObjectManager.h:52
Containers::KeyedObjectManager::onDirty
void onDirty() const
Callback when the container becomes dirty.
Definition: KeyedObjectManager.cpp:136
Containers::KeyedObjectManager::insert
long insert(ObjectContainerBase *b, ContainedObject *c, void *o, long *k)
Insert new object into container.
Definition: KeyedObjectManager.cpp:145
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
template<>

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

Definition at line 391 of file KeyedObjectManager.cpp.

395 {
396 // auto key creation only possible for direct access!
397 if ( 0 == m_direct ) {
398 m_seq->push_back(o);
399 m_setup.s->v.push_back(o);
400 if ( !c->parent() ) c->setParent(b);
401 *k = ++m_keyCtxt;
402 return OBJ_INSERTED;
403 }
404 cannotInsertToContainer();
405 return OBJ_CANNOT_INSERT;
406 }
Containers::OBJ_INSERTED
Object was inserted into the container.
Definition: KeyedTraits.h:23
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@6 m_setup
ContainedObject::parent
const ObjectContainerBase * parent() const
Access to parent object.
Definition: ContainedObject.h:49
Containers::cannotInsertToContainer
GAUDI_API void cannotInsertToContainer()
Function to be called to indicate that an object cannot be inserted to the container.
Definition: KeyedObjectManager.cpp:77
std::vector::push_back
T push_back(T...args)
Containers::OBJ_CANNOT_INSERT
Cannot insert object into container.
Definition: KeyedTraits.h:24
Containers::KeyedObjectManager::m_keyCtxt
long m_keyCtxt
Definition: KeyedObjectManager.h:52
ContainedObject::setParent
void setParent(ObjectContainerBase *value)
Update parent member.
Definition: ContainedObject.h:51
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
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 410 of file KeyedObjectManager.cpp.

414 {
415 if ( 0 == m_direct ) {
416 if ( k == m_keyCtxt+1 ) {
417 return insert(b, c, o, &k);
418 }
419 onDirty();
420 return insert(b, c, o, k);
421 }
423 if ( k > m_keyCtxt ) m_keyCtxt = k;
425 if ( k+1 > long(m_setup.s->m_idx.size()) ) {
426 m_setup.s->m_idx.resize(k+1, -1);
427 }
428 auto idx = m_setup.s->m_idx.begin()+k;
429 if ( *idx == -1 ) {
430 *idx = m_setup.s->v.size();
431 m_setup.s->v.push_back(o);
432 m_seq->push_back(o);
433 if ( !c->parent() ) c->setParent(b);
434 return OBJ_INSERTED;
435 }
436 cannotInsertToContainer();
437 return OBJ_CANNOT_INSERT;
438 }
Containers::OBJ_INSERTED
Object was inserted into the container.
Definition: KeyedTraits.h:23
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@6 m_setup
ContainedObject::parent
const ObjectContainerBase * parent() const
Access to parent object.
Definition: ContainedObject.h:49
Containers::cannotInsertToContainer
GAUDI_API void cannotInsertToContainer()
Function to be called to indicate that an object cannot be inserted to the container.
Definition: KeyedObjectManager.cpp:77
std::vector::push_back
T push_back(T...args)
Containers::OBJ_CANNOT_INSERT
Cannot insert object into container.
Definition: KeyedTraits.h:24
Containers::KeyedObjectManager::m_keyCtxt
long m_keyCtxt
Definition: KeyedObjectManager.h:52
Containers::KeyedObjectManager::onDirty
void onDirty() const
Callback when the container becomes dirty.
Definition: KeyedObjectManager.cpp:136
Containers::KeyedObjectManager::insert
long insert(ObjectContainerBase *b, ContainedObject *c, void *o, long *k)
Insert new object into container.
Definition: KeyedObjectManager.cpp:145
ContainedObject::setParent
void setParent(ObjectContainerBase *value)
Update parent member.
Definition: ContainedObject.h:51
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
template<>

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

Definition at line 607 of file KeyedObjectManager.cpp.

611 {
612 m_seq->push_back(o);
613 m_setup.s->v.push_back(o);
614 if ( !c->parent() ) c->setParent(b);
615 *k = (m_setup.s->v.size()-1);
616 return OBJ_INSERTED;
617 }
Containers::OBJ_INSERTED
Object was inserted into the container.
Definition: KeyedTraits.h:23
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@6 m_setup
ContainedObject::parent
const ObjectContainerBase * parent() const
Access to parent object.
Definition: ContainedObject.h:49
std::vector::push_back
T push_back(T...args)
ContainedObject::setParent
void setParent(ObjectContainerBase *value)
Update parent member.
Definition: ContainedObject.h:51
Containers::KeyedObjectManager::m_seq
seq_type * m_seq
Container holding array like container.
Definition: KeyedObjectManager.h:49
template<>

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

Definition at line 621 of file KeyedObjectManager.cpp.

625 {
626 if ( k == long(m_setup.s->v.size()) ) {
627 return insert(b, c, o, &k);
628 }
629 cannotInsertToContainer();
630 return OBJ_CANNOT_INSERT;
631 }
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:77
Containers::OBJ_CANNOT_INSERT
Cannot insert object into container.
Definition: KeyedTraits.h:24
Containers::KeyedObjectManager::insert
long insert(ObjectContainerBase *b, ContainedObject *c, void *o, long *k)
Insert new object into container.
Definition: KeyedObjectManager.cpp:145
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 194 of file KeyedObjectManager.cpp.

199 {
201 if ( key > m_keyCtxt ) {
202 m_keyCtxt = key;
203 }
204 if ( 1==m_direct ) {
205 if ( m_setup.s->insert(obj, key) ) {
206 if ( !pObject->parent() ) {
207 pObject->setParent(pBase);
208 }
209 return OBJ_INSERTED;
210 }
211 }
212 else if ( key == long(m_setup.s->v.size()) ) {
213 m_setup.s->v.push_back(obj);
214 if ( !pObject->parent() ) {
215 pObject->setParent(pBase);
216 }
217 return OBJ_INSERTED;
218 }
219 else {
220 // Document is dirty now...
221 // need to copy all pointers from the vector to the map
222 onDirty();
223 return insertDirect(pBase, pObject, obj, key);
224 }
225 cannotInsertToContainer();
226 return OBJ_CANNOT_INSERT;
227 }
Containers::OBJ_INSERTED
Object was inserted into the container.
Definition: KeyedTraits.h:23
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:77
Containers::OBJ_CANNOT_INSERT
Cannot insert object into container.
Definition: KeyedTraits.h:24
Containers::KeyedObjectManager::m_keyCtxt
long m_keyCtxt
Definition: KeyedObjectManager.h:52
Containers::KeyedObjectManager::onDirty
void onDirty() const
Callback when the container becomes dirty.
Definition: KeyedObjectManager.cpp:136
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:194
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 442 of file KeyedObjectManager.cpp.

446 {
447 if ( 0 == m_direct ) {
448 if ( k == m_keyCtxt+1 ) {
449 m_setup.s->v.push_back(o);
450 if ( !c->parent() ) c->setParent(b);
451 ++m_keyCtxt;
452 return OBJ_INSERTED;
453 }
454 onDirty();
455 return insertDirect(b, c, o, k);
456 }
458 if ( k > m_keyCtxt ) m_keyCtxt = k;
460 if ( k+1 > long(m_setup.s->m_idx.size()) ) {
461 m_setup.s->m_idx.resize(k+1, -1);
462 }
463 auto idx = m_setup.s->m_idx.begin()+k;
464 if ( *idx == -1 ) {
465 *idx = m_setup.s->v.size();
466 m_setup.s->v.push_back(o);
467 if ( !c->parent() ) c->setParent(b);
468 return OBJ_INSERTED;
469 }
470 cannotInsertToContainer();
471 return OBJ_CANNOT_INSERT;
472 }
Containers::OBJ_INSERTED
Object was inserted into the container.
Definition: KeyedTraits.h:23
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@6 m_setup
ContainedObject::parent
const ObjectContainerBase * parent() const
Access to parent object.
Definition: ContainedObject.h:49
Containers::cannotInsertToContainer
GAUDI_API void cannotInsertToContainer()
Function to be called to indicate that an object cannot be inserted to the container.
Definition: KeyedObjectManager.cpp:77
Containers::OBJ_CANNOT_INSERT
Cannot insert object into container.
Definition: KeyedTraits.h:24
Containers::KeyedObjectManager::m_keyCtxt
long m_keyCtxt
Definition: KeyedObjectManager.h:52
Containers::KeyedObjectManager::onDirty
void onDirty() const
Callback when the container becomes dirty.
Definition: KeyedObjectManager.cpp:136
ContainedObject::setParent
void setParent(ObjectContainerBase *value)
Update parent member.
Definition: ContainedObject.h:51
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:194
template<>

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

Definition at line 635 of file KeyedObjectManager.cpp.

639 {
640 if ( k == long(m_setup.s->v.size()) ) {
641 m_setup.s->v.push_back(o);
642 if ( !c->parent() ) c->setParent(b);
643 return OBJ_INSERTED;
644 }
645 cannotInsertToContainer();
646 return OBJ_CANNOT_INSERT;
647 }
Containers::OBJ_INSERTED
Object was inserted into the container.
Definition: KeyedTraits.h:23
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@6 m_setup
ContainedObject::parent
const ObjectContainerBase * parent() const
Access to parent object.
Definition: ContainedObject.h:49
Containers::cannotInsertToContainer
GAUDI_API void cannotInsertToContainer()
Function to be called to indicate that an object cannot be inserted to the container.
Definition: KeyedObjectManager.cpp:77
Containers::OBJ_CANNOT_INSERT
Cannot insert object into container.
Definition: KeyedTraits.h:24
ContainedObject::setParent
void setParent(ObjectContainerBase *value)
Update parent member.
Definition: ContainedObject.h:51
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
template<class T >

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

Retrieve object identified by a key from the container.

Definition at line 255 of file KeyedObjectManager.cpp.

256 {
257 if ( 0 == m_direct ) onDirty();
258 auto i = m_setup.s->m.find(key);
259 if ( i != m_setup.s->m.end() ) return (*i).second;
260 return nullptr;
261 }
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:136
Containers::KeyedObjectManager::m_direct
long m_direct
Dirty flag.
Definition: KeyedObjectManager.h:51
template<>

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

Definition at line 361 of file KeyedObjectManager.cpp.

362 {
363 #ifdef CHECK_KEYED_CONTAINER
364 unsigned long siz = m_setup.s->m_idx.size();
365 if ( value >= 0 && size_t(value) < siz ) {
366 long ent = *(m_setup.s->m_idx.begin()+value);
367 if ( ent >= 0 ) {
368 return *(m_setup.s->v.begin() + ent);
369 }
370 }
371 return nullptr;
372 #else
373 return *(m_setup.s->v.begin() + (*(m_setup.s->m_idx.begin()+value)));
374 #endif
375 }
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@6 m_setup
template<>

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

Definition at line 594 of file KeyedObjectManager.cpp.

595 {
596 invalidContainerOperation();
597 return nullptr;
598 }
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:89
template<class T >

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

Callback when the container becomes dirty.

Definition at line 136 of file KeyedObjectManager.cpp.

136 {
137 m_direct = 1;
138 auto &s = *m_setup.s;
139 long i = 0;
140 for(auto p: s.v) s.insert(p, i++);
141 s.v.clear();
142 }
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@6 m_setup
Containers::KeyedObjectManager::s
SETUP * s
Definition: KeyedObjectManager.h:56
Containers::KeyedObjectManager::m_direct
long m_direct
Dirty flag.
Definition: KeyedObjectManager.h:51
template<>

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

Definition at line 378 of file KeyedObjectManager.cpp.

378 {
379 m_direct = 1;
380 m_setup.s->m_idx.reserve(m_setup.s->v.size()+1);
381 for(int i = 0, stop = m_setup.s->v.size(); i < stop; ++i) {
382 if ( !m_setup.s->v[i] ) {
383 containerIsInconsistent();
384 }
385 m_setup.s->m_idx.push_back(i);
386 }
387 }
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:51
template<>

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

Definition at line 601 of file KeyedObjectManager.cpp.

601 {
602 invalidContainerOperation();
603 }
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:89
template<class T >

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

Reserve buffer space.

Definition at line 264 of file KeyedObjectManager.cpp.

265 {
266 switch( m_direct ) {
267 case 1:
268 break;
269 case 0:
270 m_setup.s->v.reserve(len);
271 break;
272 default:
273 break;
274 }
275 m_seq->reserve(len);
276 }
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@6 m_setup
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)
template<class T >

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

Setup of the Map and the parent object.

Definition at line 129 of file KeyedObjectManager.cpp.

130 {
131 m_seq = (seq_type*)seq;
132 *rndm = &m_setup.s->v;
133 }
Containers::KeyedObjectManager::m_setup
union Containers::KeyedObjectManager::@6 m_setup
SequentialAlgSequencerTest.seq
seq
Definition: SequentialAlgSequencerTest.py:77
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

## Member Data Documentation

template<class SETUP >

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

Buffer space to hold keyed container.

Definition at line 55 of file KeyedObjectManager.h.

template<class SETUP >

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

Dirty flag.

Definition at line 51 of file KeyedObjectManager.h.

template<class SETUP >

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

Definition at line 52 of file KeyedObjectManager.h.

template<class SETUP >

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

Container holding array like container.

Definition at line 49 of file KeyedObjectManager.h.

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

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