37 auto p =
m.
insert( map_type::value_type(
key, obj ) );
71 typedef typename CONT::value_type
v_type;
80 throw GaudiException(
"Cannot assign key to keyed object! Object already has a key.",
"KeyedObject",
88 throw GaudiException(
"Keyed Container structures are inconsistent - severe problem!",
"KeyedContainer",
93 throw GaudiException(
"Keyed Container cannot satisfy request - severe problem!",
"KeyedContainer",
99 if (
sizeof(
typename T::map_type ) >
sizeof(
m_setup.buffer ) ) {
108 : m_seq(
nullptr ), m_direct( other.m_direct ), m_keyCtxt( other.m_keyCtxt ) {
111 other.m_keyCtxt = -1;
112 other.m_seq =
nullptr;
130 *rndm = &m_setup.s->v;
136 auto&
s = *m_setup.s;
138 for (
auto p :
s.v )
s.insert( p, i++ );
146 return insert( pBase, pObject, obj, *
key );
153 if (
key > m_keyCtxt ) { m_keyCtxt =
key; }
154 if ( 1 == m_direct ) {
155 if ( m_setup.s->insert( obj,
key ) ) {
157 m_seq->push_back( obj );
160 }
else if (
key ==
long( m_setup.s->v.size() ) ) {
161 m_setup.s->v.push_back( obj );
163 m_seq->push_back( obj );
169 return insert( pBase, pObject, obj,
key );
179 if (
key > m_keyCtxt ) { m_keyCtxt =
key; }
180 if ( 1 == m_direct ) {
181 if ( m_setup.s->insert( obj,
key ) ) {
185 }
else if (
key ==
long( m_setup.s->v.size() ) ) {
186 m_setup.s->v.push_back( obj );
193 return insertDirect( pBase, pObject, obj,
key );
202 typedef typename T::map_type MTYP;
204 if ( 1 == m_direct ) {
205 auto&
m = m_setup.s->m;
206 auto i = ( obj ?
std::find_if(
m.begin(),
m.end(), FND( obj ) ) : m_setup.s->m.find(
key ) );
207 if ( i != m_setup.s->m.end() ) {
209 auto j =
std::find( m_seq->begin(), m_seq->end(), o );
210 if (
j != m_seq->end() ) {
212 m_setup.s->m.erase( i );
219 return erase(
key, obj );
224 if ( 0 == m_direct ) onDirty();
225 auto i = m_setup.s->m.find(
key );
226 if ( i != m_setup.s->m.end() )
return ( *i ).second;
232 switch ( m_direct ) {
236 m_setup.s->v.reserve( len );
241 m_seq->reserve( len );
252 switch ( m_direct ) {
254 m_setup.s->m.clear();
257 m_setup.s->v.clear();
269 typedef typename T::map_type MTYP;
271 if ( 0 == m_direct ) {
273 return erase( beg,
end );
275 if ( beg == m_seq->begin() &&
end == m_seq->end() ) {
278 for (
auto j = beg;
j !=
end; ++
j ) {
280 auto i =
std::find_if( m_setup.s->m.begin(), m_setup.s->m.end(), FND( *
j ) );
281 if ( i != m_setup.s->m.end() ) {
282 m_setup.s->m.erase( i );
287 m_seq->erase( beg,
end );
299 return CLID_ObjectVector + 0x00030000;
303 return CLID_ObjectVector + 0x00040000;
323 #ifdef CHECK_KEYED_CONTAINER
324 unsigned long siz = m_setup.s->m_idx.size();
325 if ( value >= 0 &&
size_t( value ) < siz ) {
326 long ent = *( m_setup.s->m_idx.begin() + value );
327 if ( ent >= 0 ) {
return *( m_setup.s->v.begin() + ent ); }
331 return *( m_setup.s->v.begin() + ( *( m_setup.s->m_idx.begin() + value ) ) );
338 m_setup.s->m_idx.reserve( m_setup.s->v.size() + 1 );
339 for (
size_t i = 0, stop = m_setup.s->v.size(); i < stop; ++i ) {
341 m_setup.s->m_idx.push_back( i );
349 if ( 0 == m_direct ) {
350 m_seq->push_back( o );
351 m_setup.s->v.push_back( o );
352 if ( !
c->parent() )
c->setParent( b );
363 if ( 0 == m_direct ) {
364 if ( k == m_keyCtxt + 1 ) {
return insert( b,
c, o, &k ); }
369 if ( k > m_keyCtxt ) m_keyCtxt = k;
371 if ( k + 1 >
long( m_setup.s->m_idx.size() ) ) { m_setup.s->m_idx.resize( k + 1, -1 ); }
372 auto idx = m_setup.s->m_idx.begin() + k;
374 *idx = m_setup.s->v.size();
375 m_setup.s->v.push_back( o );
376 m_seq->push_back( o );
377 if ( !
c->parent() )
c->setParent( b );
387 if ( 0 == m_direct ) {
388 if ( k == m_keyCtxt + 1 ) {
389 m_setup.s->v.push_back( o );
390 if ( !
c->parent() )
c->setParent( b );
395 return insertDirect( b,
c, o, k );
398 if ( k > m_keyCtxt ) m_keyCtxt = k;
400 if ( k + 1 >
long( m_setup.s->m_idx.size() ) ) { m_setup.s->m_idx.resize( k + 1, -1 ); }
401 auto idx = m_setup.s->m_idx.begin() + k;
403 *idx = m_setup.s->v.size();
404 m_setup.s->v.push_back( o );
405 if ( !
c->parent() )
c->setParent( b );
415 m_setup.s->v.clear();
416 m_setup.s->m_idx.clear();
424 if ( 0 == m_direct ) {
426 return erase(
key, obj );
429 auto& idx = m_setup.s->m_idx;
430 for (
auto& elem : idx ) {
431 auto j = m_setup.s->v.begin() + ( elem );
432 auto k =
std::find( m_seq->begin(), m_seq->end(), *
j );
436 m_setup.s->v.erase(
j );
442 }
else if (
key >= 0 &&
key <
long( m_setup.s->m_idx.size() ) ) {
443 auto idx = m_setup.s->m_idx.begin() +
key;
445 auto i = m_setup.s->v.begin() + ( *idx );
448 auto j =
std::find( m_seq->begin(), m_seq->end(), o );
451 m_setup.s->v.erase( i );
464 if ( beg == m_seq->begin() &&
end == m_seq->end() ) {
467 }
else if ( 0 == m_direct ) {
469 return erase( beg,
end );
471 long cnt = 0, nobj =
end - beg;
472 auto& idx = m_setup.s->m_idx;
473 for (
auto& elem : idx ) {
474 auto j = m_setup.s->v.begin() + ( elem );
477 m_setup.s->v.erase(
j );
481 if ( cnt == nobj )
break;
484 m_seq->erase( beg,
end );
493 return CLID_ObjectVector + 0x00050000;
522 m_seq->push_back( o );
523 m_setup.s->v.push_back( o );
524 if ( !
c->parent() )
c->setParent( b );
525 *k = ( m_setup.s->v.size() - 1 );
532 if ( k ==
long( m_setup.s->v.size() ) ) {
return insert( b,
c, o, &k ); }
540 if ( k ==
long( m_setup.s->v.size() ) ) {
541 m_setup.s->v.push_back( o );
542 if ( !
c->parent() )
c->setParent( b );
552 m_setup.s->v.clear();
567 if ( beg == m_seq->begin() &&
end == m_seq->end() ) {
577 return CLID_ObjectVector + 0x00060000;