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

Helper class to provide type-safe access to aux data. More...

#include <Decorator.h>

Collaboration diagram for SG::Decorator< T, ALLOC >:

Public Types

using reference_type = typename AuxDataTraits< T, ALLOC >::reference_type
 Type referencing an item. More...
 
using element_type = typename AuxDataTraits< T, ALLOC >::element_type
 Type the user sees. More...
 
using container_pointer_type = typename AuxDataTraits< T, ALLOC >::container_pointer_type
 Pointer into the container holding this item. More...
 
using const_container_pointer_type = typename AuxDataTraits< T, ALLOC >::const_container_pointer_type
 
using span = typename AuxDataTraits< T, ALLOC >::span
 A span over elements in the container. More...
 
using const_span = typename AuxDataTraits< T, ALLOC >::const_span
 

Public Member Functions

 Decorator (const std::string &name)
 Constructor. More...
 
 Decorator (const std::string &name, const std::string &clsname)
 Constructor. More...
 
 Decorator (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...
 
template<class ELT >
void set (const ELT &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...
 
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...
 
template<class ELT >
bool isAvailable (const ELT &e) const
 Test to see if this variable exists in the store. More...
 
template<class ELT >
bool isAvailableWritable (const ELT &e) 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...
 

Protected Member Functions

 Decorator (const std::string &name, const std::string &clsname, const SG::AuxVarFlags flags)
 Constructor. More...
 
 Decorator (const SG::auxid_t auxid, const SG::AuxVarFlags flags)
 Constructor taking an auxid directly. More...
 

Private Attributes

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

Detailed Description

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

Helper class to provide type-safe access to aux data.

This is like Accessor, except that it only ‘decorates’ the container. What this means is that this object can operate on a const container and return a non-const reference. However, if the container is locked, this will only work if either this is a reference to a new variable, in which case it is marked as a decoration, or it is a reference to a variable already marked as a decoration.

This is written as a separate class in order to be able to cache the name -> auxid lookup.

You might use this something like this:

// Only need to do this once.
SG::Decorator<int> vint1 ("myInt");
...
const Myclass* m = ...;
vint1 (*m) = 123;

Definition at line 57 of file Decorator.h.

Member Typedef Documentation

◆ const_container_pointer_type

template<class T , class ALLOC = AuxAllocator_t<T>>
using SG::Decorator< T, ALLOC >::const_container_pointer_type = typename AuxDataTraits<T, ALLOC>::const_container_pointer_type

Definition at line 69 of file Decorator.h.

◆ const_span

template<class T , class ALLOC = AuxAllocator_t<T>>
using SG::Decorator< T, ALLOC >::const_span = typename AuxDataTraits<T, ALLOC>::const_span

Definition at line 74 of file Decorator.h.

◆ container_pointer_type

template<class T , class ALLOC = AuxAllocator_t<T>>
using SG::Decorator< T, ALLOC >::container_pointer_type = typename AuxDataTraits<T, ALLOC>::container_pointer_type

Pointer into the container holding this item.

Definition at line 67 of file Decorator.h.

◆ element_type

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

Type the user sees.

Definition at line 64 of file Decorator.h.

◆ reference_type

template<class T , class ALLOC = AuxAllocator_t<T>>
using SG::Decorator< T, ALLOC >::reference_type = typename AuxDataTraits<T, ALLOC>::reference_type

Type referencing an item.

Definition at line 61 of file Decorator.h.

◆ span

template<class T , class ALLOC = AuxAllocator_t<T>>
using SG::Decorator< T, ALLOC >::span = typename AuxDataTraits<T, ALLOC>::span

A span over elements in the container.

Definition at line 73 of file Decorator.h.

Constructor & Destructor Documentation

◆ Decorator() [1/5]

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

Constructor.

Parameters
nameName of this aux variable.

The name -> auxid lookup is done here.

◆ Decorator() [2/5]

template<class T , class ALLOC = AuxAllocator_t<T>>
SG::Decorator< T, ALLOC >::Decorator ( 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.

◆ Decorator() [3/5]

template<class T , class ALLOC = AuxAllocator_t<T>>
SG::Decorator< T, ALLOC >::Decorator ( 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.

◆ Decorator() [4/5]

template<class T , class ALLOC = AuxAllocator_t<T>>
SG::Decorator< T, ALLOC >::Decorator ( const std::string &  name,
const std::string &  clsname,
const SG::AuxVarFlags  flags 
)
protected

Constructor.

Parameters
nameName of this aux variable.
clsnameThe name of its associated class. May be blank.
flagsOptional flags qualifying the type. See AuxTypeRegsitry.

The name -> auxid lookup is done here.

◆ Decorator() [5/5]

template<class T , class ALLOC = AuxAllocator_t<T>>
SG::Decorator< T, ALLOC >::Decorator ( const SG::auxid_t  auxid,
const SG::AuxVarFlags  flags 
)
protected

Constructor taking an auxid directly.

Parameters
auxidID for this auxiliary variable.
flagsOptional flags qualifying the type. See AuxTypeRegistry.

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

Member Function Documentation

◆ auxid()

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

Return the aux id for this variable.

◆ getDataArray()

template<class T , class ALLOC = AuxAllocator_t<T>>
const_container_pointer_type SG::Decorator< 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()

template<class T , class ALLOC = AuxAllocator_t<T>>
const_span SG::Decorator< T, ALLOC >::getDataSpan ( const AuxVectorData container) const

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::Decorator< 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()

template<class T , class ALLOC = AuxAllocator_t<T>>
span SG::Decorator< T, ALLOC >::getDecorationSpan ( const AuxVectorData container) const

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()

template<class T , class ALLOC = AuxAllocator_t<T>>
template<class ELT >
bool SG::Decorator< T, ALLOC >::isAvailable ( const ELT &  e) const

Test to see if this variable exists in the store.

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

◆ isAvailableWritable()

template<class T , class ALLOC = AuxAllocator_t<T>>
template<class ELT >
bool SG::Decorator< T, ALLOC >::isAvailableWritable ( const ELT &  e) const

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

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

◆ operator()() [1/2]

template<class T , class ALLOC = AuxAllocator_t<T>>
reference_type SG::Decorator< 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::Decorator< 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()

template<class T , class ALLOC = AuxAllocator_t<T>>
template<class ELT >
void SG::Decorator< T, ALLOC >::set ( const ELT &  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.

Member Data Documentation

◆ m_auxid

template<class T , class ALLOC = AuxAllocator_t<T>>
SG::auxid_t SG::Decorator< T, ALLOC >::m_auxid
private

The cached auxid.

Definition at line 234 of file Decorator.h.


The documentation for this class was generated from the following file:
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
SG::Decorator< int >