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

Access an auxiliary variable atomically. More...

#include <AtomicDecorator.h>

Inheritance diagram for SG::AtomicDecorator< T, ALLOC >:
Collaboration diagram for SG::AtomicDecorator< T, ALLOC >:

Public Types

using Base = Decorator< T, ALLOC >
 Base class. More...
 
using reference_type = std::atomic< T > &
 Type referencing an item. More...
 
using element_type = typename AuxDataTraits< T, ALLOC >::element_type
 Type the user sees. More...
 
using container_pointer_type = std::atomic< T > *
 Pointer into the container holding this item. More...
 
using const_container_pointer_type = const std::atomic< T > *
 
using span = typename AuxDataTraits< T, AuxAllocator_t< T > >::span
 A span over elements in the container. More...
 
using const_span = typename AuxDataTraits< T, AuxAllocator_t< T > >::const_span
 

Public Member Functions

 AtomicDecorator (const std::string &name)
 Constructor. More...
 
 AtomicDecorator (const std::string &name, const std::string &clsname)
 Constructor. More...
 
 AtomicDecorator (const SG::auxid_t auxid)
 Constructor taking an auxid directly. More...
 
template<class ELT >
reference_type operator() (const ELT &e) const
 Fetch the variable for one element, as a non-const reference. More...
 
reference_type operator() (const AuxVectorData &container, size_t index) const
 Fetch the variable for one element, as a non-const reference. More...
 
void set (const AuxElement &e, const element_type &x) const
 Set the variable for one element. More...
 
const_container_pointer_type getDataArray (const AuxVectorData &container) const
 Get a pointer to the start of the auxiliary data array. More...
 
container_pointer_type getDecorationArray (const AuxVectorData &container) const
 Get a pointer to the start of the auxiliary data array. More...
 
void set (const ELT &e, const element_type &x) const
 Set the variable for one element. More...
 
const_span getDataSpan (const AuxVectorData &container) const
 Get a span over the auxilary data array. More...
 
span getDecorationSpan (const AuxVectorData &container) const
 Get a span over the auxilary data array. More...
 
bool isAvailable (const ELT &e) const
 Test to see if this variable exists in the store. More...
 
bool isAvailable (const AuxVectorData &c) const
 Test to see if this variable exists in the store. More...
 
bool isAvailableWritable (const ELT &e) const
 Test to see if this variable exists in the store and is writable. More...
 
bool isAvailableWritable (const AuxVectorData &c) const
 Test to see if this variable exists in the store and is writable. More...
 
SG::auxid_t auxid () const
 Return the aux id for this variable. More...
 

Private Attributes

SG::auxid_t m_auxid
 The cached auxid. More...
 

Detailed Description

template<class T, class ALLOC = AuxAllocator_t<T>>
class SG::AtomicDecorator< T, ALLOC >

Access an auxiliary variable atomically.

Definition at line 42 of file AtomicDecorator.h.

Member Typedef Documentation

◆ Base

template<class T , class ALLOC = AuxAllocator_t<T>>
using SG::AtomicDecorator< T, ALLOC >::Base = Decorator<T, ALLOC>

Base class.

Definition at line 47 of file AtomicDecorator.h.

◆ const_container_pointer_type

template<class T , class ALLOC = AuxAllocator_t<T>>
using SG::AtomicDecorator< T, ALLOC >::const_container_pointer_type = const std::atomic<T>*

Definition at line 57 of file AtomicDecorator.h.

◆ const_span

using SG::Decorator< T, AuxAllocator_t< T > >::const_span = typename AuxDataTraits<T, AuxAllocator_t< T > >::const_span
inherited

Definition at line 75 of file Decorator.h.

◆ container_pointer_type

template<class T , class ALLOC = AuxAllocator_t<T>>
using SG::AtomicDecorator< T, ALLOC >::container_pointer_type = std::atomic<T>*

Pointer into the container holding this item.

Definition at line 56 of file AtomicDecorator.h.

◆ element_type

template<class T , class ALLOC = AuxAllocator_t<T>>
using SG::AtomicDecorator< T, ALLOC >::element_type = typename AuxDataTraits<T, ALLOC>::element_type

Type the user sees.

Definition at line 53 of file AtomicDecorator.h.

◆ reference_type

template<class T , class ALLOC = AuxAllocator_t<T>>
using SG::AtomicDecorator< T, ALLOC >::reference_type = std::atomic<T>&

Type referencing an item.

Definition at line 50 of file AtomicDecorator.h.

◆ span

using SG::Decorator< T, AuxAllocator_t< T > >::span = typename AuxDataTraits<T, AuxAllocator_t< T > >::span
inherited

A span over elements in the container.

Definition at line 74 of file Decorator.h.

Constructor & Destructor Documentation

◆ AtomicDecorator() [1/3]

template<class T , class ALLOC = AuxAllocator_t<T>>
SG::AtomicDecorator< T, ALLOC >::AtomicDecorator ( const std::string &  name)

Constructor.

Parameters
nameName of this aux variable.

The name -> auxid lookup is done here.

◆ AtomicDecorator() [2/3]

template<class T , class ALLOC = AuxAllocator_t<T>>
SG::AtomicDecorator< T, ALLOC >::AtomicDecorator ( const std::string &  name,
const std::string &  clsname 
)

Constructor.

Parameters
nameName of this aux variable.
clsnameThe name of its associated class. May be blank.

The name -> auxid lookup is done here.

◆ AtomicDecorator() [3/3]

template<class T , class ALLOC = AuxAllocator_t<T>>
SG::AtomicDecorator< T, ALLOC >::AtomicDecorator ( const SG::auxid_t  auxid)

Constructor taking an auxid directly.

Parameters
auxidID for this auxiliary variable.

Will throw SG::ExcAuxTypeMismatch if the types don't match.

Member Function Documentation

◆ auxid()

SG::auxid_t SG::Decorator< T, AuxAllocator_t< T > >::auxid
inherited

Return the aux id for this variable.

◆ getDataArray()

template<class T , class ALLOC = AuxAllocator_t<T>>
const_container_pointer_type SG::AtomicDecorator< T, ALLOC >::getDataArray ( const AuxVectorData container) const

Get a pointer to the start of the auxiliary data array.

Parameters
containerThe container from which to fetch the variable.

◆ getDataSpan()

const_span SG::Decorator< T, AuxAllocator_t< T > >::getDataSpan ( const AuxVectorData container) const
inherited

Get a span over the auxilary data array.

Parameters
containerThe container from which to fetch the variable.

◆ getDecorationArray()

template<class T , class ALLOC = AuxAllocator_t<T>>
container_pointer_type SG::AtomicDecorator< T, ALLOC >::getDecorationArray ( const AuxVectorData container) const

Get a pointer to the start of the auxiliary data array.

Parameters
containerThe container from which to fetch the variable.

If the container is locked, this will allow fetching only variables that do not yet exist (in which case they will be marked as decorations) or variables already marked as decorations.

◆ getDecorationSpan()

span SG::Decorator< T, AuxAllocator_t< T > >::getDecorationSpan ( const AuxVectorData container) const
inherited

Get a span over the auxilary data array.

Parameters
containerThe container from which to fetch the variable.

If the container is locked, this will allow fetching only variables that do not yet exist (in which case they will be marked as decorations) or variables already marked as decorations.

◆ isAvailable() [1/2]

bool SG::Decorator< T, AuxAllocator_t< T > >::isAvailable ( const AuxVectorData c) const
inherited

Test to see if this variable exists in the store.

Parameters
cThe container in which to test the variable.

◆ isAvailable() [2/2]

bool SG::Decorator< T, AuxAllocator_t< T > >::isAvailable ( const ELT &  e) const
inherited

Test to see if this variable exists in the store.

Parameters
eAn element of the container in which to test the variable.

◆ isAvailableWritable() [1/2]

bool SG::Decorator< T, AuxAllocator_t< T > >::isAvailableWritable ( const AuxVectorData c) const
inherited

Test to see if this variable exists in the store and is writable.

Parameters
cThe container in which to test the variable.

◆ isAvailableWritable() [2/2]

bool SG::Decorator< T, AuxAllocator_t< T > >::isAvailableWritable ( const ELT &  e) const
inherited

Test to see if this variable exists in the store and is writable.

Parameters
eAn element of the container in which to test the variable.

◆ operator()() [1/2]

template<class T , class ALLOC = AuxAllocator_t<T>>
reference_type SG::AtomicDecorator< T, ALLOC >::operator() ( const AuxVectorData container,
size_t  index 
) const

Fetch the variable for one element, as a non-const reference.

Parameters
containerThe container from which to fetch the variable.
indexThe index of the desired element.

This allows retrieving aux data by container / index. Looping over the index via this method will be faster then looping over the elements of the container.

If the container is locked, this will allow fetching only variables that do not yet exist (in which case they will be marked as decorations) or variables already marked as decorations.

◆ operator()() [2/2]

template<class T , class ALLOC = AuxAllocator_t<T>>
template<class ELT >
reference_type SG::AtomicDecorator< T, ALLOC >::operator() ( const ELT &  e) const

Fetch the variable for one element, as a non-const reference.

Parameters
eThe element for which to fetch the variable.

If the container is locked, this will allow fetching only variables that do not yet exist (in which case they will be marked as decorations) or variables already marked as decorations.

◆ set() [1/2]

template<class T , class ALLOC = AuxAllocator_t<T>>
void SG::AtomicDecorator< T, ALLOC >::set ( const AuxElement e,
const element_type x 
) const

Set the variable for one element.

Parameters
eThe element for which to fetch the variable.
xThe variable value to set.

◆ set() [2/2]

void SG::Decorator< T, AuxAllocator_t< T > >::set ( const ELT &  e,
const element_type x 
) const
inherited

Set the variable for one element.

Parameters
eThe element for which to fetch the variable.
xThe variable value to set.

Member Data Documentation

◆ m_auxid

SG::auxid_t SG::Decorator< T, AuxAllocator_t< T > >::m_auxid
privateinherited

The cached auxid.

Definition at line 249 of file Decorator.h.


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