Containers::KeyedObjectManager< SETUP > Class Template Reference

KeyedObjectManager Class to manage keyed objects. More...

#include <GaudiKernel/KeyedObjectManager.h>

Collaboration diagram for Containers::KeyedObjectManager< SETUP >:

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_typem_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 }
Define general base for Gaudi exception.
union Containers::KeyedObjectManager::@6 m_setup
seq_type * m_seq
Container holding array like container.
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 }
union Containers::KeyedObjectManager::@6 m_setup
STL namespace.
seq_type * m_seq
Container holding array like container.
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 }
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.

Definition at line 337 of file KeyedObjectManager.cpp.

337  {
338  return CLID_ObjectVector+0x00030000;
339  }

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 }
void clearDirect()
Clear all direct access fields.
T clear(T...args)
seq_type * m_seq
Container holding array like container.
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 }
union Containers::KeyedObjectManager::@6 m_setup
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 }
union Containers::KeyedObjectManager::@6 m_setup
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 }
union Containers::KeyedObjectManager::@6 m_setup
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  }
249  }
250  onDirty();
251  return erase(key, obj);
252 }
union Containers::KeyedObjectManager::@6 m_setup
GAUDI_API void containerIsInconsistent()
Function to be called to indicate that the container is found to be inconsistent. ...
T end(T...args)
void * erase(long key, const void *obj)
Remove object from container (very inefficient if key is invalid)
constexpr double m
Definition: SystemOfUnits.h:93
T erase(T...args)
void onDirty() const
Callback when the container becomes dirty.
T find_if(T...args)
T begin(T...args)
seq_type * m_seq
Container holding array like container.
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  }
325  }
326  m_seq->erase(beg, end);
327  }
328  return OBJ_ERASED;
329 }
void clear()
Clear content of the vector.
union Containers::KeyedObjectManager::@6 m_setup
GAUDI_API void containerIsInconsistent()
Function to be called to indicate that the container is found to be inconsistent. ...
T end(T...args)
void * erase(long key, const void *obj)
Remove object from container (very inefficient if key is invalid)
constexpr double m
Definition: SystemOfUnits.h:93
T erase(T...args)
void onDirty() const
Callback when the container becomes dirty.
auto end(reverse_wrapper< T > &w)
Definition: reverse.h:50
Object was removed, but not deleted.
Definition: KeyedTraits.h:22
T find_if(T...args)
T begin(T...args)
seq_type * m_seq
Container holding array like container.
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() ) {
517  }
518  void* o = *i;
519  auto j=std::find(m_seq->begin(),m_seq->end(),o);
520  if ( j == m_seq->end() ) {
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  }
533  return nullptr;
534 }
union Containers::KeyedObjectManager::@6 m_setup
GAUDI_API void containerIsInconsistent()
Function to be called to indicate that the container is found to be inconsistent. ...
T end(T...args)
void * erase(long key, const void *obj)
Remove object from container (very inefficient if key is invalid)
T erase(T...args)
void onDirty() const
Callback when the container becomes dirty.
T find(T...args)
T begin(T...args)
T for_each(T...args)
seq_type * m_seq
Container holding array like container.
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 ) {
570  }
571  return OBJ_ERASED;
572  }
573  // cannot reach this point
574 }
void clear()
Clear content of the vector.
union Containers::KeyedObjectManager::@6 m_setup
GAUDI_API void containerIsInconsistent()
Function to be called to indicate that the container is found to be inconsistent. ...
T end(T...args)
void * erase(long key, const void *obj)
Remove object from container (very inefficient if key is invalid)
T erase(T...args)
void onDirty() const
Callback when the container becomes dirty.
auto end(reverse_wrapper< T > &w)
Definition: reverse.h:50
Object was removed, but not deleted.
Definition: KeyedTraits.h:22
T find(T...args)
T begin(T...args)
T for_each(T...args)
seq_type * m_seq
Container holding array like container.
template<>
void * Containers::KeyedObjectManager< __V >::erase ( long  ,
const void *   
)

Definition at line 659 of file KeyedObjectManager.cpp.

661 {
663  return nullptr;
664 }
GAUDI_API void invalidContainerOperation()
Function to be called to indicate that an operation should be performed on the container or it&#39;s cont...
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  }
676  return OBJ_ERASED;
677 }
void clear()
Clear content of the vector.
T end(T...args)
GAUDI_API void invalidContainerOperation()
Function to be called to indicate that an operation should be performed on the container or it&#39;s cont...
auto end(reverse_wrapper< T > &w)
Definition: reverse.h:50
Object was removed, but not deleted.
Definition: KeyedTraits.h:22
T begin(T...args)
seq_type * m_seq
Container holding array like container.
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 }
long insert(ObjectContainerBase *b, ContainedObject *c, void *o, long *k)
Insert new object into container.
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  }
190  return OBJ_CANNOT_INSERT;
191 }
Object was inserted into the container.
Definition: KeyedTraits.h:23
union Containers::KeyedObjectManager::@6 m_setup
GAUDI_API void cannotInsertToContainer()
Function to be called to indicate that an object cannot be inserted to the container.
T push_back(T...args)
Cannot insert object into container.
Definition: KeyedTraits.h:24
void onDirty() const
Callback when the container becomes dirty.
long insert(ObjectContainerBase *b, ContainedObject *c, void *o, long *k)
Insert new object into container.
seq_type * m_seq
Container holding array like container.
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  }
405  return OBJ_CANNOT_INSERT;
406 }
Object was inserted into the container.
Definition: KeyedTraits.h:23
union Containers::KeyedObjectManager::@6 m_setup
const ObjectContainerBase * parent() const
Access to parent object.
GAUDI_API void cannotInsertToContainer()
Function to be called to indicate that an object cannot be inserted to the container.
T push_back(T...args)
Cannot insert object into container.
Definition: KeyedTraits.h:24
void setParent(ObjectContainerBase *value)
Update parent member.
seq_type * m_seq
Container holding array like container.
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  }
437  return OBJ_CANNOT_INSERT;
438 }
Object was inserted into the container.
Definition: KeyedTraits.h:23
union Containers::KeyedObjectManager::@6 m_setup
const ObjectContainerBase * parent() const
Access to parent object.
GAUDI_API void cannotInsertToContainer()
Function to be called to indicate that an object cannot be inserted to the container.
T push_back(T...args)
Cannot insert object into container.
Definition: KeyedTraits.h:24
void onDirty() const
Callback when the container becomes dirty.
long insert(ObjectContainerBase *b, ContainedObject *c, void *o, long *k)
Insert new object into container.
void setParent(ObjectContainerBase *value)
Update parent member.
seq_type * m_seq
Container holding array like container.
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 }
Object was inserted into the container.
Definition: KeyedTraits.h:23
union Containers::KeyedObjectManager::@6 m_setup
const ObjectContainerBase * parent() const
Access to parent object.
T push_back(T...args)
void setParent(ObjectContainerBase *value)
Update parent member.
seq_type * m_seq
Container holding array like container.
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  }
630  return OBJ_CANNOT_INSERT;
631 }
union Containers::KeyedObjectManager::@6 m_setup
GAUDI_API void cannotInsertToContainer()
Function to be called to indicate that an object cannot be inserted to the container.
Cannot insert object into container.
Definition: KeyedTraits.h:24
long insert(ObjectContainerBase *b, ContainedObject *c, void *o, long *k)
Insert new object into container.
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  }
226  return OBJ_CANNOT_INSERT;
227 }
Object was inserted into the container.
Definition: KeyedTraits.h:23
union Containers::KeyedObjectManager::@6 m_setup
GAUDI_API void cannotInsertToContainer()
Function to be called to indicate that an object cannot be inserted to the container.
Cannot insert object into container.
Definition: KeyedTraits.h:24
void onDirty() const
Callback when the container becomes dirty.
long insertDirect(ObjectContainerBase *b, ContainedObject *c, void *o, long k)
Insert element into direct access map.
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  }
471  return OBJ_CANNOT_INSERT;
472 }
Object was inserted into the container.
Definition: KeyedTraits.h:23
union Containers::KeyedObjectManager::@6 m_setup
const ObjectContainerBase * parent() const
Access to parent object.
GAUDI_API void cannotInsertToContainer()
Function to be called to indicate that an object cannot be inserted to the container.
Cannot insert object into container.
Definition: KeyedTraits.h:24
void onDirty() const
Callback when the container becomes dirty.
void setParent(ObjectContainerBase *value)
Update parent member.
long insertDirect(ObjectContainerBase *b, ContainedObject *c, void *o, long k)
Insert element into direct access map.
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  }
646  return OBJ_CANNOT_INSERT;
647 }
Object was inserted into the container.
Definition: KeyedTraits.h:23
union Containers::KeyedObjectManager::@6 m_setup
const ObjectContainerBase * parent() const
Access to parent object.
GAUDI_API void cannotInsertToContainer()
Function to be called to indicate that an object cannot be inserted to the container.
Cannot insert object into container.
Definition: KeyedTraits.h:24
void setParent(ObjectContainerBase *value)
Update parent member.
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; }
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 }
union Containers::KeyedObjectManager::@6 m_setup
void onDirty() const
Callback when the container becomes dirty.
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 }
union Containers::KeyedObjectManager::@6 m_setup
template<>
void * Containers::KeyedObjectManager< __V >::object ( long  ) const

Definition at line 594 of file KeyedObjectManager.cpp.

595 {
597  return nullptr;
598 }
GAUDI_API void invalidContainerOperation()
Function to be called to indicate that an operation should be performed on the container or it&#39;s cont...
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 }
union Containers::KeyedObjectManager::@6 m_setup
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] ) {
384  }
385  m_setup.s->m_idx.push_back(i);
386  }
387 }
union Containers::KeyedObjectManager::@6 m_setup
GAUDI_API void containerIsInconsistent()
Function to be called to indicate that the container is found to be inconsistent. ...
template<>
void Containers::KeyedObjectManager< __V >::onDirty ( ) const
private

Definition at line 601 of file KeyedObjectManager.cpp.

601  {
603 }
GAUDI_API void invalidContainerOperation()
Function to be called to indicate that an operation should be performed on the container or it&#39;s cont...
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 }
union Containers::KeyedObjectManager::@6 m_setup
seq_type * m_seq
Container holding array like container.
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 }
union Containers::KeyedObjectManager::@6 m_setup
std::vector< void * > seq_type
seq_type * m_seq
Container holding array like container.

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
mutableprivate

Dirty flag.

Definition at line 51 of file KeyedObjectManager.h.

template<class SETUP >
long Containers::KeyedObjectManager< SETUP >::m_keyCtxt
mutableprivate

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: