66 typedef typename CONT::value_type
v_type;
69 find(
const void* o ) : m_obj( o ) {}
70 bool operator()(
const void* cmp )
const {
return cmp == m_obj; }
71 bool operator()(
const v_type& cmp )
const {
return ( *
this )( cmp.second ); }
76 throw GaudiException(
"Cannot assign key to keyed object! Object already has a key.",
"KeyedObject",
86 throw GaudiException(
"Keyed Container structures are inconsistent - severe problem!",
"KeyedContainer",
92 throw GaudiException(
"Keyed Container cannot satisfy request - severe problem!",
"KeyedContainer",
99 if (
sizeof(
typename T::map_type ) >
sizeof(
m_setup.buffer ) ) {
112 other.m_keyCtxt = -1;
113 other.m_seq =
nullptr;
137 for (
auto p :
s.v )
s.insert( p, i++ );
146 return insert( pBase, pObject, obj, *key );
158 if (
m_setup.s->insert( obj, key ) ) {
159 if ( !pObject->
parent() ) {
165 }
else if ( key ==
long(
m_setup.s->v.size() ) ) {
167 if ( !pObject->
parent() ) {
176 return insert( pBase, pObject, obj, key );
191 if (
m_setup.s->insert( obj, key ) ) {
192 if ( !pObject->
parent() ) {
197 }
else if ( key ==
long(
m_setup.s->v.size() ) ) {
199 if ( !pObject->
parent() ) {
217 typedef typename T::map_type MTYP;
222 if ( i !=
m_setup.s->m.end() ) {
234 return erase( key, obj );
241 auto i =
m_setup.s->m.find( key );
242 if ( i !=
m_setup.s->m.end() )
return ( *i ).second;
289 typedef typename T::map_type MTYP;
293 return erase( beg, end );
298 for (
auto j = beg; j !=
end; ++j ) {
301 if ( i !=
m_setup.s->m.end() ) {
321 return CLID_ObjectVector + 0x00030000;
326 return CLID_ObjectVector + 0x00040000;
348 #ifdef CHECK_KEYED_CONTAINER 349 unsigned long siz =
m_setup.s->m_idx.size();
350 if ( value >= 0 &&
size_t( value ) < siz ) {
351 long ent = *(
m_setup.s->m_idx.begin() + value );
353 return *(
m_setup.s->v.begin() + ent );
358 return *(
m_setup.s->v.begin() + ( *(
m_setup.s->m_idx.begin() + value ) ) );
367 for (
int i = 0, stop =
m_setup.s->v.size(); i < stop; ++i ) {
371 m_setup.s->m_idx.push_back( i );
397 return insert( b, c, o, &k );
400 return insert( b, c, o, k );
405 if ( k + 1 >
long(
m_setup.s->m_idx.size() ) ) {
406 m_setup.s->m_idx.resize( k + 1, -1 );
408 auto idx =
m_setup.s->m_idx.begin() + k;
437 if ( k + 1 >
long(
m_setup.s->m_idx.size() ) ) {
438 m_setup.s->m_idx.resize( k + 1, -1 );
440 auto idx =
m_setup.s->m_idx.begin() + k;
468 return erase( key, obj );
471 id_type& idx =
m_setup.s->m_idx;
472 for (
auto& elem : idx ) {
473 auto j =
m_setup.s->v.begin() + ( elem );
484 }
else if ( key >= 0 && key <
long(
m_setup.s->m_idx.size() ) ) {
485 auto idx =
m_setup.s->m_idx.begin() + key;
487 auto i =
m_setup.s->v.begin() + ( *idx );
488 if ( i ==
m_setup.s->v.end() ) {
517 return erase( beg, end );
519 long cnt = 0, nobj = end - beg;
520 id_type& idx =
m_setup.s->m_idx;
521 for (
auto& elem : idx ) {
522 auto j =
m_setup.s->v.begin() + ( elem );
529 if ( cnt == nobj )
break;
544 return CLID_ObjectVector + 0x00050000;
580 *k = (
m_setup.s->v.size() - 1 );
588 if ( k ==
long(
m_setup.s->v.size() ) ) {
589 return insert( b, c, o, &k );
599 if ( k ==
long(
m_setup.s->v.size() ) ) {
640 return CLID_ObjectVector + 0x00060000;
constexpr static const auto FAILURE
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.
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