The Gaudi Framework  v30r4 (9b837755)
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 46 of file KeyedObjectManager.h.

Member Typedef Documentation

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

Definition at line 49 of file KeyedObjectManager.h.

Constructor & Destructor Documentation

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

Standard Constructor.

Definition at line 97 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", "KeyedContainer", StatusCode::FAILURE );
101  }
102  m_setup.s = ::new ( m_setup.buffer + sizeof( m_setup.s ) ) T();
103  m_keyCtxt = -1;
104 }
constexpr static const auto FAILURE
Definition: StatusCode.h:88
Define general base for Gaudi exception.
seq_type * m_seq
Container holding array like container.
union Containers::KeyedObjectManager::@2 m_setup
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 {
110  m_setup.s = ::new ( m_setup.buffer + sizeof( m_setup.s ) ) T( std::move( *other.m_setup.s ) );
111 
112  other.m_keyCtxt = -1;
113  other.m_seq = nullptr;
114  other.m_direct = 0;
115 }
STL namespace.
seq_type * m_seq
Container holding array like container.
union Containers::KeyedObjectManager::@2 m_setup
template<class T >
Containers::KeyedObjectManager< T >::~KeyedObjectManager ( )
virtual

Standard Destructor.

Definition at line 118 of file KeyedObjectManager.cpp.

119 {
120  m_setup.s->~T();
121 }
union Containers::KeyedObjectManager::@2 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 319 of file KeyedObjectManager.cpp.

320  {
321  return CLID_ObjectVector + 0x00030000;
322  }

Definition at line 324 of file KeyedObjectManager.cpp.

325  {
326  return CLID_ObjectVector + 0x00040000;
327  }
template<>
CLID Containers::KeyedObjectManager< __A >::classID ( )

Definition at line 540 of file KeyedObjectManager.cpp.

541  {
542  return CLID_ObjectVector + 0x00050000;
543  }
template<>
CLID Containers::KeyedObjectManager< __V >::classID ( )

Definition at line 636 of file KeyedObjectManager.cpp.

637  {
638  return CLID_ObjectVector + 0x00060000;
639  }
template<class T >
void Containers::KeyedObjectManager< T >::clear ( )

Clear content of the vector.

Definition at line 262 of file KeyedObjectManager.cpp.

263 {
264  clearDirect();
265  m_seq->clear();
266 }
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 269 of file KeyedObjectManager.cpp.

270 {
271  switch ( m_direct ) {
272  case 1:
273  m_setup.s->m.clear();
274  break;
275  case 0:
276  m_setup.s->v.clear();
277  break;
278  default:
279  break;
280  }
281  m_direct = 0;
282  m_keyCtxt = -1;
283 }
union Containers::KeyedObjectManager::@2 m_setup
template<>
void Containers::KeyedObjectManager< __A >::clearDirect ( )

Definition at line 453 of file KeyedObjectManager.cpp.

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

Definition at line 608 of file KeyedObjectManager.cpp.

609  {
610  m_setup.s->v.clear();
611  m_direct = 0;
612  m_keyCtxt = -1;
613  }
union Containers::KeyedObjectManager::@2 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 215 of file KeyedObjectManager.cpp.

216 {
217  typedef typename T::map_type MTYP;
218  typedef find<MTYP> FND;
219  if ( 1 == m_direct ) {
220  auto& m = m_setup.s->m;
221  auto i = ( obj ? std::find_if( m.begin(), m.end(), FND( obj ) ) : m_setup.s->m.find( key ) );
222  if ( i != m_setup.s->m.end() ) {
223  void* o = i->second;
224  auto j = std::find( m_seq->begin(), m_seq->end(), o );
225  if ( j != m_seq->end() ) {
226  m_seq->erase( j );
227  m_setup.s->m.erase( i );
228  return o;
229  }
230  }
232  }
233  onDirty();
234  return erase( key, obj );
235 }
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:94
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.
union Containers::KeyedObjectManager::@2 m_setup
template<class T >
long Containers::KeyedObjectManager< T >::erase ( seq_type::iterator  beg,
seq_type::iterator  end 
)

Remove object by sequential iterators.

Definition at line 287 of file KeyedObjectManager.cpp.

288 {
289  typedef typename T::map_type MTYP;
290  typedef find<MTYP> FND;
291  if ( 0 == m_direct ) {
292  onDirty();
293  return erase( beg, end );
294  }
295  if ( beg == m_seq->begin() && end == m_seq->end() ) {
296  clear();
297  } else {
298  for ( auto j = beg; j != end; ++j ) {
299  // auto& m = m_setup.s->m;
300  auto i = std::find_if( m_setup.s->m.begin(), m_setup.s->m.end(), FND( *j ) );
301  if ( i != m_setup.s->m.end() ) {
302  m_setup.s->m.erase( i );
303  continue;
304  }
306  }
307  m_seq->erase( beg, end );
308  }
309  return OBJ_ERASED;
310 }
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)
T erase(T...args)
void onDirty() const
Callback when the container becomes dirty.
Object was removed, but not deleted.
Definition: KeyedTraits.h:26
T find_if(T...args)
T begin(T...args)
seq_type * m_seq
Container holding array like container.
union Containers::KeyedObjectManager::@2 m_setup
template<>
void * Containers::KeyedObjectManager< __A >::erase ( long  key,
const void *  obj 
)

Definition at line 463 of file KeyedObjectManager.cpp.

464  {
465  if ( 0 == m_direct ) {
466  onDirty();
467  return erase( key, obj );
468  }
469  if ( obj ) {
470  auto& idx = m_setup.s->m_idx;
471  for ( auto& elem : idx ) {
472  auto j = m_setup.s->v.begin() + ( elem );
473  auto k = std::find( m_seq->begin(), m_seq->end(), *j );
474  if ( *j == obj ) {
475  void* o = *j;
476  m_seq->erase( k );
477  m_setup.s->v.erase( j );
478  std::for_each( m_setup.s->m_idx.begin(), m_setup.s->m_idx.end(), array::decrement( elem ) );
479  elem = -1;
480  return o;
481  }
482  }
483  } else if ( key >= 0 && key < long( m_setup.s->m_idx.size() ) ) {
484  auto idx = m_setup.s->m_idx.begin() + key;
485  if ( *idx != -1 ) {
486  auto i = m_setup.s->v.begin() + ( *idx );
487  if ( i == m_setup.s->v.end() ) {
489  }
490  void* o = *i;
491  auto j = std::find( m_seq->begin(), m_seq->end(), o );
492  if ( j == m_seq->end() ) {
494  }
495  m_seq->erase( j );
496  m_setup.s->v.erase( i );
497  std::for_each( m_setup.s->m_idx.begin(), m_setup.s->m_idx.end(), array::decrement( *idx ) );
498  *idx = -1;
499  return o;
500  }
501  }
503  return nullptr;
504  }
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.
union Containers::KeyedObjectManager::@2 m_setup
template<>
long Containers::KeyedObjectManager< __A >::erase ( seq_type::iterator  beg,
seq_type::iterator  end 
)

Definition at line 508 of file KeyedObjectManager.cpp.

509  {
510  if ( beg == m_seq->begin() && end == m_seq->end() ) {
511  clear();
512  return OBJ_ERASED;
513  } else if ( 0 == m_direct ) {
514  onDirty();
515  return erase( beg, end );
516  } else {
517  long cnt = 0, nobj = end - beg;
518  auto& idx = m_setup.s->m_idx;
519  for ( auto& elem : idx ) {
520  auto j = m_setup.s->v.begin() + ( elem );
521  auto k = std::find( beg, end, *j );
522  if ( k != end ) {
523  m_setup.s->v.erase( j );
524  std::for_each( m_setup.s->m_idx.begin(), m_setup.s->m_idx.end(), array::decrement( elem ) );
525  elem = -1;
526  cnt++;
527  if ( cnt == nobj ) break;
528  }
529  }
530  m_seq->erase( beg, end );
531  if ( cnt != nobj ) {
533  }
534  return OBJ_ERASED;
535  }
536  // cannot reach this point
537  }
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)
T erase(T...args)
void onDirty() const
Callback when the container becomes dirty.
Object was removed, but not deleted.
Definition: KeyedTraits.h:26
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
template<>
void * Containers::KeyedObjectManager< __V >::erase ( long  ,
const void *   
)

Definition at line 617 of file KeyedObjectManager.cpp.

618  {
620  return nullptr;
621  }
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 625 of file KeyedObjectManager.cpp.

626  {
627  if ( beg == m_seq->begin() && end == m_seq->end() ) {
628  clear();
629  return OBJ_ERASED;
630  }
632  return OBJ_ERASED;
633  }
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...
Object was removed, but not deleted.
Definition: KeyedTraits.h:26
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 142 of file KeyedObjectManager.cpp.

144 {
145  *key = ++m_keyCtxt;
146  return insert( pBase, pObject, obj, *key );
147 }
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 150 of file KeyedObjectManager.cpp.

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

Definition at line 377 of file KeyedObjectManager.cpp.

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

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

Definition at line 573 of file KeyedObjectManager.cpp.

574  {
575  m_seq->push_back( o );
576  m_setup.s->v.push_back( o );
577  if ( !c->parent() ) c->setParent( b );
578  *k = ( m_setup.s->v.size() - 1 );
579  return OBJ_INSERTED;
580  }
Object was inserted into the container.
Definition: KeyedTraits.h:27
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.
union Containers::KeyedObjectManager::@2 m_setup
template<>
long Containers::KeyedObjectManager< __V >::insert ( ObjectContainerBase b,
ContainedObject c,
void *  o,
long  k 
)

Definition at line 584 of file KeyedObjectManager.cpp.

585  {
586  if ( k == long( m_setup.s->v.size() ) ) {
587  return insert( b, c, o, &k );
588  }
590  return OBJ_CANNOT_INSERT;
591  }
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:28
union Containers::KeyedObjectManager::@2 m_setup
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 183 of file KeyedObjectManager.cpp.

185 {
187  if ( key > m_keyCtxt ) {
188  m_keyCtxt = key;
189  }
190  if ( 1 == m_direct ) {
191  if ( m_setup.s->insert( obj, key ) ) {
192  if ( !pObject->parent() ) {
193  pObject->setParent( pBase );
194  }
195  return OBJ_INSERTED;
196  }
197  } else if ( key == long( m_setup.s->v.size() ) ) {
198  m_setup.s->v.push_back( obj );
199  if ( !pObject->parent() ) {
200  pObject->setParent( pBase );
201  }
202  return OBJ_INSERTED;
203  } else {
204  // Document is dirty now...
205  // need to copy all pointers from the vector to the map
206  onDirty();
207  return insertDirect( pBase, pObject, obj, key );
208  }
210  return OBJ_CANNOT_INSERT;
211 }
Object was inserted into the container.
Definition: KeyedTraits.h:27
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:28
long insertDirect(ObjectContainerBase *b, ContainedObject *c, void *o, long k)
Insert element into direct access map.
union Containers::KeyedObjectManager::@2 m_setup
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 422 of file KeyedObjectManager.cpp.

423  {
424  if ( 0 == m_direct ) {
425  if ( k == m_keyCtxt + 1 ) {
426  m_setup.s->v.push_back( o );
427  if ( !c->parent() ) c->setParent( b );
428  ++m_keyCtxt;
429  return OBJ_INSERTED;
430  }
431  onDirty();
432  return insertDirect( b, c, o, k );
433  }
435  if ( k > m_keyCtxt ) m_keyCtxt = k;
437  if ( k + 1 > long( m_setup.s->m_idx.size() ) ) {
438  m_setup.s->m_idx.resize( k + 1, -1 );
439  }
440  auto idx = m_setup.s->m_idx.begin() + k;
441  if ( *idx == -1 ) {
442  *idx = m_setup.s->v.size();
443  m_setup.s->v.push_back( o );
444  if ( !c->parent() ) c->setParent( b );
445  return OBJ_INSERTED;
446  }
448  return OBJ_CANNOT_INSERT;
449  }
Object was inserted into the container.
Definition: KeyedTraits.h:27
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.
Cannot insert object into container.
Definition: KeyedTraits.h:28
void setParent(ObjectContainerBase *value)
Update parent member.
long insertDirect(ObjectContainerBase *b, ContainedObject *c, void *o, long k)
Insert element into direct access map.
union Containers::KeyedObjectManager::@2 m_setup
template<>
long Containers::KeyedObjectManager< __V >::insertDirect ( ObjectContainerBase b,
ContainedObject c,
void *  o,
long  k 
)

Definition at line 595 of file KeyedObjectManager.cpp.

596  {
597  if ( k == long( m_setup.s->v.size() ) ) {
598  m_setup.s->v.push_back( o );
599  if ( !c->parent() ) c->setParent( b );
600  return OBJ_INSERTED;
601  }
603  return OBJ_CANNOT_INSERT;
604  }
Object was inserted into the container.
Definition: KeyedTraits.h:27
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:28
void setParent(ObjectContainerBase *value)
Update parent member.
union Containers::KeyedObjectManager::@2 m_setup
template<class SETUP >
long Containers::KeyedObjectManager< SETUP >::isDirect ( ) const
inline

Check if the container is dirty.

Definition at line 75 of file KeyedObjectManager.h.

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

Retrieve object identified by a key from the container.

Definition at line 238 of file KeyedObjectManager.cpp.

239 {
240  if ( 0 == m_direct ) onDirty();
241  auto i = m_setup.s->m.find( key );
242  if ( i != m_setup.s->m.end() ) return ( *i ).second;
243  return nullptr;
244 }
void onDirty() const
Callback when the container becomes dirty.
union Containers::KeyedObjectManager::@2 m_setup
template<>
void * Containers::KeyedObjectManager< __A >::object ( long  value) const

Definition at line 346 of file KeyedObjectManager.cpp.

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

Definition at line 559 of file KeyedObjectManager.cpp.

560  {
562  return nullptr;
563  }
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 132 of file KeyedObjectManager.cpp.

133 {
134  m_direct = 1;
135  auto& s = *m_setup.s;
136  long i = 0;
137  for ( auto p : s.v ) s.insert( p, i++ );
138  s.v.clear();
139 }
union Containers::KeyedObjectManager::@2 m_setup
template<>
void Containers::KeyedObjectManager< __A >::onDirty ( ) const
private

Definition at line 363 of file KeyedObjectManager.cpp.

364  {
365  m_direct = 1;
366  m_setup.s->m_idx.reserve( m_setup.s->v.size() + 1 );
367  for ( int i = 0, stop = m_setup.s->v.size(); i < stop; ++i ) {
368  if ( !m_setup.s->v[i] ) {
370  }
371  m_setup.s->m_idx.push_back( i );
372  }
373  }
GAUDI_API void containerIsInconsistent()
Function to be called to indicate that the container is found to be inconsistent. ...
union Containers::KeyedObjectManager::@2 m_setup
template<>
void Containers::KeyedObjectManager< __V >::onDirty ( ) const
private

Definition at line 566 of file KeyedObjectManager.cpp.

567  {
569  }
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 247 of file KeyedObjectManager.cpp.

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

Setup of the Map and the parent object.

Definition at line 125 of file KeyedObjectManager.cpp.

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

Member Data Documentation

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

Buffer space to hold keyed container.

Definition at line 57 of file KeyedObjectManager.h.

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

Dirty flag.

Definition at line 53 of file KeyedObjectManager.h.

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

Definition at line 54 of file KeyedObjectManager.h.

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

Container holding array like container.

Definition at line 51 of file KeyedObjectManager.h.

union { ... } Containers::KeyedObjectManager< SETUP >::m_setup
template<class SETUP >
SETUP* Containers::KeyedObjectManager< SETUP >::s

Definition at line 58 of file KeyedObjectManager.h.


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