ATLAS Offline Software
|
Maintain a set of objects, one per slot. More...
#include <SlotSpecificObj.h>
Public Types | |
typedef std::vector< T >::iterator | iterator |
typedef std::vector< T >::const_iterator | const_iterator |
typedef std::vector< T >::value_type | value_type |
Public Member Functions | |
SlotSpecificObj () | |
Constructor. More... | |
SlotSpecificObj (size_t nslots) | |
Constructor, with number of slots specified explicitly. More... | |
T * | get (const EventContext &ctx) |
Return pointer to the object for slot given by ctx . More... | |
T * | get () |
Return pointer to the object for the current slot. More... | |
const T * | get (const EventContext &ctx) const |
Return pointer to the object for slot given by ctx . More... | |
const T * | get () const |
Return pointer to the object for the current slot. More... | |
T & | operator* () |
Dereference the pointer. More... | |
const T & | operator* () const |
Dereference the pointer. More... | |
T * | operator-> () |
Dereference the pointer. More... | |
const T * | operator-> () const |
Dereference the pointer. More... | |
iterator | begin () |
Begin iterator. More... | |
const_iterator | begin () const |
Const begin iterator. More... | |
iterator | end () |
End iterator. More... | |
const_iterator | end () const |
Const end iterator. More... | |
Private Attributes | |
std::vector< T > | m_slots |
Set of per-slot objects. More... | |
Maintain a set of objects, one per slot.
The payload T
must be default-constructable. One such instance of T
will be made for each event slot.
The usual pointer operators may be used to access the object, as well as get()
. get()
also takes an optional event context argument, to allow specifying the slot explicitly, rather than looking it up in a thread-local global.
This class does not do anything itself to protect the contents of the payload objects against simultaneous access from different threads. Especially if the owner is a service or a reentrant algorithm, multiple threads may be executing simultaneously for the same slot. In such cases, T
must be safe against simultaneous access from multiple threads, possibly with an internal lock or using std::atomic.
This is similiar to ContextSpecificPtr
from Gaudi, but with some important differences:
EventContext
argument. Definition at line 69 of file AthenaKernel/AthenaKernel/SlotSpecificObj.h.
typedef std::vector<T>::const_iterator SG::SlotSpecificObj< T >::const_iterator |
Definition at line 155 of file AthenaKernel/AthenaKernel/SlotSpecificObj.h.
typedef std::vector<T>::iterator SG::SlotSpecificObj< T >::iterator |
Definition at line 154 of file AthenaKernel/AthenaKernel/SlotSpecificObj.h.
typedef std::vector<T>::value_type SG::SlotSpecificObj< T >::value_type |
Definition at line 156 of file AthenaKernel/AthenaKernel/SlotSpecificObj.h.
SG::SlotSpecificObj< T >::SlotSpecificObj | ( | ) |
Constructor.
The number of slots will be found by calling getNSlots()
.
SG::SlotSpecificObj< T >::SlotSpecificObj | ( | size_t | nslots | ) |
Constructor, with number of slots specified explicitly.
nslots | The number of event slots. |
iterator SG::SlotSpecificObj< T >::begin | ( | ) |
Begin iterator.
const_iterator SG::SlotSpecificObj< T >::begin | ( | ) | const |
Const begin iterator.
iterator SG::SlotSpecificObj< T >::end | ( | ) |
End iterator.
const_iterator SG::SlotSpecificObj< T >::end | ( | ) | const |
Const end iterator.
T* SG::SlotSpecificObj< T >::get | ( | ) |
Return pointer to the object for the current slot.
The slot number is found by retrieving the global current context.
const T* SG::SlotSpecificObj< T >::get | ( | ) | const |
Return pointer to the object for the current slot.
The slot number is found by retrieving the global current context.
T* SG::SlotSpecificObj< T >::get | ( | const EventContext & | ctx | ) |
Return pointer to the object for slot given by ctx
.
ctx | Event context giving the desired slot. |
const T* SG::SlotSpecificObj< T >::get | ( | const EventContext & | ctx | ) | const |
Return pointer to the object for slot given by ctx
.
ctx | Event context giving the desired slot. |
T& SG::SlotSpecificObj< T >::operator* | ( | ) |
Dereference the pointer.
The slot number is found by retrieving the global current context.
const T& SG::SlotSpecificObj< T >::operator* | ( | ) | const |
Dereference the pointer.
The slot number is found by retrieving the global current context.
T* SG::SlotSpecificObj< T >::operator-> | ( | ) |
Dereference the pointer.
The slot number is found by retrieving the global current context.
const T* SG::SlotSpecificObj< T >::operator-> | ( | ) | const |
Dereference the pointer.
The slot number is found by retrieving the global current context.
|
private |
Set of per-slot objects.
Definition at line 185 of file AthenaKernel/AthenaKernel/SlotSpecificObj.h.