The Gaudi Framework
v30r3 (a5ef0a68)
|
template class KeyedContainer, KeyedContainer.h More...
#include <GaudiKernel/KeyedContainer.h>
Classes | |
struct | _InsertRelease |
Internal functor for insertion of objects. More... | |
struct | _RemoveRelease |
Internal functor for insertion of objects. More... | |
Public Types | |
typedef DATATYPE | contained_type |
Definition of the contained object type. More... | |
typedef MAPPING | container_type |
Definition of the implementing container type. More... | |
typedef std::vector< contained_type * > | seq_type |
General container specific type definitions. More... | |
typedef contained_type::key_type | key_type |
Definition of the key type: re-use definition of contained type. More... | |
typedef seq_type::value_type | value_type |
Sequential access: definition of type stored in sequential container. More... | |
typedef seq_type::reference | reference |
Sequential access: reference type used in sequential container. More... | |
typedef seq_type::const_reference | const_reference |
Sequential access: const reference type used in sequential container. More... | |
typedef seq_type::iterator | iterator |
Sequential access: iterator type used in sequential container. More... | |
typedef seq_type::const_iterator | const_iterator |
Sequential access: const iterator type used in sequential container. More... | |
typedef seq_type::reverse_iterator | reverse_iterator |
Sequential access: reverse iterator type used in sequential container. More... | |
typedef seq_type::const_reverse_iterator | const_reverse_iterator |
Sequential access: const reverse iterator type used in sequential container. More... | |
Public Types inherited from ObjectContainerBase | |
typedef size_t | size_type |
size_type, to conform the STL container interface More... | |
Public Member Functions | |
Constructors/Destructors | |
KeyedContainer (void) | |
Standard Constructor. More... | |
KeyedContainer (KeyedContainer &&other) | |
KeyedContainer (const KeyedContainer &)=delete | |
~KeyedContainer () override | |
Destructor. More... | |
NOT FOR GENERAL USE ObjectContainerBase function overloads. | |
The implementation of these methods ensure the behaviour of the class as a type of class ObjectContainerBase. This base class and its behaviour are only used by "generic" object handlers. These classes collaborate with several classes such as the
For this reason, the entry points in this section are reserved for "generic" object handling and should NOT be used in public. | |
size_type | numberOfObjects () const override |
ObjectContainerBase overload: Number of objects in the container. More... | |
long | add (ContainedObject *pObject) override |
ObjectContainerBase overload: Add an object to the container. More... | |
long | remove (ContainedObject *pObject) override |
ObjectContainerBase overload: Remove an object from the container. More... | |
ContainedObject * | containedObject (long key_value) const override |
ObjectContainerBase overload: Retrieve the object by reference given the long integer representation of the object's key. More... | |
long | index (const ContainedObject *p) const override |
ObjectContainerBase overload: Retrieve the full long integer representation of the object's key from the object base class pointer. More... | |
virtual size_type | containedObjects (std::vector< ContainedObject * > &v) const |
Retrieve the full content of the object container. More... | |
Container related implementation. | |
These methods allow to manipulate the container as a whole and to retrieve information about the internal behaviour of the container. | |
size_type | size () const |
Number of objects in the container. More... | |
bool | empty () const |
For consistency with STL: check if container is empty. More... | |
void | reserve (size_type value) |
Reserve place for "value" objects in the container. More... | |
void | clear () |
Clear the entire content and erase the objects from the container. More... | |
virtual const std::vector< const ContainedObject * > * | containedObjects () const |
Retrieve the full content of the object container by reference. More... | |
StatusCode | update () override |
Reconfigure direct access to elements (Needed by POOL data loading) This function reuses the "update" callback of the generic DataObject base class. More... | |
Sequential array access to objects using iterators. | |
Sequential object access using iterators is much faster then object access by key. In case all objects of the container should be addressed, use iterators rather than direct object access.
| |
iterator | begin () |
Retrieve start iterator. More... | |
const_iterator | begin () const |
Retrieve start const iterator. More... | |
iterator | end () |
Retrieve terminating iterator. More... | |
const_iterator | end () const |
Retrieve terminating const iterator. More... | |
reverse_iterator | rbegin () |
reverse_iterator returns the beginning of the reversed container More... | |
const_reverse_iterator | rbegin () const |
const reverse_iterator returns the beginning of the reversed container More... | |
reverse_iterator | rend () |
reverse_iterator pointing to the end of the reversed container More... | |
const_reverse_iterator | rend () const |
const reverse_iterator pointing to the end of the reversed container More... | |
Random access to objects in the container. | |
Access to objects is given by Key. Please note, that random object access is nearly in all cases significantly slower than sequential access. If all objects in the contaienr should be addresses sequentially, use iterators rather than direct access. Direct access should only be used for selective retrieval of objects. | |
value_type | object (const key_type &kval) const |
Object access by key. More... | |
value_type | operator() (const key_type &kval) const |
STL algorithms support for object access. More... | |
Insert/Remove objects from the container. | |
Objects generally are identified by key. Since keys are stored with the objects, insertions and removals are possible by key or by reference. | |
long | erase (const key_type &kval) |
Remove/erase object (identified by key) from the container. More... | |
long | erase (const value_type val) |
Remove/erase object (identified by pointer value) from the container. More... | |
long | erase (iterator pos) |
Remove/erase object (identified by iterator) from the container. More... | |
void | erase (iterator pos_start, iterator pos_stop, bool use_temp=false) |
Remove/erase objects by iterator range. More... | |
const key_type & | insert (const value_type val, const key_type &kval) |
Insert entry to the container with a valid key. More... | |
const key_type & | insert (const value_type val) |
Insert entry to the container with automatic key assignment. More... | |
Public Member Functions inherited from DataObject | |
DataObject () | |
Standard Constructor. More... | |
DataObject (const DataObject &rhs) | |
Copy Constructor. More... | |
DataObject & | operator= (const DataObject &rhs) |
Assignment Operator. More... | |
DataObject (DataObject &&rhs) | |
Move Constructor. More... | |
DataObject & | operator= (DataObject &&rhs) |
Move Assignment Operator. More... | |
virtual | ~DataObject () |
Standard Destructor. More... | |
virtual unsigned long | addRef () |
Add reference to object. More... | |
virtual unsigned long | release () |
release reference to object More... | |
const std::string & | name () const |
Retreive DataObject name. It is the name when registered in the store. More... | |
void | setRegistry (IRegistry *pRegistry) |
Set pointer to Registry. More... | |
IRegistry * | registry () const |
Get pointer to Registry. More... | |
LinkManager * | linkMgr () const |
Retrieve Link manager. More... | |
unsigned char | version () const |
Retrieve version number of this object representation. More... | |
void | setVersion (unsigned char vsn) |
Set version number of this object representation. More... | |
unsigned long | refCount () const |
Return the refcount. More... | |
virtual std::ostream & | fillStream (std::ostream &s) const |
Fill the output stream (ASCII) More... | |
Private Types | |
typedef Containers::traits< container_type, contained_type > | traits |
Traits class definition. More... | |
Friends | |
struct | GaudiDict::KeyedContainerDict< DATATYPE > |
Implementation helpers. | |
container_type | m_cont |
Map container to facilitate object access by key. More... | |
seq_type | m_sequential |
Array to allow sequential access to the object (can be ordered). More... | |
seq_type * | m_random |
Array to allow random access to objects (not exposed) More... | |
FORCE_INLINE value_type | i_object (const key_type &k) const |
Internal function to access objects within the container. More... | |
long | i_erase (const_reference v, const key_type &k) |
Internal function to erase an object from the container. More... | |
DataObject virtual function overloads. | |
The implementation of these methods is required by the DataObject base class and determines the persistent run-time-type information. | |
const CLID & | clID () const override |
Retrieve class ID. More... | |
static const CLID & | classID () |
Retrieve class ID. More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from DataObject | |
static const CLID & | classID () |
Retrieve reference to class definition structure (static access) More... | |
Protected Member Functions inherited from ObjectContainerBase | |
ObjectContainerBase ()=default | |
Constructor. More... | |
ObjectContainerBase (ObjectContainerBase &&)=default | |
ObjectContainerBase & | operator= (ObjectContainerBase &&)=default |
template class KeyedContainer, KeyedContainer.h
This class represents a container, where the contained objects are accessed by a key. Such a key can be any class, which is able to convert to and from a 32-bit (long) integer.
To insert objects into the container, this implementation determines the key in the following way:
Access to objects is given two-fold:
The KeyedContainer class uses for further specialization a traits class. By specializing these traits extra behaviour can be forced on request for special containers or special keys.
Definition at line 65 of file KeyedContainer.h.
typedef seq_type::const_iterator KeyedContainer< DATATYPE, MAPPING >::const_iterator |
Sequential access: const iterator type used in sequential container.
Definition at line 94 of file KeyedContainer.h.
typedef seq_type::const_reference KeyedContainer< DATATYPE, MAPPING >::const_reference |
Sequential access: const reference type used in sequential container.
Definition at line 90 of file KeyedContainer.h.
typedef seq_type::const_reverse_iterator KeyedContainer< DATATYPE, MAPPING >::const_reverse_iterator |
Sequential access: const reverse iterator type used in sequential container.
Definition at line 100 of file KeyedContainer.h.
typedef DATATYPE KeyedContainer< DATATYPE, MAPPING >::contained_type |
Definition of the contained object type.
Definition at line 71 of file KeyedContainer.h.
typedef MAPPING KeyedContainer< DATATYPE, MAPPING >::container_type |
Definition of the implementing container type.
Definition at line 73 of file KeyedContainer.h.
typedef seq_type::iterator KeyedContainer< DATATYPE, MAPPING >::iterator |
Sequential access: iterator type used in sequential container.
Definition at line 92 of file KeyedContainer.h.
typedef contained_type::key_type KeyedContainer< DATATYPE, MAPPING >::key_type |
Definition of the key type: re-use definition of contained type.
Definition at line 84 of file KeyedContainer.h.
typedef seq_type::reference KeyedContainer< DATATYPE, MAPPING >::reference |
Sequential access: reference type used in sequential container.
Definition at line 88 of file KeyedContainer.h.
typedef seq_type::reverse_iterator KeyedContainer< DATATYPE, MAPPING >::reverse_iterator |
Sequential access: reverse iterator type used in sequential container.
Definition at line 96 of file KeyedContainer.h.
typedef std::vector<contained_type*> KeyedContainer< DATATYPE, MAPPING >::seq_type |
General container specific type definitions.
The following type definitions are generic to most STL containers and are also presented by the KeyedContainer class. These forward declarations typically are used by STL algorithms.Definition of the STL sequential access type
Definition at line 82 of file KeyedContainer.h.
|
private |
Traits class definition.
Specializing traits allows to specialize the container implementation for special needs.
Definition at line 106 of file KeyedContainer.h.
typedef seq_type::value_type KeyedContainer< DATATYPE, MAPPING >::value_type |
Sequential access: definition of type stored in sequential container.
Definition at line 86 of file KeyedContainer.h.
|
inline |
Standard Constructor.
Definition at line 184 of file KeyedContainer.h.
|
inline |
Definition at line 191 of file KeyedContainer.h.
|
delete |
|
inlineoverride |
Destructor.
Inline code for keyed container class.
Definition at line 502 of file KeyedContainer.h.
|
inlineoverridevirtual |
ObjectContainerBase overload: Add an object to the container.
Plese see the documentation of the member function
const key_type& insert(DATATYPE* pObject)
for further details.
pObject | Pointer to the object to be inserted into the container. |
Implements ObjectContainerBase.
Definition at line 612 of file KeyedContainer.h.
|
inline |
Retrieve start iterator.
Definition at line 322 of file KeyedContainer.h.
|
inline |
Retrieve start const iterator.
Definition at line 324 of file KeyedContainer.h.
|
inlinestatic |
|
inline |
Clear the entire content and erase the objects from the container.
Definition at line 294 of file KeyedContainer.h.
|
inlineoverridevirtual |
Retrieve class ID.
Reimplemented from DataObject.
Definition at line 212 of file KeyedContainer.h.
|
inlineoverridevirtual |
ObjectContainerBase overload: Retrieve the object by reference given the long integer representation of the object's key.
Implements ObjectContainerBase.
Definition at line 269 of file KeyedContainer.h.
|
inlinevirtual |
Retrieve the full content of the object container.
v | Vector of contained objects, which will host all objects contained in this container. |
Definition at line 597 of file KeyedContainer.h.
|
inlinevirtual |
Retrieve the full content of the object container by reference.
Returned is the random access container if in sequntial direct access mode. Otherwise the sequential access container is returned
Definition at line 538 of file KeyedContainer.h.
|
inline |
For consistency with STL: check if container is empty.
Definition at line 290 of file KeyedContainer.h.
|
inline |
Retrieve terminating iterator.
Definition at line 326 of file KeyedContainer.h.
|
inline |
Retrieve terminating const iterator.
Definition at line 328 of file KeyedContainer.h.
|
inline |
Remove/erase object (identified by key) from the container.
kval | Key to identify the object within the container. |
Definition at line 392 of file KeyedContainer.h.
|
inline |
Remove/erase object (identified by pointer value) from the container.
This member function removes an object, which is identified by its reference from the container. No key value is supplied. To identify the object within the container, the key of the object is used as it can be retrieved using the KeyedObject::key() method.
val | Reference to object to be removed from the container. |
Definition at line 414 of file KeyedContainer.h.
|
inline |
Remove/erase object (identified by iterator) from the container.
This member function removes an object, which is identified by its reference from the container. No key value is supplied. To identify the object within the container, the key of the object is used as it can be retrieved using the KeyedObject::key() method.
val | Reference to object to be removed from the container. |
Definition at line 436 of file KeyedContainer.h.
|
inline |
Remove/erase objects by iterator range.
This member function removes all objects, which are within the sequential iterator range [pos_start, pos_stop[.
pos_start | Starting iterator of the range to be removed. |
pos_stop | Starting iterator of the range to be removed. |
use_temp | Flag to indicate that a temporary arry should be used. |
Definition at line 641 of file KeyedContainer.h.
|
inlineprivate |
Internal function to erase an object from the container.
Definition at line 142 of file KeyedContainer.h.
|
inlineprivate |
Internal function to access objects within the container.
Definition at line 135 of file KeyedContainer.h.
|
inlineoverridevirtual |
ObjectContainerBase overload: Retrieve the full long integer representation of the object's key from the object base class pointer.
Implements ObjectContainerBase.
Definition at line 587 of file KeyedContainer.h.
|
inline |
Insert entry to the container with a valid key.
This member function inserts an element, which is identified by its reference to the container. The element will be inserted using the specified key. If the object is already keyed, the long representations of the supplied key and the object's key must agree.
The object will not be inserted and an exception will be raised under the following conditions:
val | Reference to object to be inserted into the container. The object reference may NOT be NULL. |
kval | Key to identify the object within the container. |
Definition at line 545 of file KeyedContainer.h.
const KeyedContainer< DATATYPE, MAPPING >::key_type & KeyedContainer< DATATYPE, MAPPING >::insert | ( | const value_type | val | ) |
Insert entry to the container with automatic key assignment.
This member function inserts an element, which is identified by its reference to the container. No key value is supplied. The key used to insert the object is retrieved from the element itself. In the event the object already has a key, the assigned key of the object is used. If no key was assigned to the object, (i.e. the object's key is equal to the invalid key), a key is generated according to the number of objects present in the container.
The object will not be inserted and an exception will be raised under the following conditions:
val | Reference to object to be inserted into the container. |
Definition at line 565 of file KeyedContainer.h.
|
inlineoverridevirtual |
ObjectContainerBase overload: Number of objects in the container.
Implements ObjectContainerBase.
Definition at line 238 of file KeyedContainer.h.
|
inline |
Object access by key.
Access contained objects by key.
kval | Key of the object to be returned. |
Definition at line 356 of file KeyedContainer.h.
|
inline |
STL algorithms support for object access.
Access contained objects by key using the operator(), which is demanded by STL algorithms.
kval | Key of the object to be returned. |
Definition at line 367 of file KeyedContainer.h.
|
inline |
reverse_iterator returns the beginning of the reversed container
Definition at line 330 of file KeyedContainer.h.
|
inline |
const reverse_iterator returns the beginning of the reversed container
Definition at line 332 of file KeyedContainer.h.
|
inlineoverridevirtual |
ObjectContainerBase overload: Remove an object from the container.
Because this function is also called from the destructor of The ContainedObject class, it is no longer possible to deduce the key from the object itself. It is hence necessary to relay on the NON-EXISTENCE of virtual inheritance, ie. (void*)pObject = (void*)(contained_object). If the virtual object table is still intact, the normal erase is called.
pObject | Pointer to the object to be removed from the container. |
Implements ObjectContainerBase.
Definition at line 619 of file KeyedContainer.h.
|
inline |
reverse_iterator pointing to the end of the reversed container
Definition at line 334 of file KeyedContainer.h.
|
inline |
const reverse_iterator pointing to the end of the reversed container
Definition at line 336 of file KeyedContainer.h.
|
inline |
Reserve place for "value" objects in the container.
Definition at line 292 of file KeyedContainer.h.
|
inline |
Number of objects in the container.
Definition at line 288 of file KeyedContainer.h.
|
inlineoverridevirtual |
Reconfigure direct access to elements (Needed by POOL data loading) This function reuses the "update" callback of the generic DataObject base class.
Reimplemented from DataObject.
Definition at line 510 of file KeyedContainer.h.
|
friend |
Definition at line 67 of file KeyedContainer.h.
|
private |
Map container to facilitate object access by key.
Definition at line 112 of file KeyedContainer.h.
|
private |
Array to allow random access to objects (not exposed)
Definition at line 116 of file KeyedContainer.h.
|
private |
Array to allow sequential access to the object (can be ordered).
Definition at line 114 of file KeyedContainer.h.