Go to the documentation of this file.
60 template <
class DATATYPE,
class MAPPING = Containers::HashMap>
76 typedef typename std::vector<contained_type*>
seq_type;
114 #ifdef CHECK_KEYED_CONTAINER
117 if ( traits::checkBounds( m_random, k ) ) {
118 value_type p = *( m_random->begin() + traits::hash( k ) );
119 if ( traits::checkKey( p, k ) ) {
return p; }
124 return traits::checkKey( p, k ) ? p : 0;
128 return 0 == m_cont.
isDirect() ?
value_type( *( m_random->begin() + traits::hash( k ) ) )
132 long i_erase( const_reference
v,
const key_type& k ) {
134 value_type p = value_type( m_cont.
erase( traits::hash( k ),
v ) );
136 if ( p->parent() ==
this ) { p->setParent( 0 ); }
157 if (
par == m_obj ) { p->setParent( 0 ); }
170 seq_type** rptr = &m_random;
171 seq_type* sptr = &m_sequential;
172 m_cont.
setup( (
void*)sptr, (
void**)rptr );
176 , m_cont(
std::move( other.m_cont ) )
177 , m_sequential(
std::move( other.m_sequential ) ) {
178 m_cont.
setup( (
void*)&m_sequential, (
void**)&m_random );
181 other.m_cont.setup( (
void*)&other.m_sequential, (
void**)&other.m_random );
197 static CLID clid = contained_type::classID() + container_type::classID();
218 size_type
numberOfObjects()
const override {
return m_sequential.size(); }
252 return i_object( traits::makeKey( key_value ) );
274 bool empty()
const {
return m_sequential.empty(); }
485 template <
class DATATYPE,
class MAPPING>
492 template <
class DATATYPE,
class MAPPING>
496 for (
typename seq_type::value_type
v : m_sequential ) {
498 if ( !
v->hasKey() ) {
499 traits::setKey(
v,
v->key() );
502 long k0 = traits::hash(
v->key() );
513 template <
class DATATYPE,
class MAPPING>
515 return (
const std::vector<const ContainedObject*>*)( ( 0 == m_cont.
isDirect() ) ? m_random : &m_sequential );
518 template <
class DATATYPE,
class MAPPING>
522 long k0 = traits::hash( kval );
523 if ( !val->hasKey() || ( traits::hash( val->key() ) == k0 ) ) {
525 if ( !val->hasKey() ) traits::setKey( val, kval );
526 traits::addRef( val );
537 template <
class DATATYPE,
class MAPPING>
541 if ( val->hasKey() ) {
543 traits::addRef( val );
549 traits::setKey( val, traits::makeKey( k0 ) );
550 traits::addRef( val );
559 template <
class DATATYPE,
class MAPPING>
562 if ( ptr )
return traits::identifier( ptr->key() );
567 template <
class DATATYPE,
class MAPPING>
571 vec.reserve(
size() );
572 for (
typename seq_type::value_type
v : m_sequential ) {
580 template <
class DATATYPE,
class MAPPING>
582 return traits::identifier(
insert(
dynamic_cast<typename seq_type::value_type
>( pObject ) ) );
586 template <
class DATATYPE,
class MAPPING>
590 return this->erase(
p1 );
605 template <
class DATATYPE,
class MAPPING>
607 bool is_start = start_pos == m_sequential.begin();
608 bool is_stop = stop_pos == m_sequential.end();
609 if ( is_start && is_stop ) {
611 }
else if ( is_start || is_stop || use_tmp ) {
612 std::vector<DATATYPE*> tmp( m_sequential.begin(), start_pos );
613 tmp.insert( tmp.end(), stop_pos, m_sequential.end() );
615 this->erase( m_sequential.begin(), m_sequential.end() );
616 std::for_each( tmp.begin(), tmp.end(), _InsertRelease(
this ) );
619 std::for_each( start_pos, stop_pos, _RemoveRelease(
this ) );
621 std::vector<void*>*
v = (std::vector<void*>*)sptr;
622 std::vector<void*>::iterator i1 =
v->begin() + std::distance( m_sequential.begin(), start_pos );
623 std::vector<void*>::iterator i2 =
v->begin() + std::distance( m_sequential.begin(), stop_pos );
624 m_cont.
erase( i1, i2 );
long erase(const key_type &kval)
Remove/erase object (identified by key) from the container.
bool empty() const
For consistency with STL: check if container is empty.
@ OBJ_ERASED
Object was removed, but not deleted
iterator end()
Retrieve terminating iterator.
GAUDI_API void cannotInsertToContainer()
Function to be called to indicate that an object cannot be inserted to the container.
KeyedObjectManager Class to manage keyed objects.
ContainedObject * containedObject(long key_value) override
ObjectContainerBase overload: Retrieve the object by reference given the long integer representation ...
@ OBJ_INSERTED
Object was inserted into the container.
constexpr auto size(const T &, Args &&...) noexcept
long insertDirect(ObjectContainerBase *b, ContainedObject *c, void *o, long k)
Insert element into direct access map.
contained_type::key_type key_type
Definition of the key type: re-use definition of contained type.
seq_type * m_random
Array to allow random access to objects (not exposed)
seq_type::const_iterator const_iterator
Sequential access: const iterator type used in sequential container.
StatusCode update() override
Reconfigure direct access to elements (Needed by POOL data loading) This function reuses the "update"...
const_iterator begin() const
Retrieve start const iterator.
reverse_iterator rend()
reverse_iterator pointing to the end of the reversed container
value_type operator()(const key_type &kval) const
STL algorithms support for object access.
seq_type::const_reverse_iterator const_reverse_iterator
Sequential access: const reverse iterator type used in sequential container.
long insert(ObjectContainerBase *b, ContainedObject *c, void *o, long *k)
Insert new object into container.
void clearDirect()
Clear all direct access fields.
void operator()(value_type p)
seq_type::value_type value_type
Sequential access: definition of type stored in sequential container.
ContainedObject const * containedObject(long key_value) const override
Pointer to an object of a given distance.
GAUDI_API void invalidContainerOperation()
Function to be called to indicate that an operation should be performed on the container or it's cont...
Internal functor for insertion of objects.
void reserve(size_type value)
Reserve place for "value" objects in the container.
void operator()(value_type p)
void clear()
Clear the entire content and erase the objects from the container.
KeyedContainer< DATATYPE, MAPPING > * m_obj
long add(ContainedObject *pObject) override
ObjectContainerBase overload: Add an object to the container.
void * object(long key) const
Retrieve object identified by a key from the container.
MAPPING container_type
Definition of the implementing container type.
AttribStringParser::Iterator begin(const AttribStringParser &parser)
ObjectContainerBase * m_obj
value_type object(const key_type &kval) const
Object access by key.
void for_each(ContainerOfSynced &c, Fun &&f)
DATATYPE contained_type
Definition of the contained object type.
long erase(const value_type val)
Remove/erase object (identified by pointer value) from the container.
@ OBJ_DELETED
Object was removed from the container and deleted.
seq_type::const_reference const_reference
Sequential access: const reference type used in sequential container.
@ OBJ_NOT_FOUND
Object not present in the container.
size_t size_type
size_type, to conform the STL container interface
template class KeyedContainer, KeyedContainer.h
unsigned int CLID
Class ID definition.
reverse_iterator rbegin()
reverse_iterator returns the beginning of the reversed container
const key_type & insert(const value_type val, const key_type &kval)
Insert entry to the container with a valid key.
seq_type::iterator iterator
Sequential access: iterator type used in sequential container.
void * erase(long key, const void *obj)
Remove object from container (very inefficient if key is invalid)
static const CLID & classID()
Retrieve class ID.
const ObjectContainerBase * parent() const
Access to parent object.
int key_type
Definition of the key-type to access object.
KeyedContainer(const KeyedContainer &)=delete
void reserve(long size)
Reserve buffer space.
_InsertRelease(KeyedContainer< DATATYPE, MAPPING > *p)
const_iterator end() const
Retrieve terminating const iterator.
constexpr static const auto SUCCESS
long index(const ContainedObject *p) const override
ObjectContainerBase overload: Retrieve the full long integer representation of the object's key from ...
void setParent(ObjectContainerBase *value)
Update parent member.
_RemoveRelease(ObjectContainerBase *p)
virtual const std::vector< const ContainedObject * > * containedObjects() const
Retrieve the full content of the object container by reference.
Internal functor for insertion of objects.
long erase(iterator pos)
Remove/erase object (identified by iterator) from the container.
void erase(iterator pos_start, iterator pos_stop, bool use_temp=false)
Remove/erase objects by iterator range.
void setup(void *seq, void **rndm)
Setup of the Map and the parent object.
Generator[dict, None, None] reference(request, Optional[Path] reference_path)
value_type i_object(const key_type &k) const
Internal function to access objects within the container.
seq_type m_sequential
Array to allow sequential access to the object (can be ordered).
seq_type::reverse_iterator reverse_iterator
Sequential access: reverse iterator type used in sequential container.
long remove(ContainedObject *pObject) override
ObjectContainerBase overload: Remove an object from the container.
seq_type::reference reference
Sequential access: reference type used in sequential container.
long isDirect() const
Check if the container is dirty.
virtual size_type numberOfObjects() const =0
Number of objects in the container.
Containers::traits< container_type, contained_type > traits
Traits class definition.
virtual size_type containedObjects(std::vector< ContainedObject * > &v) const
Retrieve the full content of the object container.
static const CLID & classID()
Retrieve reference to class definition structure (static access)
virtual const CLID & clID() const
Retrieve reference to class definition structure.
constexpr struct Gaudi::Functional::details::insert_t insert
~KeyedContainer() override
Destructor.
KeyedContainer(KeyedContainer &&other)
const_reverse_iterator rend() const
const reverse_iterator pointing to the end of the reversed container
const key_type & insert(const value_type val)
Insert entry to the container with automatic key assignment.
const_reverse_iterator rbegin() const
const reverse_iterator returns the beginning of the reversed container
void clear()
Clear content of the vector.
std::vector< contained_type * > seq_type
General container specific type definitions.