The Gaudi Framework  v33r0 (d5ea422b)
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 55 of file KeyedObjectManager.h.

Member Typedef Documentation

◆ seq_type

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

Definition at line 57 of file KeyedObjectManager.h.

Constructor & Destructor Documentation

◆ KeyedObjectManager() [1/2]

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

Standard Constructor.

Definition at line 98 of file KeyedObjectManager.cpp.

98  : m_seq( nullptr ), m_direct( 0 ) {
99  if ( sizeof( typename T::map_type ) > sizeof( m_setup.buffer ) ) {
100  throw GaudiException( "Basic STL contaier sizes are incompatible", "KeyedContainer", StatusCode::FAILURE );
101  }
102  m_setup.s = ::new ( m_setup.buffer + sizeof( m_setup.s ) ) T();
103  m_keyCtxt = -1;
104 }
Define general base for Gaudi exception.
constexpr static const auto FAILURE
Definition: StatusCode.h:97
seq_type * m_seq
Container holding array like container.
union Containers::KeyedObjectManager::@2 m_setup

◆ KeyedObjectManager() [2/2]

template<class T >
Containers::KeyedObjectManager< T >::KeyedObjectManager ( KeyedObjectManager< SETUP > &&  other)

Definition at line 107 of file KeyedObjectManager.cpp.

108  : m_seq( nullptr ), m_direct( other.m_direct ), m_keyCtxt( other.m_keyCtxt ) {
109  m_setup.s = ::new ( m_setup.buffer + sizeof( m_setup.s ) ) T( std::move( *other.m_setup.s ) );
110 
111  other.m_keyCtxt = -1;
112  other.m_seq = nullptr;
113  other.m_direct = 0;
114 }
STL namespace.
seq_type * m_seq
Container holding array like container.
union Containers::KeyedObjectManager::@2 m_setup

◆ ~KeyedObjectManager()

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

Standard Destructor.

Definition at line 117 of file KeyedObjectManager.cpp.

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

Member Function Documentation

◆ classID() [1/5]

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

Access CLID for this type of container.

◆ classID() [2/5]

Definition at line 293 of file KeyedObjectManager.cpp.

293  {
294  return CLID_ObjectVector + 0x00030000;
295  }

◆ classID() [3/5]

Definition at line 297 of file KeyedObjectManager.cpp.

297  {
298  return CLID_ObjectVector + 0x00040000;
299  }

◆ classID() [4/5]

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

Definition at line 487 of file KeyedObjectManager.cpp.

487  {
488  return CLID_ObjectVector + 0x00050000;
489  }

◆ classID() [5/5]

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

Definition at line 571 of file KeyedObjectManager.cpp.

571  {
572  return CLID_ObjectVector + 0x00060000;
573  }

◆ clear()

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

Clear content of the vector.

Definition at line 240 of file KeyedObjectManager.cpp.

240  {
241  clearDirect();
242  m_seq->clear();
243 }
void clearDirect()
Clear all direct access fields.
T clear(T... args)
seq_type * m_seq
Container holding array like container.

◆ clearDirect() [1/3]

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

Clear all direct access fields.

Definition at line 246 of file KeyedObjectManager.cpp.

246  {
247  switch ( m_direct ) {
248  case 1:
249  m_setup.s->m.clear();
250  break;
251  case 0:
252  m_setup.s->v.clear();
253  break;
254  default:
255  break;
256  }
257  m_direct = 0;
258  m_keyCtxt = -1;
259 }
union Containers::KeyedObjectManager::@2 m_setup

◆ clearDirect() [2/3]

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

Definition at line 409 of file KeyedObjectManager.cpp.

409  {
410  m_setup.s->v.clear();
411  m_setup.s->m_idx.clear();
412  m_direct = 0;
413  m_keyCtxt = -1;
414  }
union Containers::KeyedObjectManager::@2 m_setup

◆ clearDirect() [3/3]

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

Definition at line 546 of file KeyedObjectManager.cpp.

546  {
547  m_setup.s->v.clear();
548  m_direct = 0;
549  m_keyCtxt = -1;
550  }
union Containers::KeyedObjectManager::@2 m_setup

◆ erase() [1/6]

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

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

Definition at line 196 of file KeyedObjectManager.cpp.

196  {
197  typedef typename T::map_type MTYP;
198  typedef find<MTYP> FND;
199  if ( 1 == m_direct ) {
200  auto& m = m_setup.s->m;
201  auto i = ( obj ? std::find_if( m.begin(), m.end(), FND( obj ) ) : m_setup.s->m.find( key ) );
202  if ( i != m_setup.s->m.end() ) {
203  void* o = i->second;
204  auto j = std::find( m_seq->begin(), m_seq->end(), o );
205  if ( j != m_seq->end() ) {
206  m_seq->erase( j );
207  m_setup.s->m.erase( i );
208  return o;
209  }
210  }
212  }
213  onDirty();
214  return erase( key, obj );
215 }
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)
void onDirty() const
Callback when the container becomes dirty.
constexpr double m
T erase(T... args)
T find_if(T... args)
T begin(T... args)
seq_type * m_seq
Container holding array like container.
union Containers::KeyedObjectManager::@2 m_setup

◆ erase() [2/6]

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

Remove object by sequential iterators.

Definition at line 263 of file KeyedObjectManager.cpp.

263  {
264  typedef typename T::map_type MTYP;
265  typedef find<MTYP> FND;
266  if ( 0 == m_direct ) {
267  onDirty();
268  return erase( beg, end );
269  }
270  if ( beg == m_seq->begin() && end == m_seq->end() ) {
271  clear();
272  } else {
273  for ( auto j = beg; j != end; ++j ) {
274  // auto& m = m_setup.s->m;
275  auto i = std::find_if( m_setup.s->m.begin(), m_setup.s->m.end(), FND( *j ) );
276  if ( i != m_setup.s->m.end() ) {
277  m_setup.s->m.erase( i );
278  continue;
279  }
281  }
282  m_seq->erase( beg, end );
283  }
284  return OBJ_ERASED;
285 }
void clear()
Clear content of the vector.
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)
void onDirty() const
Callback when the container becomes dirty.
T erase(T... args)
Object was removed, but not deleted.
Definition: KeyedTraits.h:35
def end
Definition: IOTest.py:123
T find_if(T... args)
T begin(T... args)
seq_type * m_seq
Container holding array like container.
union Containers::KeyedObjectManager::@2 m_setup

◆ erase() [3/6]

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

Definition at line 418 of file KeyedObjectManager.cpp.

418  {
419  if ( 0 == m_direct ) {
420  onDirty();
421  return erase( key, obj );
422  }
423  if ( obj ) {
424  auto& idx = m_setup.s->m_idx;
425  for ( auto& elem : idx ) {
426  auto j = m_setup.s->v.begin() + ( elem );
427  auto k = std::find( m_seq->begin(), m_seq->end(), *j );
428  if ( *j == obj ) {
429  void* o = *j;
430  m_seq->erase( k );
431  m_setup.s->v.erase( j );
432  std::for_each( m_setup.s->m_idx.begin(), m_setup.s->m_idx.end(), array::decrement( elem ) );
433  elem = -1;
434  return o;
435  }
436  }
437  } else if ( key >= 0 && key < long( m_setup.s->m_idx.size() ) ) {
438  auto idx = m_setup.s->m_idx.begin() + key;
439  if ( *idx != -1 ) {
440  auto i = m_setup.s->v.begin() + ( *idx );
441  if ( i == m_setup.s->v.end() ) { containerIsInconsistent(); }
442  void* o = *i;
443  auto j = std::find( m_seq->begin(), m_seq->end(), o );
444  if ( j == m_seq->end() ) { containerIsInconsistent(); }
445  m_seq->erase( j );
446  m_setup.s->v.erase( i );
447  std::for_each( m_setup.s->m_idx.begin(), m_setup.s->m_idx.end(), array::decrement( *idx ) );
448  *idx = -1;
449  return o;
450  }
451  }
453  return nullptr;
454  }
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)
void onDirty() const
Callback when the container becomes dirty.
T erase(T... args)
T find(T... args)
T begin(T... args)
T for_each(T... args)
seq_type * m_seq
Container holding array like container.
union Containers::KeyedObjectManager::@2 m_setup

◆ erase() [4/6]

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

Definition at line 458 of file KeyedObjectManager.cpp.

458  {
459  if ( beg == m_seq->begin() && end == m_seq->end() ) {
460  clear();
461  return OBJ_ERASED;
462  } else if ( 0 == m_direct ) {
463  onDirty();
464  return erase( beg, end );
465  } else {
466  long cnt = 0, nobj = end - beg;
467  auto& idx = m_setup.s->m_idx;
468  for ( auto& elem : idx ) {
469  auto j = m_setup.s->v.begin() + ( elem );
470  auto k = std::find( beg, end, *j );
471  if ( k != end ) {
472  m_setup.s->v.erase( j );
473  std::for_each( m_setup.s->m_idx.begin(), m_setup.s->m_idx.end(), array::decrement( elem ) );
474  elem = -1;
475  cnt++;
476  if ( cnt == nobj ) break;
477  }
478  }
479  m_seq->erase( beg, end );
480  if ( cnt != nobj ) { containerIsInconsistent(); }
481  return OBJ_ERASED;
482  }
483  // cannot reach this point
484  }
void clear()
Clear content of the vector.
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)
void onDirty() const
Callback when the container becomes dirty.
T erase(T... args)
Object was removed, but not deleted.
Definition: KeyedTraits.h:35
def end
Definition: IOTest.py:123
T find(T... args)
T begin(T... args)
T for_each(T... args)
seq_type * m_seq
Container holding array like container.
union Containers::KeyedObjectManager::@2 m_setup

◆ erase() [5/6]

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

Definition at line 554 of file KeyedObjectManager.cpp.

554  {
556  return nullptr;
557  }
GAUDI_API void invalidContainerOperation()
Function to be called to indicate that an operation should be performed on the container or it's cont...

◆ erase() [6/6]

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

Definition at line 561 of file KeyedObjectManager.cpp.

561  {
562  if ( beg == m_seq->begin() && end == m_seq->end() ) {
563  clear();
564  return OBJ_ERASED;
565  }
567  return OBJ_ERASED;
568  }
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's cont...
Object was removed, but not deleted.
Definition: KeyedTraits.h:35
def end
Definition: IOTest.py:123
T begin(T... args)
seq_type * m_seq
Container holding array like container.

◆ insert() [1/6]

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

Insert new object into container.

Definition at line 138 of file KeyedObjectManager.cpp.

139  {
140  *key = ++m_keyCtxt;
141  return insert( pBase, pObject, obj, *key );
142 }
long insert(ObjectContainerBase *b, ContainedObject *c, void *o, long *k)
Insert new object into container.

◆ insert() [2/6]

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

Insert new object into container.

Keep major key value

Definition at line 145 of file KeyedObjectManager.cpp.

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

◆ insert() [3/6]

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

Definition at line 342 of file KeyedObjectManager.cpp.

342  {
343  // auto key creation only possible for direct access!
344  if ( 0 == m_direct ) {
345  m_seq->push_back( o );
346  m_setup.s->v.push_back( o );
347  if ( !c->parent() ) c->setParent( b );
348  *k = ++m_keyCtxt;
349  return OBJ_INSERTED;
350  }
352  return OBJ_CANNOT_INSERT;
353  }
Object was inserted into the container.
Definition: KeyedTraits.h:36
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:37
seq_type * m_seq
Container holding array like container.
union Containers::KeyedObjectManager::@2 m_setup

◆ insert() [4/6]

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

Keep major key value

Extend redirection array and insert

Definition at line 357 of file KeyedObjectManager.cpp.

357  {
358  if ( 0 == m_direct ) {
359  if ( k == m_keyCtxt + 1 ) { return insert( b, c, o, &k ); }
360  onDirty();
361  return insert( b, c, o, k );
362  }
364  if ( k > m_keyCtxt ) m_keyCtxt = k;
366  if ( k + 1 > long( m_setup.s->m_idx.size() ) ) { m_setup.s->m_idx.resize( k + 1, -1 ); }
367  auto idx = m_setup.s->m_idx.begin() + k;
368  if ( *idx == -1 ) {
369  *idx = m_setup.s->v.size();
370  m_setup.s->v.push_back( o );
371  m_seq->push_back( o );
372  if ( !c->parent() ) c->setParent( b );
373  return OBJ_INSERTED;
374  }
376  return OBJ_CANNOT_INSERT;
377  }
Object was inserted into the container.
Definition: KeyedTraits.h:36
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.
T push_back(T... args)
long insert(ObjectContainerBase *b, ContainedObject *c, void *o, long *k)
Insert new object into container.
Cannot insert object into container.
Definition: KeyedTraits.h:37
seq_type * m_seq
Container holding array like container.
union Containers::KeyedObjectManager::@2 m_setup

◆ insert() [5/6]

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

Definition at line 516 of file KeyedObjectManager.cpp.

516  {
517  m_seq->push_back( o );
518  m_setup.s->v.push_back( o );
519  if ( !c->parent() ) c->setParent( b );
520  *k = ( m_setup.s->v.size() - 1 );
521  return OBJ_INSERTED;
522  }
Object was inserted into the container.
Definition: KeyedTraits.h:36
T push_back(T... args)
seq_type * m_seq
Container holding array like container.
union Containers::KeyedObjectManager::@2 m_setup

◆ insert() [6/6]

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

Definition at line 526 of file KeyedObjectManager.cpp.

526  {
527  if ( k == long( m_setup.s->v.size() ) ) { return insert( b, c, o, &k ); }
529  return OBJ_CANNOT_INSERT;
530  }
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:37
union Containers::KeyedObjectManager::@2 m_setup

◆ insertDirect() [1/3]

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

Insert element into direct access map.

Keep major key value

Definition at line 171 of file KeyedObjectManager.cpp.

172  {
174  if ( key > m_keyCtxt ) { m_keyCtxt = key; }
175  if ( 1 == m_direct ) {
176  if ( m_setup.s->insert( obj, key ) ) {
177  if ( !pObject->parent() ) { pObject->setParent( pBase ); }
178  return OBJ_INSERTED;
179  }
180  } else if ( key == long( m_setup.s->v.size() ) ) {
181  m_setup.s->v.push_back( obj );
182  if ( !pObject->parent() ) { pObject->setParent( pBase ); }
183  return OBJ_INSERTED;
184  } else {
185  // Document is dirty now...
186  // need to copy all pointers from the vector to the map
187  onDirty();
188  return insertDirect( pBase, pObject, obj, key );
189  }
191  return OBJ_CANNOT_INSERT;
192 }
Object was inserted into the container.
Definition: KeyedTraits.h:36
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.
Cannot insert object into container.
Definition: KeyedTraits.h:37
long insertDirect(ObjectContainerBase *b, ContainedObject *c, void *o, long k)
Insert element into direct access map.
union Containers::KeyedObjectManager::@2 m_setup

◆ insertDirect() [2/3]

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

Keep major key value

Extend redirection array and insert

Definition at line 381 of file KeyedObjectManager.cpp.

381  {
382  if ( 0 == m_direct ) {
383  if ( k == m_keyCtxt + 1 ) {
384  m_setup.s->v.push_back( o );
385  if ( !c->parent() ) c->setParent( b );
386  ++m_keyCtxt;
387  return OBJ_INSERTED;
388  }
389  onDirty();
390  return insertDirect( b, c, o, k );
391  }
393  if ( k > m_keyCtxt ) m_keyCtxt = k;
395  if ( k + 1 > long( m_setup.s->m_idx.size() ) ) { m_setup.s->m_idx.resize( k + 1, -1 ); }
396  auto idx = m_setup.s->m_idx.begin() + k;
397  if ( *idx == -1 ) {
398  *idx = m_setup.s->v.size();
399  m_setup.s->v.push_back( o );
400  if ( !c->parent() ) c->setParent( b );
401  return OBJ_INSERTED;
402  }
404  return OBJ_CANNOT_INSERT;
405  }
Object was inserted into the container.
Definition: KeyedTraits.h:36
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.
Cannot insert object into container.
Definition: KeyedTraits.h:37
long insertDirect(ObjectContainerBase *b, ContainedObject *c, void *o, long k)
Insert element into direct access map.
union Containers::KeyedObjectManager::@2 m_setup

◆ insertDirect() [3/3]

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

Definition at line 534 of file KeyedObjectManager.cpp.

534  {
535  if ( k == long( m_setup.s->v.size() ) ) {
536  m_setup.s->v.push_back( o );
537  if ( !c->parent() ) c->setParent( b );
538  return OBJ_INSERTED;
539  }
541  return OBJ_CANNOT_INSERT;
542  }
Object was inserted into the container.
Definition: KeyedTraits.h:36
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:37
union Containers::KeyedObjectManager::@2 m_setup

◆ isDirect()

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

Check if the container is dirty.

Definition at line 83 of file KeyedObjectManager.h.

83 { return m_direct; }

◆ object() [1/3]

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

Retrieve object identified by a key from the container.

Definition at line 218 of file KeyedObjectManager.cpp.

218  {
219  if ( 0 == m_direct ) onDirty();
220  auto i = m_setup.s->m.find( key );
221  if ( i != m_setup.s->m.end() ) return ( *i ).second;
222  return nullptr;
223 }
void onDirty() const
Callback when the container becomes dirty.
union Containers::KeyedObjectManager::@2 m_setup

◆ object() [2/3]

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

Definition at line 317 of file KeyedObjectManager.cpp.

317  {
318 #ifdef CHECK_KEYED_CONTAINER
319  unsigned long siz = m_setup.s->m_idx.size();
320  if ( value >= 0 && size_t( value ) < siz ) {
321  long ent = *( m_setup.s->m_idx.begin() + value );
322  if ( ent >= 0 ) { return *( m_setup.s->v.begin() + ent ); }
323  }
324  return nullptr;
325 #else
326  return *( m_setup.s->v.begin() + ( *( m_setup.s->m_idx.begin() + value ) ) );
327 #endif
328  }
union Containers::KeyedObjectManager::@2 m_setup

◆ object() [3/3]

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

Definition at line 504 of file KeyedObjectManager.cpp.

504  {
506  return nullptr;
507  }
GAUDI_API void invalidContainerOperation()
Function to be called to indicate that an operation should be performed on the container or it's cont...

◆ onDirty() [1/3]

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

Callback when the container becomes dirty.

Definition at line 129 of file KeyedObjectManager.cpp.

129  {
130  m_direct = 1;
131  auto& s = *m_setup.s;
132  long i = 0;
133  for ( auto p : s.v ) s.insert( p, i++ );
134  s.v.clear();
135 }
union Containers::KeyedObjectManager::@2 m_setup

◆ onDirty() [2/3]

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

Definition at line 331 of file KeyedObjectManager.cpp.

331  {
332  m_direct = 1;
333  m_setup.s->m_idx.reserve( m_setup.s->v.size() + 1 );
334  for ( int i = 0, stop = m_setup.s->v.size(); i < stop; ++i ) {
335  if ( !m_setup.s->v[i] ) { containerIsInconsistent(); }
336  m_setup.s->m_idx.push_back( i );
337  }
338  }
GAUDI_API void containerIsInconsistent()
Function to be called to indicate that the container is found to be inconsistent.
union Containers::KeyedObjectManager::@2 m_setup

◆ onDirty() [3/3]

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

Definition at line 510 of file KeyedObjectManager.cpp.

510  {
512  }
GAUDI_API void invalidContainerOperation()
Function to be called to indicate that an operation should be performed on the container or it's cont...

◆ reserve()

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

Reserve buffer space.

Definition at line 226 of file KeyedObjectManager.cpp.

226  {
227  switch ( m_direct ) {
228  case 1:
229  break;
230  case 0:
231  m_setup.s->v.reserve( len );
232  break;
233  default:
234  break;
235  }
236  m_seq->reserve( len );
237 }
seq_type * m_seq
Container holding array like container.
T reserve(T... args)
union Containers::KeyedObjectManager::@2 m_setup

◆ setup()

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

Setup of the Map and the parent object.

Definition at line 123 of file KeyedObjectManager.cpp.

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

Member Data Documentation

◆ buffer

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

Buffer space to hold keyed container.

Definition at line 65 of file KeyedObjectManager.h.

◆ m_direct

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

Dirty flag.

Definition at line 61 of file KeyedObjectManager.h.

◆ m_keyCtxt

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

Definition at line 62 of file KeyedObjectManager.h.

◆ m_seq

template<class SETUP >
seq_type* Containers::KeyedObjectManager< SETUP >::m_seq
private

Container holding array like container.

Definition at line 59 of file KeyedObjectManager.h.

◆ m_setup

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

◆ s

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

Definition at line 66 of file KeyedObjectManager.h.


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