25 auto p =
m.insert( map_type::value_type( key, obj ) );
36 auto p =
m.insert( map_type::value_type( key, obj ) );
70 typedef typename CONT::value_type
v_type;
79 throw GaudiException(
"Cannot assign key to keyed object! Object already has a key.",
"KeyedObject",
87 throw GaudiException(
"Keyed Container structures are inconsistent - severe problem!",
"KeyedContainer",
92 throw GaudiException(
"Keyed Container cannot satisfy request - severe problem!",
"KeyedContainer",
98 if (
sizeof(
typename T::map_type ) >
sizeof(
m_setup.buffer ) ) {
99 throw GaudiException(
"Basic STL contaier sizes are incompatible",
"KeyedContainer", StatusCode::FAILURE );
110 other.m_keyCtxt = -1;
111 other.m_seq =
nullptr;
137 for (
auto p :
s.v )
s.insert( p, i++ );
145 return insert( pBase, pObject, obj, *key );
154 if (
m_setup.s->insert( obj, key ) ) {
156 m_seq->push_back( obj );
159 }
else if ( key ==
long(
m_setup.s->v.size() ) ) {
162 m_seq->push_back( obj );
168 return insert( pBase, pObject, obj, key );
180 if (
m_setup.s->insert( obj, key ) ) {
184 }
else if ( key ==
long(
m_setup.s->v.size() ) ) {
201 typedef typename T::map_type MTYP;
205 auto i = ( obj ? std::find_if( m.begin(), m.end(), FND( obj ) ) :
m_setup.s->m.find( key ) );
206 if ( i !=
m_setup.s->m.end() ) {
208 auto j = std::find(
m_seq->begin(),
m_seq->end(), o );
209 if ( j !=
m_seq->end() ) {
218 return erase( key, obj );
224 auto i =
m_setup.s->m.find( key );
225 if ( i !=
m_setup.s->m.end() )
return ( *i ).second;
240 m_seq->reserve( len );
268 typedef typename T::map_type MTYP;
272 return erase( beg, end );
274 if ( beg ==
m_seq->begin() && end ==
m_seq->end() ) {
277 for (
auto j = beg; j != end; ++j ) {
279 auto i = std::find_if(
m_setup.s->m.begin(),
m_setup.s->m.end(), FND( *j ) );
280 if ( i !=
m_setup.s->m.end() ) {
286 m_seq->erase( beg, end );
298 return CLID_ObjectVector + 0x00030000;
302 return CLID_ObjectVector + 0x00040000;
322#ifdef CHECK_KEYED_CONTAINER
323 unsigned long siz =
m_setup.s->m_idx.size();
324 if ( value >= 0 &&
size_t( value ) < siz ) {
325 long ent = *(
m_setup.s->m_idx.begin() + value );
326 if ( ent >= 0 ) {
return *(
m_setup.s->v.begin() + ent ); }
330 return *(
m_setup.s->v.begin() + ( *(
m_setup.s->m_idx.begin() + value ) ) );
338 for (
size_t i = 0, stop =
m_setup.s->v.size(); i < stop; ++i ) {
340 m_setup.s->m_idx.push_back( i );
349 m_seq->push_back( o );
351 if ( !c->parent() ) c->setParent( b );
365 return insert( b, c, o, k );
370 if ( k + 1 >
long(
m_setup.s->m_idx.size() ) ) {
m_setup.s->m_idx.resize( k + 1, -1 ); }
371 auto idx =
m_setup.s->m_idx.begin() + k;
375 m_seq->push_back( o );
376 if ( !c->parent() ) c->setParent( b );
389 if ( !c->parent() ) c->setParent( b );
399 if ( k + 1 >
long(
m_setup.s->m_idx.size() ) ) {
m_setup.s->m_idx.resize( k + 1, -1 ); }
400 auto idx =
m_setup.s->m_idx.begin() + k;
404 if ( !c->parent() ) c->setParent( b );
425 return erase( key, obj );
429 for (
auto& elem : idx ) {
430 auto j =
m_setup.s->v.begin() + ( elem );
431 auto k = std::find(
m_seq->begin(),
m_seq->end(), *j );
441 }
else if ( key >= 0 && key <
long(
m_setup.s->m_idx.size() ) ) {
442 auto idx =
m_setup.s->m_idx.begin() + key;
444 auto i =
m_setup.s->v.begin() + ( *idx );
447 auto j = std::find(
m_seq->begin(),
m_seq->end(), o );
463 if ( beg ==
m_seq->begin() && end ==
m_seq->end() ) {
468 return erase( beg, end );
470 long cnt = 0, nobj = end - beg;
472 for (
auto& elem : idx ) {
473 auto j =
m_setup.s->v.begin() + ( elem );
474 auto k = std::find( beg, end, *j );
480 if ( cnt == nobj )
break;
483 m_seq->erase( beg, end );
492 return CLID_ObjectVector + 0x00050000;
521 m_seq->push_back( o );
523 if ( !c->parent() ) c->setParent( b );
524 *k = (
m_setup.s->v.size() - 1 );
531 if ( k ==
long(
m_setup.s->v.size() ) ) {
return insert( b, c, o, &k ); }
539 if ( k ==
long(
m_setup.s->v.size() ) ) {
541 if ( !c->parent() ) c->setParent( b );
566 if ( beg ==
m_seq->begin() && end ==
m_seq->end() ) {
576 return CLID_ObjectVector + 0x00060000;
unsigned int CLID
Class ID definition.
All classes that their objects may be contained in an LHCb ObjectContainer (e.g.
void setParent(ObjectContainerBase *value)
Update parent member.
const ObjectContainerBase * parent() const
Access to parent object.
KeyedObjectManager Class to manage keyed objects.
static CLID classID()
Access CLID for this type of container.
void onDirty() const
Callback when the container becomes dirty.
void * erase(long key, const void *obj)
Remove object from container (very inefficient if key is invalid)
void setup(void *seq, void **rndm)
Setup of the Map and the parent object.
virtual ~KeyedObjectManager()
Standard Destructor.
void clearDirect()
Clear all direct access fields.
void * object(long key) const
Retrieve object identified by a key from the container.
KeyedObjectManager()
Standard Constructor.
union Containers::KeyedObjectManager::@010153222074056071241275200334232161065316116020 m_setup
seq_type * m_seq
Container holding array like container.
void reserve(long size)
Reserve buffer space.
void clear()
Clear content of the vector.
std::vector< void * > seq_type
long insert(ObjectContainerBase *b, ContainedObject *c, void *o, long *k)
Insert new object into container.
long insertDirect(ObjectContainerBase *b, ContainedObject *c, void *o, long k)
Insert element into direct access map.
bool operator()(const v_type &cmp) const
bool operator()(const void *cmp) const
Define general base for Gaudi exception.
Common class providing an architecture-independent hash map.
ObjectContainerBase is the base class for Gaudi container classes.
constexpr static const auto FAILURE
GAUDI_API void containerIsInconsistent()
Function to be called to indicate that the container is found to be inconsistent.
@ OBJ_INSERTED
Object was inserted into the container.
@ OBJ_ERASED
Object was removed, but not deleted.
@ OBJ_CANNOT_INSERT
Cannot insert object into container.
GAUDI_API void cannotAssignObjectKey()
Function to be called when an object key cannot be assigned.
GAUDI_API void cannotInsertToContainer()
Function to be called to indicate that an object cannot be inserted to the container.
GAUDI_API void invalidContainerOperation()
Function to be called to indicate that an operation should be performed on the container or it's cont...
bool operator()(long &j) const
std::vector< void * > v
Direct access array.
std::vector< long > map_type
std::vector< long > m_idx
Indirection array.
hashmap(hashmap &&)=default
GaudiUtils::HashMap< long, void * > map_type
bool insert(void *obj, long key)
bool insert(void *obj, long key)
std::map< long, void * > map_type
std::vector< void * > map_type
vector(vector &&)=default
std::vector< void * > v
Direct access array.