61 typedef typename CONT::value_type
v_type;
64 find(
const void* o ) : m_obj( o ) {}
65 bool operator()(
const void* cmp )
const {
return cmp == m_obj; }
66 bool operator()(
const v_type& cmp )
const {
return ( *
this )( cmp.second ); }
70 throw GaudiException(
"Cannot assign key to keyed object! Object already has a key.",
"KeyedObject",
78 throw GaudiException(
"Keyed Container structures are inconsistent - severe problem!",
"KeyedContainer",
83 throw GaudiException(
"Keyed Container cannot satisfy request - severe problem!",
"KeyedContainer",
89 if (
sizeof(
typename T::map_type ) >
sizeof(
m_setup.buffer ) ) {
101 other.m_keyCtxt = -1;
102 other.m_seq =
nullptr;
123 for (
auto p :
s.v )
s.insert( p, i++ );
131 return insert( pBase, pObject, obj, *key );
140 if (
m_setup.s->insert( obj, key ) ) {
145 }
else if ( key ==
long(
m_setup.s->v.size() ) ) {
154 return insert( pBase, pObject, obj, key );
166 if (
m_setup.s->insert( obj, key ) ) {
170 }
else if ( key ==
long(
m_setup.s->v.size() ) ) {
187 typedef typename T::map_type MTYP;
192 if ( i !=
m_setup.s->m.end() ) {
204 return erase( key, obj );
210 auto i =
m_setup.s->m.find( key );
211 if ( i !=
m_setup.s->m.end() )
return ( *i ).second;
254 typedef typename T::map_type MTYP;
258 return erase( beg, end );
263 for (
auto j = beg; j !=
end; ++j ) {
266 if ( i !=
m_setup.s->m.end() ) {
284 return CLID_ObjectVector + 0x00030000;
288 return CLID_ObjectVector + 0x00040000;
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 ); }
316 return *(
m_setup.s->v.begin() + ( *(
m_setup.s->m_idx.begin() + value ) ) );
324 for (
int i = 0, stop =
m_setup.s->v.size(); i < stop; ++i ) {
326 m_setup.s->m_idx.push_back( i );
351 return insert( b, c, o, 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;
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;
411 return erase( key, obj );
415 for (
auto& elem : idx ) {
416 auto j =
m_setup.s->v.begin() + ( elem );
427 }
else if ( key >= 0 && key <
long(
m_setup.s->m_idx.size() ) ) {
428 auto idx =
m_setup.s->m_idx.begin() + key;
430 auto i =
m_setup.s->v.begin() + ( *idx );
454 return erase( beg, end );
456 long cnt = 0, nobj = end - beg;
458 for (
auto& elem : idx ) {
459 auto j =
m_setup.s->v.begin() + ( elem );
466 if ( cnt == nobj )
break;
478 return CLID_ObjectVector + 0x00050000;
510 *k = (
m_setup.s->v.size() - 1 );
517 if ( k ==
long(
m_setup.s->v.size() ) ) {
return insert( b, c, o, &k ); }
525 if ( k ==
long(
m_setup.s->v.size() ) ) {
562 return CLID_ObjectVector + 0x00060000;
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
GAUDI_API void containerIsInconsistent()
Function to be called to indicate that the container is found to be inconsistent. ...
struct GAUDI_API vector
Parametrisation class for vector-like implementation.
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
Object was inserted into the container.
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.
std::pair< iterator, bool > insert(ValueType &&val)
void reserve(long size)
Reserve buffer space.
GAUDI_API void invalidContainerOperation()
Function to be called to indicate that an operation should be performed on the container or it's cont...
struct GAUDI_API map
Parametrisation class for map-like implementation.
GaudiUtils::HashMap< long, void * > map_type
void onDirty() const
Callback when the container becomes dirty.
Object was removed, but not deleted.
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
All classes that their objects may be contained in an LHCb ObjectContainer (e.g.
struct GAUDI_API array
Parametrisation class for redirection array - like implementation.
GAUDI_API void cannotAssignObjectKey()
Function to be called when an object key cannot be assigned.
std::pair< const long, void * > value_type
Cannot insert object into container.
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.
void setup(void *seq, void **rndm)
Setup of the Map and the parent object.
constexpr static const auto FAILURE
ObjectContainerBase is the base class for Gaudi container classes.
KeyedObjectManager()
Standard Constructor.
bool operator()(const void *cmp) const
bool insert(void *obj, long key)
seq_type * m_seq
Container holding array like container.
long insertDirect(ObjectContainerBase *b, ContainedObject *c, void *o, long k)
Insert element into direct access map.
union Containers::KeyedObjectManager::@2 m_setup