ATLAS Offline Software
Public Types | Public Member Functions | Private Attributes | List of all members
SG::SlotSpecificObj< T > Class Template Reference

Maintain a set of objects, one per slot. More...

#include <SlotSpecificObj.h>

Collaboration diagram for SG::SlotSpecificObj< T >:

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...
 

Detailed Description

template<class T>
class SG::SlotSpecificObj< T >

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:

Definition at line 69 of file AthenaKernel/AthenaKernel/SlotSpecificObj.h.

Member Typedef Documentation

◆ const_iterator

template<class T >
typedef std::vector<T>::const_iterator SG::SlotSpecificObj< T >::const_iterator

Definition at line 155 of file AthenaKernel/AthenaKernel/SlotSpecificObj.h.

◆ iterator

template<class T >
typedef std::vector<T>::iterator SG::SlotSpecificObj< T >::iterator

Definition at line 154 of file AthenaKernel/AthenaKernel/SlotSpecificObj.h.

◆ value_type

template<class T >
typedef std::vector<T>::value_type SG::SlotSpecificObj< T >::value_type

Definition at line 156 of file AthenaKernel/AthenaKernel/SlotSpecificObj.h.

Constructor & Destructor Documentation

◆ SlotSpecificObj() [1/2]

template<class T >
SG::SlotSpecificObj< T >::SlotSpecificObj ( )

Constructor.

The number of slots will be found by calling getNSlots().

◆ SlotSpecificObj() [2/2]

template<class T >
SG::SlotSpecificObj< T >::SlotSpecificObj ( size_t  nslots)

Constructor, with number of slots specified explicitly.

Parameters
nslotsThe number of event slots.

Member Function Documentation

◆ begin() [1/2]

template<class T >
iterator SG::SlotSpecificObj< T >::begin ( )

Begin iterator.

◆ begin() [2/2]

template<class T >
const_iterator SG::SlotSpecificObj< T >::begin ( ) const

Const begin iterator.

◆ end() [1/2]

template<class T >
iterator SG::SlotSpecificObj< T >::end ( )

End iterator.

◆ end() [2/2]

template<class T >
const_iterator SG::SlotSpecificObj< T >::end ( ) const

Const end iterator.

◆ get() [1/4]

template<class T >
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.

◆ get() [2/4]

template<class T >
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.

◆ get() [3/4]

template<class T >
T* SG::SlotSpecificObj< T >::get ( const EventContext &  ctx)

Return pointer to the object for slot given by ctx.

Parameters
ctxEvent context giving the desired slot.

◆ get() [4/4]

template<class T >
const T* SG::SlotSpecificObj< T >::get ( const EventContext &  ctx) const

Return pointer to the object for slot given by ctx.

Parameters
ctxEvent context giving the desired slot.

◆ operator*() [1/2]

template<class T >
T& SG::SlotSpecificObj< T >::operator* ( )

Dereference the pointer.

The slot number is found by retrieving the global current context.

◆ operator*() [2/2]

template<class T >
const T& SG::SlotSpecificObj< T >::operator* ( ) const

Dereference the pointer.

The slot number is found by retrieving the global current context.

◆ operator->() [1/2]

template<class T >
T* SG::SlotSpecificObj< T >::operator-> ( )

Dereference the pointer.

The slot number is found by retrieving the global current context.

◆ operator->() [2/2]

template<class T >
const T* SG::SlotSpecificObj< T >::operator-> ( ) const

Dereference the pointer.

The slot number is found by retrieving the global current context.

Member Data Documentation

◆ m_slots

template<class T >
std::vector<T> SG::SlotSpecificObj< T >::m_slots
private

Set of per-slot objects.

Definition at line 185 of file AthenaKernel/AthenaKernel/SlotSpecificObj.h.


The documentation for this class was generated from the following file: