Containers::KeyedObjectManager< SETUP > Class Template Reference

KeyedObjectManager Class to manage keyed objects. More...

#include </tmp/marcocle/lhcb-release/1122/GAUDI/GAUDI_v27r0/InstallArea/x86_64-slc6-gcc49-opt/include/GaudiKernel/KeyedObjectManager.h>

Collaboration diagram for Containers::KeyedObjectManager< SETUP >:

Public Member Functions

 KeyedObjectManager ()
 Standard Constructor. More...
 
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...
 
 KeyedObjectManager ()
 Standard Constructor. More...
 
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...
 
static CLID classID ()
 Access CLID for this type of container. More...
 

Private Types

typedef std::vector< void * > seq_type
 
typedef std::vector< void * > seq_type
 

Private Member Functions

void onDirty () const
 Callback when the container becomes dirty. More...
 
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
 
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.

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 88 of file KeyedObjectManager.cpp.

89 : m_seq(nullptr), m_direct(0)
90 {
91  if ( sizeof(typename T::map_type) > sizeof(m_setup.buffer) ) {
92  throw GaudiException("Basic STL contaier sizes are incompatible",
93  "KeyedContainer",
94  0);
95  }
96  m_setup.s = ::new(m_setup.buffer+sizeof(m_setup.s)) T();
97  m_keyCtxt = -1;
98 }
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 ( )
virtual

Standard Destructor.

Definition at line 101 of file KeyedObjectManager.cpp.

102 {
103  m_setup.s->~T();
104 }
union Containers::KeyedObjectManager::@6 m_setup
template<class SETUP >
Containers::KeyedObjectManager< SETUP >::KeyedObjectManager ( )

Standard Constructor.

template<class SETUP >
virtual Containers::KeyedObjectManager< SETUP >::~KeyedObjectManager ( )
virtual

Standard Destructor.

Member Function Documentation

template<class SETUP >
static CLID Containers::KeyedObjectManager< SETUP >::classID ( )
static

Access CLID for this type of container.

template<class SETUP >
static CLID Containers::KeyedObjectManager< SETUP >::classID ( )
static

Access CLID for this type of container.

Definition at line 316 of file KeyedObjectManager.cpp.

316  {
317  return CLID_ObjectVector+0x00030000;
318  }

Definition at line 320 of file KeyedObjectManager.cpp.

320  {
321  return CLID_ObjectVector+0x00040000;
322  }
template<>
CLID Containers::KeyedObjectManager< __A >::classID ( )

Definition at line 556 of file KeyedObjectManager.cpp.

556  {
557  return CLID_ObjectVector+0x00050000;
558 }
template<>
CLID Containers::KeyedObjectManager< __V >::classID ( )

Definition at line 659 of file KeyedObjectManager.cpp.

659  {
660  return CLID_ObjectVector+0x00060000;
661 }
template<class T >
void Containers::KeyedObjectManager< T >::clear ( )

Clear content of the vector.

Definition at line 258 of file KeyedObjectManager.cpp.

259 {
260  clearDirect();
261  m_seq->clear();
262 }
void clearDirect()
Clear all direct access fields.
seq_type * m_seq
Container holding array like container.
template<class SETUP >
void Containers::KeyedObjectManager< SETUP >::clear ( )

Clear content of the vector.

template<class T >
void Containers::KeyedObjectManager< T >::clearDirect ( )

Clear all direct access fields.

Definition at line 265 of file KeyedObjectManager.cpp.

266 {
267  switch( m_direct ) {
268  case 1:
269  m_setup.s->m.clear();
270  break;
271  case 0:
272  m_setup.s->v.clear();
273  break;
274  default:
275  break;
276  }
277  m_direct = 0;
278  m_keyCtxt = -1;
279 }
union Containers::KeyedObjectManager::@6 m_setup
template<class SETUP >
void Containers::KeyedObjectManager< SETUP >::clearDirect ( )

Clear all direct access fields.

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

Definition at line 455 of file KeyedObjectManager.cpp.

455  {
456  m_setup.s->v.clear();
457  m_setup.s->m_idx.clear();
458  m_direct = 0;
459  m_keyCtxt = -1;
460 }
union Containers::KeyedObjectManager::@6 m_setup
template<>
void Containers::KeyedObjectManager< __V >::clearDirect ( )

Definition at line 630 of file KeyedObjectManager.cpp.

630  {
631  m_setup.s->v.clear();
632  m_direct = 0;
633  m_keyCtxt = -1;
634 }
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 210 of file KeyedObjectManager.cpp.

211  {
212  typedef typename T::map_type MTYP;
213  typedef find<MTYP> FND;
214  if ( 1 == m_direct ) {
215  auto& m = m_setup.s->m;
216  auto i = (obj ? std::find_if(m.begin(),m.end(),FND(obj))
217  : m_setup.s->m.find(key) );
218  if ( i != m_setup.s->m.end() ) {
219  void* o = i->second;
220  auto j = std::find(m_seq->begin(),m_seq->end(),o);
221  if ( j != m_seq->end() ) {
222  m_seq->erase(j);
223  m_setup.s->m.erase(i);
224  return o;
225  }
226  }
228  }
229  onDirty();
230  return erase(key, obj);
231 }
union Containers::KeyedObjectManager::@6 m_setup
void * erase(long key, const void *obj)
Remove object from container (very inefficient if key is invalid)
constexpr double m
Definition: SystemOfUnits.h:93
seq_type * m_seq
Container holding array like container.
void onDirty() const
Callback when the container becomes dirty.
GAUDI_API void containerIsInconsistent()
Function to be called to indicate that the container is found to be inconsistent. ...
list i
Definition: ana.py:128
template<class SETUP >
void* Containers::KeyedObjectManager< SETUP >::erase ( long  key,
const void *  obj 
)

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

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

Remove object by sequential iterators.

Definition at line 283 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  }
295  else {
296  for ( auto j=beg; j != end; ++j) {
297  auto& m = m_setup.s->m;
298  auto i = std::find_if(m.begin(),m.end(),FND(*j));
299  if ( i != m_setup.s->m.end() ) {
300  m_setup.s->m.erase(i);
301  continue;
302  }
304  }
305  m_seq->erase(beg, end);
306  }
307  return OBJ_ERASED;
308 }
void clear()
Clear content of the vector.
union Containers::KeyedObjectManager::@6 m_setup
Object was removed, but not deleted.
Definition: KeyedTraits.h:22
void * erase(long key, const void *obj)
Remove object from container (very inefficient if key is invalid)
auto end(reverse_wrapper< T > &w)
Definition: reverse.h:47
constexpr double m
Definition: SystemOfUnits.h:93
seq_type * m_seq
Container holding array like container.
void onDirty() const
Callback when the container becomes dirty.
GAUDI_API void containerIsInconsistent()
Function to be called to indicate that the container is found to be inconsistent. ...
list i
Definition: ana.py:128
template<class SETUP >
long Containers::KeyedObjectManager< SETUP >::erase ( seq_type::iterator  beg,
seq_type::iterator  end 
)

Remove object by sequential iterators.

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

Definition at line 464 of file KeyedObjectManager.cpp.

466 {
467  typedef std::vector<long> id_type;
468  typedef id_type::iterator id_iter;
469  if ( 0 == m_direct ) {
470  onDirty();
471  return erase(key, obj);
472  }
473  if ( obj ) {
474  id_type& idx = m_setup.s->m_idx;
475  for (auto & elem : idx) {
476  auto j = m_setup.s->v.begin()+(elem);
477  auto k = std::find(m_seq->begin(),m_seq->end(),*j);
478  if ( *j == obj ) {
479  void* o = *j;
480  m_seq->erase(k);
481  m_setup.s->v.erase(j);
482  std::for_each(m_setup.s->m_idx.begin(),
483  m_setup.s->m_idx.end(),
484  array::decrement(elem));
485  elem = -1;
486  return o;
487  }
488  }
489  }
490  else if ( key >= 0 && key < long(m_setup.s->m_idx.size()) ) {
491  auto idx = m_setup.s->m_idx.begin()+key;
492  if ( *idx != -1 ) {
493  auto i = m_setup.s->v.begin()+(*idx);
494  if ( i == m_setup.s->v.end() ) {
496  }
497  void* o = *i;
498  auto j=std::find(m_seq->begin(),m_seq->end(),o);
499  if ( j == m_seq->end() ) {
501  }
502  m_seq->erase(j);
503  m_setup.s->v.erase(i);
504  std::for_each(m_setup.s->m_idx.begin(),
505  m_setup.s->m_idx.end(),
506  array::decrement(*idx));
507  *idx = -1;
508  return o;
509  }
510  }
512  return nullptr;
513 }
union Containers::KeyedObjectManager::@6 m_setup
void * erase(long key, const void *obj)
Remove object from container (very inefficient if key is invalid)
seq_type * m_seq
Container holding array like container.
void onDirty() const
Callback when the container becomes dirty.
GAUDI_API void containerIsInconsistent()
Function to be called to indicate that the container is found to be inconsistent. ...
list i
Definition: ana.py:128
template<>
long Containers::KeyedObjectManager< __A >::erase ( seq_type::iterator  beg,
seq_type::iterator  end 
)

Definition at line 517 of file KeyedObjectManager.cpp.

519 {
520  typedef std::vector<long> id_type;
521  typedef id_type::iterator id_iter;
522  if ( beg == m_seq->begin() && end == m_seq->end() ) {
523  clear();
524  return OBJ_ERASED;
525  }
526  else if ( 0 == m_direct ) {
527  onDirty();
528  return erase(beg, end);
529  }
530  else {
531  long cnt = 0, nobj = end-beg;
532  id_type& idx = m_setup.s->m_idx;
533  for (auto & elem : idx) {
534  auto j = m_setup.s->v.begin()+(elem);
535  auto k = std::find(beg,end,*j);
536  if ( k != end ) {
537  m_setup.s->v.erase(j);
538  std::for_each(m_setup.s->m_idx.begin(),
539  m_setup.s->m_idx.end(),
540  array::decrement(elem));
541  elem = -1;
542  cnt++;
543  if ( cnt == nobj ) break;
544  }
545  }
546  m_seq->erase(beg, end);
547  if ( cnt != nobj ) {
549  }
550  return OBJ_ERASED;
551  }
552  // cannot reach this point
553 }
void clear()
Clear content of the vector.
union Containers::KeyedObjectManager::@6 m_setup
Object was removed, but not deleted.
Definition: KeyedTraits.h:22
void * erase(long key, const void *obj)
Remove object from container (very inefficient if key is invalid)
auto end(reverse_wrapper< T > &w)
Definition: reverse.h:47
seq_type * m_seq
Container holding array like container.
void onDirty() const
Callback when the container becomes dirty.
GAUDI_API void containerIsInconsistent()
Function to be called to indicate that the container is found to be inconsistent. ...
template<>
void * Containers::KeyedObjectManager< __V >::erase ( long  ,
const void *   
)

Definition at line 638 of file KeyedObjectManager.cpp.

640 {
642  return nullptr;
643 }
GAUDI_API void invalidContainerOperation()
Function to be called to indicate that an operation should be performed on the container or it's cont...
template<>
long Containers::KeyedObjectManager< __V >::erase ( seq_type::iterator  beg,
seq_type::iterator  end 
)

Definition at line 647 of file KeyedObjectManager.cpp.

649 {
650  if ( beg == m_seq->begin() && end == m_seq->end() ) {
651  clear();
652  return OBJ_ERASED;
653  }
655  return OBJ_ERASED;
656 }
void clear()
Clear content of the vector.
Object was removed, but not deleted.
Definition: KeyedTraits.h:22
auto end(reverse_wrapper< T > &w)
Definition: reverse.h:47
seq_type * m_seq
Container holding array like container.
GAUDI_API void invalidContainerOperation()
Function to be called to indicate that an operation should be performed on the container or it's cont...
template<class SETUP >
long Containers::KeyedObjectManager< SETUP >::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.

Definition at line 124 of file KeyedObjectManager.cpp.

129 {
130  *key = ++m_keyCtxt;
131  return insert(pBase, pObject, obj, *key);
132 }
long insert(ObjectContainerBase *b, ContainedObject *c, void *o, long *k)
Insert new object into container.
template<class SETUP >
long Containers::KeyedObjectManager< SETUP >::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 135 of file KeyedObjectManager.cpp.

140 {
142  if ( key > m_keyCtxt ) {
143  m_keyCtxt = key;
144  }
145  if ( 1==m_direct ) {
146  if ( m_setup.s->insert(obj, key) ) {
147  if ( !pObject->parent() ) {
148  pObject->setParent(pBase);
149  }
150  m_seq->push_back(obj);
151  return OBJ_INSERTED;
152  }
153  }
154  else if ( key == long(m_setup.s->v.size()) ) {
155  m_setup.s->v.push_back(obj);
156  if ( !pObject->parent() ) {
157  pObject->setParent(pBase);
158  }
159  m_seq->push_back(obj);
160  return OBJ_INSERTED;
161  }
162  else {
163  // Document is dirty now...
164  // need to copy all pointers from the vector to the map
165  onDirty();
166  return insert(pBase, pObject, obj, key);
167  }
169  return OBJ_CANNOT_INSERT;
170 }
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.
seq_type * m_seq
Container holding array like container.
void onDirty() const
Callback when the container becomes dirty.
long insert(ObjectContainerBase *b, ContainedObject *c, void *o, long *k)
Insert new object into container.
Object was inserted into the container.
Definition: KeyedTraits.h:23
Cannot insert object into container.
Definition: KeyedTraits.h:24
template<>
long Containers::KeyedObjectManager< __A >::insert ( ObjectContainerBase b,
ContainedObject c,
void *  o,
long *  k 
)

Definition at line 370 of file KeyedObjectManager.cpp.

374 {
375  // auto key creation only possible for direct access!
376  if ( 0 == m_direct ) {
377  m_seq->push_back(o);
378  m_setup.s->v.push_back(o);
379  if ( !c->parent() ) c->setParent(b);
380  *k = ++m_keyCtxt;
381  return OBJ_INSERTED;
382  }
384  return OBJ_CANNOT_INSERT;
385 }
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.
seq_type * m_seq
Container holding array like container.
Object was inserted into the container.
Definition: KeyedTraits.h:23
void setParent(ObjectContainerBase *value)
Update parent member.
Cannot insert object into container.
Definition: KeyedTraits.h:24
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 389 of file KeyedObjectManager.cpp.

393 {
394  if ( 0 == m_direct ) {
395  if ( k == m_keyCtxt+1 ) {
396  return insert(b, c, o, &k);
397  }
398  onDirty();
399  return insert(b, c, o, k);
400  }
402  if ( k > m_keyCtxt ) m_keyCtxt = k;
404  if ( k+1 > long(m_setup.s->m_idx.size()) ) {
405  m_setup.s->m_idx.resize(k+1, -1);
406  }
407  auto idx = m_setup.s->m_idx.begin()+k;
408  if ( *idx == -1 ) {
409  *idx = m_setup.s->v.size();
410  m_setup.s->v.push_back(o);
411  m_seq->push_back(o);
412  if ( !c->parent() ) c->setParent(b);
413  return OBJ_INSERTED;
414  }
416  return OBJ_CANNOT_INSERT;
417 }
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.
seq_type * m_seq
Container holding array like container.
void onDirty() const
Callback when the container becomes dirty.
long insert(ObjectContainerBase *b, ContainedObject *c, void *o, long *k)
Insert new object into container.
Object was inserted into the container.
Definition: KeyedTraits.h:23
void setParent(ObjectContainerBase *value)
Update parent member.
Cannot insert object into container.
Definition: KeyedTraits.h:24
template<>
long Containers::KeyedObjectManager< __V >::insert ( ObjectContainerBase b,
ContainedObject c,
void *  o,
long *  k 
)

Definition at line 586 of file KeyedObjectManager.cpp.

590 {
591  m_seq->push_back(o);
592  m_setup.s->v.push_back(o);
593  if ( !c->parent() ) c->setParent(b);
594  *k = (m_setup.s->v.size()-1);
595  return OBJ_INSERTED;
596 }
union Containers::KeyedObjectManager::@6 m_setup
const ObjectContainerBase * parent() const
Access to parent object.
seq_type * m_seq
Container holding array like container.
Object was inserted into the container.
Definition: KeyedTraits.h:23
void setParent(ObjectContainerBase *value)
Update parent member.
template<>
long Containers::KeyedObjectManager< __V >::insert ( ObjectContainerBase b,
ContainedObject c,
void *  o,
long  k 
)

Definition at line 600 of file KeyedObjectManager.cpp.

604 {
605  if ( k == long(m_setup.s->v.size()) ) {
606  return insert(b, c, o, &k);
607  }
609  return OBJ_CANNOT_INSERT;
610 }
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.
long insert(ObjectContainerBase *b, ContainedObject *c, void *o, long *k)
Insert new object into container.
Cannot insert object into container.
Definition: KeyedTraits.h:24
template<class SETUP >
long Containers::KeyedObjectManager< SETUP >::insertDirect ( ObjectContainerBase b,
ContainedObject c,
void *  o,
long  k 
)

Insert element into direct access map.

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 173 of file KeyedObjectManager.cpp.

178 {
180  if ( key > m_keyCtxt ) {
181  m_keyCtxt = key;
182  }
183  if ( 1==m_direct ) {
184  if ( m_setup.s->insert(obj, key) ) {
185  if ( !pObject->parent() ) {
186  pObject->setParent(pBase);
187  }
188  return OBJ_INSERTED;
189  }
190  }
191  else if ( key == long(m_setup.s->v.size()) ) {
192  m_setup.s->v.push_back(obj);
193  if ( !pObject->parent() ) {
194  pObject->setParent(pBase);
195  }
196  return OBJ_INSERTED;
197  }
198  else {
199  // Document is dirty now...
200  // need to copy all pointers from the vector to the map
201  onDirty();
202  return insertDirect(pBase, pObject, obj, key);
203  }
205  return OBJ_CANNOT_INSERT;
206 }
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.
void onDirty() const
Callback when the container becomes dirty.
Object was inserted into the container.
Definition: KeyedTraits.h:23
Cannot insert object into container.
Definition: KeyedTraits.h:24
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 421 of file KeyedObjectManager.cpp.

425 {
426  if ( 0 == m_direct ) {
427  if ( k == m_keyCtxt+1 ) {
428  m_setup.s->v.push_back(o);
429  if ( !c->parent() ) c->setParent(b);
430  ++m_keyCtxt;
431  return OBJ_INSERTED;
432  }
433  onDirty();
434  return insertDirect(b, c, o, k);
435  }
437  if ( k > m_keyCtxt ) m_keyCtxt = k;
439  if ( k+1 > long(m_setup.s->m_idx.size()) ) {
440  m_setup.s->m_idx.resize(k+1, -1);
441  }
442  auto idx = m_setup.s->m_idx.begin()+k;
443  if ( *idx == -1 ) {
444  *idx = m_setup.s->v.size();
445  m_setup.s->v.push_back(o);
446  if ( !c->parent() ) c->setParent(b);
447  return OBJ_INSERTED;
448  }
450  return OBJ_CANNOT_INSERT;
451 }
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.
void onDirty() const
Callback when the container becomes dirty.
Object was inserted into the container.
Definition: KeyedTraits.h:23
void setParent(ObjectContainerBase *value)
Update parent member.
Cannot insert object into container.
Definition: KeyedTraits.h:24
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 614 of file KeyedObjectManager.cpp.

618 {
619  if ( k == long(m_setup.s->v.size()) ) {
620  m_setup.s->v.push_back(o);
621  if ( !c->parent() ) c->setParent(b);
622  return OBJ_INSERTED;
623  }
625  return OBJ_CANNOT_INSERT;
626 }
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.
Object was inserted into the container.
Definition: KeyedTraits.h:23
void setParent(ObjectContainerBase *value)
Update parent member.
Cannot insert object into container.
Definition: KeyedTraits.h:24
template<class SETUP >
long Containers::KeyedObjectManager< SETUP >::isDirect ( ) const
inline

Check if the container is dirty.

Definition at line 72 of file KeyedObjectManager.h.

72 { return m_direct; }
template<class SETUP >
long Containers::KeyedObjectManager< SETUP >::isDirect ( ) const
inline

Check if the container is dirty.

Definition at line 72 of file KeyedObjectManager.h.

72 { return m_direct; }
template<class SETUP >
void* Containers::KeyedObjectManager< SETUP >::object ( long  key) const

Retrieve object identified by a key from the container.

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

Retrieve object identified by a key from the container.

Definition at line 234 of file KeyedObjectManager.cpp.

235 {
236  if ( 0 == m_direct ) onDirty();
237  auto i = m_setup.s->m.find(key);
238  if ( i != m_setup.s->m.end() ) return (*i).second;
239  return nullptr;
240 }
union Containers::KeyedObjectManager::@6 m_setup
void onDirty() const
Callback when the container becomes dirty.
list i
Definition: ana.py:128
template<>
void * Containers::KeyedObjectManager< __A >::object ( long  value) const

Definition at line 340 of file KeyedObjectManager.cpp.

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

Definition at line 573 of file KeyedObjectManager.cpp.

574 {
576  return nullptr;
577 }
GAUDI_API void invalidContainerOperation()
Function to be called to indicate that an operation should be performed on the container or it's cont...
template<class SETUP >
void Containers::KeyedObjectManager< SETUP >::onDirty ( ) const
private

Callback when the container becomes dirty.

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

Callback when the container becomes dirty.

Definition at line 115 of file KeyedObjectManager.cpp.

115  {
116  m_direct = 1;
117  for(int i = 0, stop = m_setup.s->v.size(); i < stop; i++ ) {
118  m_setup.s->insert(*(m_setup.s->v.begin()+i), i);
119  }
120  m_setup.s->v.clear();
121 }
union Containers::KeyedObjectManager::@6 m_setup
list i
Definition: ana.py:128
template<>
void Containers::KeyedObjectManager< __A >::onDirty ( ) const
private

Definition at line 357 of file KeyedObjectManager.cpp.

357  {
358  m_direct = 1;
359  m_setup.s->m_idx.reserve(m_setup.s->v.size()+1);
360  for(int i = 0, stop = m_setup.s->v.size(); i < stop; ++i) {
361  if ( !m_setup.s->v[i] ) {
363  }
364  m_setup.s->m_idx.push_back(i);
365  }
366 }
union Containers::KeyedObjectManager::@6 m_setup
GAUDI_API void containerIsInconsistent()
Function to be called to indicate that the container is found to be inconsistent. ...
list i
Definition: ana.py:128
template<>
void Containers::KeyedObjectManager< __V >::onDirty ( ) const
private

Definition at line 580 of file KeyedObjectManager.cpp.

580  {
582 }
GAUDI_API void invalidContainerOperation()
Function to be called to indicate that an operation should be performed on the container or it's cont...
template<class SETUP >
void Containers::KeyedObjectManager< SETUP >::reserve ( long  size)

Reserve buffer space.

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

Reserve buffer space.

Definition at line 243 of file KeyedObjectManager.cpp.

244 {
245  switch( m_direct ) {
246  case 1:
247  break;
248  case 0:
249  m_setup.s->v.reserve(len);
250  break;
251  default:
252  break;
253  }
254  m_seq->reserve(len);
255 }
union Containers::KeyedObjectManager::@6 m_setup
seq_type * m_seq
Container holding array like container.
template<class T >
void Containers::KeyedObjectManager< T >::setup ( void *  seq,
void **  rndm 
)

Setup of the Map and the parent object.

Definition at line 108 of file KeyedObjectManager.cpp.

109 {
110  m_seq = (seq_type*)seq;
111  *rndm = &m_setup.s->v;
112 }
union Containers::KeyedObjectManager::@6 m_setup
seq_type * m_seq
Container holding array like container.
std::vector< void * > seq_type
template<class SETUP >
void Containers::KeyedObjectManager< SETUP >::setup ( void *  seq,
void **  rndm 
)

Setup of the Map and the parent object.

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
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: