The Gaudi Framework  v31r0 (aeb156f0)
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 88 of file KeyedObjectManager.cpp.

88  : m_seq( nullptr ), m_direct( 0 ) {
89  if ( sizeof( typename T::map_type ) > sizeof( m_setup.buffer ) ) {
90  throw GaudiException( "Basic STL contaier sizes are incompatible", "KeyedContainer", StatusCode::FAILURE );
91  }
92  m_setup.s = ::new ( m_setup.buffer + sizeof( m_setup.s ) ) T();
93  m_keyCtxt = -1;
94 }
Define general base for Gaudi exception.
constexpr static const auto FAILURE
Definition: StatusCode.h:86
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 97 of file KeyedObjectManager.cpp.

98  : m_seq( nullptr ), m_direct( other.m_direct ), m_keyCtxt( other.m_keyCtxt ) {
99  m_setup.s = ::new ( m_setup.buffer + sizeof( m_setup.s ) ) T( std::move( *other.m_setup.s ) );
100 
101  other.m_keyCtxt = -1;
102  other.m_seq = nullptr;
103  other.m_direct = 0;
104 }
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 107 of file KeyedObjectManager.cpp.

107  {
108  m_setup.s->~T();
109 }
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 283 of file KeyedObjectManager.cpp.

283  {
284  return CLID_ObjectVector + 0x00030000;
285  }

Definition at line 287 of file KeyedObjectManager.cpp.

287  {
288  return CLID_ObjectVector + 0x00040000;
289  }
template<>
CLID Containers::KeyedObjectManager< __A >::classID ( )

Definition at line 477 of file KeyedObjectManager.cpp.

477  {
478  return CLID_ObjectVector + 0x00050000;
479  }
template<>
CLID Containers::KeyedObjectManager< __V >::classID ( )

Definition at line 561 of file KeyedObjectManager.cpp.

561  {
562  return CLID_ObjectVector + 0x00060000;
563  }
template<class T >
void Containers::KeyedObjectManager< T >::clear ( )

Clear content of the vector.

Definition at line 230 of file KeyedObjectManager.cpp.

230  {
231  clearDirect();
232  m_seq->clear();
233 }
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 236 of file KeyedObjectManager.cpp.

236  {
237  switch ( m_direct ) {
238  case 1:
239  m_setup.s->m.clear();
240  break;
241  case 0:
242  m_setup.s->v.clear();
243  break;
244  default:
245  break;
246  }
247  m_direct = 0;
248  m_keyCtxt = -1;
249 }
union Containers::KeyedObjectManager::@2 m_setup
template<>
void Containers::KeyedObjectManager< __A >::clearDirect ( )

Definition at line 399 of file KeyedObjectManager.cpp.

399  {
400  m_setup.s->v.clear();
401  m_setup.s->m_idx.clear();
402  m_direct = 0;
403  m_keyCtxt = -1;
404  }
union Containers::KeyedObjectManager::@2 m_setup
template<>
void Containers::KeyedObjectManager< __V >::clearDirect ( )

Definition at line 536 of file KeyedObjectManager.cpp.

536  {
537  m_setup.s->v.clear();
538  m_direct = 0;
539  m_keyCtxt = -1;
540  }
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 186 of file KeyedObjectManager.cpp.

186  {
187  typedef typename T::map_type MTYP;
188  typedef find<MTYP> FND;
189  if ( 1 == m_direct ) {
190  auto& m = m_setup.s->m;
191  auto i = ( obj ? std::find_if( m.begin(), m.end(), FND( obj ) ) : m_setup.s->m.find( key ) );
192  if ( i != m_setup.s->m.end() ) {
193  void* o = i->second;
194  auto j = std::find( m_seq->begin(), m_seq->end(), o );
195  if ( j != m_seq->end() ) {
196  m_seq->erase( j );
197  m_setup.s->m.erase( i );
198  return o;
199  }
200  }
202  }
203  onDirty();
204  return erase( key, obj );
205 }
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:92
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 253 of file KeyedObjectManager.cpp.

253  {
254  typedef typename T::map_type MTYP;
255  typedef find<MTYP> FND;
256  if ( 0 == m_direct ) {
257  onDirty();
258  return erase( beg, end );
259  }
260  if ( beg == m_seq->begin() && end == m_seq->end() ) {
261  clear();
262  } else {
263  for ( auto j = beg; j != end; ++j ) {
264  // auto& m = m_setup.s->m;
265  auto i = std::find_if( m_setup.s->m.begin(), m_setup.s->m.end(), FND( *j ) );
266  if ( i != m_setup.s->m.end() ) {
267  m_setup.s->m.erase( i );
268  continue;
269  }
271  }
272  m_seq->erase( beg, end );
273  }
274  return OBJ_ERASED;
275 }
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:25
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 408 of file KeyedObjectManager.cpp.

408  {
409  if ( 0 == m_direct ) {
410  onDirty();
411  return erase( key, obj );
412  }
413  if ( obj ) {
414  auto& idx = m_setup.s->m_idx;
415  for ( auto& elem : idx ) {
416  auto j = m_setup.s->v.begin() + ( elem );
417  auto k = std::find( m_seq->begin(), m_seq->end(), *j );
418  if ( *j == obj ) {
419  void* o = *j;
420  m_seq->erase( k );
421  m_setup.s->v.erase( j );
422  std::for_each( m_setup.s->m_idx.begin(), m_setup.s->m_idx.end(), array::decrement( elem ) );
423  elem = -1;
424  return o;
425  }
426  }
427  } else if ( key >= 0 && key < long( m_setup.s->m_idx.size() ) ) {
428  auto idx = m_setup.s->m_idx.begin() + key;
429  if ( *idx != -1 ) {
430  auto i = m_setup.s->v.begin() + ( *idx );
431  if ( i == m_setup.s->v.end() ) { containerIsInconsistent(); }
432  void* o = *i;
433  auto j = std::find( m_seq->begin(), m_seq->end(), o );
434  if ( j == m_seq->end() ) { containerIsInconsistent(); }
435  m_seq->erase( j );
436  m_setup.s->v.erase( i );
437  std::for_each( m_setup.s->m_idx.begin(), m_setup.s->m_idx.end(), array::decrement( *idx ) );
438  *idx = -1;
439  return o;
440  }
441  }
443  return nullptr;
444  }
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 448 of file KeyedObjectManager.cpp.

448  {
449  if ( beg == m_seq->begin() && end == m_seq->end() ) {
450  clear();
451  return OBJ_ERASED;
452  } else if ( 0 == m_direct ) {
453  onDirty();
454  return erase( beg, end );
455  } else {
456  long cnt = 0, nobj = end - beg;
457  auto& idx = m_setup.s->m_idx;
458  for ( auto& elem : idx ) {
459  auto j = m_setup.s->v.begin() + ( elem );
460  auto k = std::find( beg, end, *j );
461  if ( k != end ) {
462  m_setup.s->v.erase( j );
463  std::for_each( m_setup.s->m_idx.begin(), m_setup.s->m_idx.end(), array::decrement( elem ) );
464  elem = -1;
465  cnt++;
466  if ( cnt == nobj ) break;
467  }
468  }
469  m_seq->erase( beg, end );
470  if ( cnt != nobj ) { containerIsInconsistent(); }
471  return OBJ_ERASED;
472  }
473  // cannot reach this point
474  }
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:25
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 544 of file KeyedObjectManager.cpp.

544  {
546  return nullptr;
547  }
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 551 of file KeyedObjectManager.cpp.

551  {
552  if ( beg == m_seq->begin() && end == m_seq->end() ) {
553  clear();
554  return OBJ_ERASED;
555  }
557  return OBJ_ERASED;
558  }
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:25
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 128 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 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.

136  {
138  if ( key > m_keyCtxt ) { m_keyCtxt = key; }
139  if ( 1 == m_direct ) {
140  if ( m_setup.s->insert( obj, key ) ) {
141  if ( !pObject->parent() ) { pObject->setParent( pBase ); }
142  m_seq->push_back( obj );
143  return OBJ_INSERTED;
144  }
145  } else if ( key == long( m_setup.s->v.size() ) ) {
146  m_setup.s->v.push_back( obj );
147  if ( !pObject->parent() ) { pObject->setParent( pBase ); }
148  m_seq->push_back( obj );
149  return OBJ_INSERTED;
150  } else {
151  // Document is dirty now...
152  // need to copy all pointers from the vector to the map
153  onDirty();
154  return insert( pBase, pObject, obj, key );
155  }
157  return OBJ_CANNOT_INSERT;
158 }
Object was inserted into the container.
Definition: KeyedTraits.h:26
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:27
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 332 of file KeyedObjectManager.cpp.

332  {
333  // auto key creation only possible for direct access!
334  if ( 0 == m_direct ) {
335  m_seq->push_back( o );
336  m_setup.s->v.push_back( o );
337  if ( !c->parent() ) c->setParent( b );
338  *k = ++m_keyCtxt;
339  return OBJ_INSERTED;
340  }
342  return OBJ_CANNOT_INSERT;
343  }
Object was inserted into the container.
Definition: KeyedTraits.h:26
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:27
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 347 of file KeyedObjectManager.cpp.

347  {
348  if ( 0 == m_direct ) {
349  if ( k == m_keyCtxt + 1 ) { return insert( b, c, o, &k ); }
350  onDirty();
351  return insert( b, c, o, k );
352  }
354  if ( k > m_keyCtxt ) m_keyCtxt = k;
356  if ( k + 1 > long( m_setup.s->m_idx.size() ) ) { m_setup.s->m_idx.resize( k + 1, -1 ); }
357  auto idx = m_setup.s->m_idx.begin() + k;
358  if ( *idx == -1 ) {
359  *idx = m_setup.s->v.size();
360  m_setup.s->v.push_back( o );
361  m_seq->push_back( o );
362  if ( !c->parent() ) c->setParent( b );
363  return OBJ_INSERTED;
364  }
366  return OBJ_CANNOT_INSERT;
367  }
Object was inserted into the container.
Definition: KeyedTraits.h:26
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:27
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 506 of file KeyedObjectManager.cpp.

506  {
507  m_seq->push_back( o );
508  m_setup.s->v.push_back( o );
509  if ( !c->parent() ) c->setParent( b );
510  *k = ( m_setup.s->v.size() - 1 );
511  return OBJ_INSERTED;
512  }
Object was inserted into the container.
Definition: KeyedTraits.h:26
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 516 of file KeyedObjectManager.cpp.

516  {
517  if ( k == long( m_setup.s->v.size() ) ) { return insert( b, c, o, &k ); }
519  return OBJ_CANNOT_INSERT;
520  }
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:27
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 161 of file KeyedObjectManager.cpp.

162  {
164  if ( key > m_keyCtxt ) { m_keyCtxt = key; }
165  if ( 1 == m_direct ) {
166  if ( m_setup.s->insert( obj, key ) ) {
167  if ( !pObject->parent() ) { pObject->setParent( pBase ); }
168  return OBJ_INSERTED;
169  }
170  } else if ( key == long( m_setup.s->v.size() ) ) {
171  m_setup.s->v.push_back( obj );
172  if ( !pObject->parent() ) { pObject->setParent( pBase ); }
173  return OBJ_INSERTED;
174  } else {
175  // Document is dirty now...
176  // need to copy all pointers from the vector to the map
177  onDirty();
178  return insertDirect( pBase, pObject, obj, key );
179  }
181  return OBJ_CANNOT_INSERT;
182 }
Object was inserted into the container.
Definition: KeyedTraits.h:26
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:27
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 371 of file KeyedObjectManager.cpp.

371  {
372  if ( 0 == m_direct ) {
373  if ( k == m_keyCtxt + 1 ) {
374  m_setup.s->v.push_back( o );
375  if ( !c->parent() ) c->setParent( b );
376  ++m_keyCtxt;
377  return OBJ_INSERTED;
378  }
379  onDirty();
380  return insertDirect( b, c, o, k );
381  }
383  if ( k > m_keyCtxt ) m_keyCtxt = k;
385  if ( k + 1 > long( m_setup.s->m_idx.size() ) ) { m_setup.s->m_idx.resize( k + 1, -1 ); }
386  auto idx = m_setup.s->m_idx.begin() + k;
387  if ( *idx == -1 ) {
388  *idx = m_setup.s->v.size();
389  m_setup.s->v.push_back( o );
390  if ( !c->parent() ) c->setParent( b );
391  return OBJ_INSERTED;
392  }
394  return OBJ_CANNOT_INSERT;
395  }
Object was inserted into the container.
Definition: KeyedTraits.h:26
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:27
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 524 of file KeyedObjectManager.cpp.

524  {
525  if ( k == long( m_setup.s->v.size() ) ) {
526  m_setup.s->v.push_back( o );
527  if ( !c->parent() ) c->setParent( b );
528  return OBJ_INSERTED;
529  }
531  return OBJ_CANNOT_INSERT;
532  }
Object was inserted into the container.
Definition: KeyedTraits.h:26
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:27
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 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 208 of file KeyedObjectManager.cpp.

208  {
209  if ( 0 == m_direct ) onDirty();
210  auto i = m_setup.s->m.find( key );
211  if ( i != m_setup.s->m.end() ) return ( *i ).second;
212  return nullptr;
213 }
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 307 of file KeyedObjectManager.cpp.

307  {
308 #ifdef CHECK_KEYED_CONTAINER
309  unsigned long siz = m_setup.s->m_idx.size();
310  if ( value >= 0 && size_t( value ) < siz ) {
311  long ent = *( m_setup.s->m_idx.begin() + value );
312  if ( ent >= 0 ) { return *( m_setup.s->v.begin() + ent ); }
313  }
314  return nullptr;
315 #else
316  return *( m_setup.s->v.begin() + ( *( m_setup.s->m_idx.begin() + value ) ) );
317 #endif
318  }
union Containers::KeyedObjectManager::@2 m_setup
template<>
void * Containers::KeyedObjectManager< __V >::object ( long  ) const

Definition at line 494 of file KeyedObjectManager.cpp.

494  {
496  return nullptr;
497  }
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 119 of file KeyedObjectManager.cpp.

119  {
120  m_direct = 1;
121  auto& s = *m_setup.s;
122  long i = 0;
123  for ( auto p : s.v ) s.insert( p, i++ );
124  s.v.clear();
125 }
union Containers::KeyedObjectManager::@2 m_setup
template<>
void Containers::KeyedObjectManager< __A >::onDirty ( ) const
private

Definition at line 321 of file KeyedObjectManager.cpp.

321  {
322  m_direct = 1;
323  m_setup.s->m_idx.reserve( m_setup.s->v.size() + 1 );
324  for ( int i = 0, stop = m_setup.s->v.size(); i < stop; ++i ) {
325  if ( !m_setup.s->v[i] ) { containerIsInconsistent(); }
326  m_setup.s->m_idx.push_back( i );
327  }
328  }
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 500 of file KeyedObjectManager.cpp.

500  {
502  }
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 216 of file KeyedObjectManager.cpp.

216  {
217  switch ( m_direct ) {
218  case 1:
219  break;
220  case 0:
221  m_setup.s->v.reserve( len );
222  break;
223  default:
224  break;
225  }
226  m_seq->reserve( len );
227 }
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 113 of file KeyedObjectManager.cpp.

113  {
114  m_seq = (seq_type*)seq;
115  *rndm = &m_setup.s->v;
116 }
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 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: