25 auto p = m.
insert(map_type::value_type(key,obj));
53 typedef typename CONT::value_type
v_type;
55 find(
const void* o) : m_obj(o) {}
60 return (*
this)(cmp.second);
65 throw GaudiException(
"Cannot assign key to keyed object! Object already has a key.",
76 throw GaudiException(
"Keyed Container structures are inconsistent - severe problem!",
82 throw GaudiException(
"Keyed Container cannot satisfy request - severe problem!",
89 : m_seq(nullptr), m_direct(0)
91 if (
sizeof(
typename T::map_type) >
sizeof(
m_setup.buffer) ) {
107 template <
class T>
void
111 *rndm = &m_setup.s->v;
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);
120 m_setup.s->v.clear();
131 return insert(pBase, pObject, obj, *key);
142 if ( key > m_keyCtxt ) {
146 if ( m_setup.s->insert(obj, key) ) {
147 if ( !pObject->
parent() ) {
150 m_seq->push_back(obj);
154 else if ( key ==
long(m_setup.s->v.size()) ) {
155 m_setup.s->v.push_back(obj);
156 if ( !pObject->
parent() ) {
159 m_seq->push_back(obj);
166 return insert(pBase, pObject, obj, key);
180 if ( key > m_keyCtxt ) {
184 if ( m_setup.s->insert(obj, key) ) {
185 if ( !pObject->
parent() ) {
191 else if ( key ==
long(m_setup.s->v.size()) ) {
192 m_setup.s->v.push_back(obj);
193 if ( !pObject->
parent() ) {
202 return insertDirect(pBase, pObject, obj, key);
212 typedef typename T::map_type MTYP;
214 if ( 1 == m_direct ) {
215 auto&
m = m_setup.s->m;
217 : m_setup.s->m.find(key) );
218 if (
i != m_setup.s->m.end() ) {
220 auto j =
std::find(m_seq->begin(),m_seq->end(),o);
221 if ( j != m_seq->end() ) {
223 m_setup.s->m.erase(
i);
230 return erase(key, obj);
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;
249 m_setup.s->v.reserve(len);
269 m_setup.s->m.clear();
272 m_setup.s->v.clear();
284 seq_type::iterator
end)
286 typedef typename T::map_type MTYP;
288 if ( 0 == m_direct ) {
290 return erase(beg, end);
292 if ( beg == m_seq->begin() && end == m_seq->end() ) {
296 for (
auto j=beg; j !=
end; ++j) {
297 auto&
m = m_setup.s->m;
299 if (
i != m_setup.s->m.end() ) {
300 m_setup.s->m.erase(
i);
305 m_seq->erase(beg, end);
317 return CLID_ObjectVector+0x00030000;
321 return CLID_ObjectVector+0x00040000;
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);
347 return *(m_setup.s->v.begin() + ent);
352 return *(m_setup.s->v.begin() + (*(m_setup.s->m_idx.begin()+
value)));
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] ) {
364 m_setup.s->m_idx.push_back(
i);
376 if ( 0 == m_direct ) {
378 m_setup.s->v.push_back(o);
394 if ( 0 == m_direct ) {
395 if ( k == m_keyCtxt+1 ) {
396 return insert(b, c, o, &k);
399 return insert(b, c, o, k);
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);
407 auto idx = m_setup.s->m_idx.begin()+k;
409 *idx = m_setup.s->v.size();
410 m_setup.s->v.push_back(o);
426 if ( 0 == m_direct ) {
427 if ( k == m_keyCtxt+1 ) {
428 m_setup.s->v.push_back(o);
434 return insertDirect(b, c, o, k);
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);
442 auto idx = m_setup.s->m_idx.begin()+k;
444 *idx = m_setup.s->v.size();
445 m_setup.s->v.push_back(o);
456 m_setup.s->v.clear();
457 m_setup.s->m_idx.clear();
468 typedef id_type::iterator id_iter;
469 if ( 0 == m_direct ) {
471 return erase(key, 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);
481 m_setup.s->v.erase(j);
483 m_setup.s->m_idx.end(),
490 else if ( key >= 0 && key <
long(m_setup.s->m_idx.size()) ) {
491 auto idx = m_setup.s->m_idx.begin()+key;
493 auto i = m_setup.s->v.begin()+(*idx);
494 if (
i == m_setup.s->v.end() ) {
498 auto j=
std::find(m_seq->begin(),m_seq->end(),o);
499 if ( j == m_seq->end() ) {
503 m_setup.s->v.erase(
i);
505 m_setup.s->m_idx.end(),
518 seq_type::iterator
end)
521 typedef id_type::iterator id_iter;
522 if ( beg == m_seq->begin() && end == m_seq->end() ) {
526 else if ( 0 == m_direct ) {
528 return erase(beg, end);
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);
537 m_setup.s->v.erase(j);
539 m_setup.s->m_idx.end(),
543 if ( cnt == nobj )
break;
546 m_seq->erase(beg, end);
557 return CLID_ObjectVector+0x00050000;
592 m_setup.s->v.push_back(o);
594 *k = (m_setup.s->v.size()-1);
605 if ( k ==
long(m_setup.s->v.size()) ) {
606 return insert(b, c, o, &k);
619 if ( k ==
long(m_setup.s->v.size()) ) {
620 m_setup.s->v.push_back(o);
631 m_setup.s->v.clear();
648 seq_type::iterator
end)
650 if ( beg == m_seq->begin() && end == m_seq->end() ) {
660 return CLID_ObjectVector+0x00060000;
Object was inserted into the container.
bool operator()(long &j) const
Define general base for Gaudi exception.
std::vector< void * > map_type
virtual ~KeyedObjectManager()
Standard Destructor.
void clear()
Clear content of the vector.
std::vector< long > map_type
union Containers::KeyedObjectManager::@6 m_setup
GAUDI_API void containerIsInconsistent()
Function to be called to indicate that the container is found to be inconsistent. ...
void clearDirect()
Clear all direct access fields.
std::vector< long > m_idx
Indirection array.
void * object(long key) const
Retrieve object identified by a key from the container.
void * erase(long key, const void *obj)
Remove object from container (very inefficient if key is invalid)
std::map< long, void * > map_type
const ObjectContainerBase * parent() const
Access to parent object.
bool insert(void *obj, long key)
GAUDI_API void cannotInsertToContainer()
Function to be called to indicate that an object cannot be inserted to the container.
std::vector< void * > v
Direct access array.
void reserve(long size)
Reserve buffer space.
Cannot insert object into container.
GAUDI_API void invalidContainerOperation()
Function to be called to indicate that an operation should be performed on the container or it's cont...
GaudiUtils::HashMap< long, void * > map_type
void onDirty() const
Callback when the container becomes dirty.
auto end(reverse_wrapper< T > &w)
long insert(ObjectContainerBase *b, ContainedObject *c, void *o, long *k)
Insert new object into container.
unsigned int CLID
Class ID definition.
bool operator()(const v_type &cmp) const
Object was removed, but not deleted.
All classes that their objects may be contained in an LHCb ObjectContainer (e.g.
GAUDI_API void cannotAssignObjectKey()
Function to be called when an object key cannot be assigned.
KeyedObjectManager Class to manage keyed objects.
std::vector< void * > v
Direct access array.
void setParent(ObjectContainerBase *value)
Update parent member.
static CLID classID()
Access CLID for this type of container.
std::pair< iterator, bool > insert(ValueType &&val)
void setup(void *seq, void **rndm)
Setup of the Map and the parent object.
ObjectContainerBase is the base class for Gaudi container classes.
KeyedObjectManager()
Standard Constructor.
bool operator()(const void *cmp) const
bool insert(void *obj, long key)
long insertDirect(ObjectContainerBase *b, ContainedObject *c, void *o, long k)
Insert element into direct access map.