ATLAS Offline Software
|
Helper class to provide constant type-safe access to aux data. More...
#include <ConstAccessor.h>
Public Types | |
using | element_type = typename AuxDataTraits< T, ALLOC >::element_type |
Type the user sees. More... | |
using | const_reference_type = typename AuxDataTraits< T, ALLOC >::const_reference_type |
Type referencing an item. More... | |
using | const_container_pointer_type = typename AuxDataTraits< T, ALLOC >::const_container_pointer_type |
Pointer into the container holding this item. More... | |
using | const_span = typename AuxDataTraits< T, ALLOC >::const_span |
A span over elements in the container. More... | |
Public Member Functions | |
ConstAccessor (const std::string &name) | |
Constructor. More... | |
ConstAccessor (const std::string &name, const std::string &clsname) | |
Constructor. More... | |
ConstAccessor (const SG::auxid_t auxid) | |
Constructor taking an auxid directly. More... | |
template<class ELT > | |
const_reference_type | operator() (const ELT &e) const |
Fetch the variable for one element, as a const reference. More... | |
const_reference_type | operator() (const AuxVectorData &container, size_t index) const |
Fetch the variable for one element, as a const reference. More... | |
template<class ELT > | |
const_reference_type | withDefault (const ELT &e, const T &deflt) const |
Fetch the variable for one element, as a const reference, with a default. More... | |
const_reference_type | withDefault (const AuxVectorData &container, size_t index, const T &deflt) const |
Fetch the variable for one element, as a const reference. More... | |
const_container_pointer_type | getDataArray (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... | |
template<class ELT > | |
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... | |
SG::auxid_t | auxid () const |
Return the aux id for this variable. More... | |
Protected Member Functions | |
ConstAccessor (const std::string &name, const std::string &clsname, const SG::AuxVarFlags flags) | |
Constructor. More... | |
ConstAccessor (const SG::auxid_t auxid, const SG::AuxVarFlags flags) | |
Constructor taking an auxid directly. More... | |
Protected Attributes | |
SG::auxid_t | m_auxid |
The cached auxid . More... | |
Helper class to provide constant type-safe access to aux data.
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:
This class can be used only for reading data. To modify data, see the class Accessor
.
Definition at line 54 of file ConstAccessor.h.
using SG::ConstAccessor< T, ALLOC >::const_container_pointer_type = typename AuxDataTraits<T, ALLOC>::const_container_pointer_type |
Pointer into the container holding this item.
Definition at line 65 of file ConstAccessor.h.
using SG::ConstAccessor< T, ALLOC >::const_reference_type = typename AuxDataTraits<T, ALLOC>::const_reference_type |
Type referencing an item.
Definition at line 61 of file ConstAccessor.h.
using SG::ConstAccessor< T, ALLOC >::const_span = typename AuxDataTraits<T, ALLOC>::const_span |
A span over elements in the container.
Definition at line 69 of file ConstAccessor.h.
using SG::ConstAccessor< T, ALLOC >::element_type = typename AuxDataTraits<T, ALLOC>::element_type |
Type the user sees.
Definition at line 58 of file ConstAccessor.h.
SG::ConstAccessor< T, ALLOC >::ConstAccessor | ( | const std::string & | name | ) |
Constructor.
name | Name of this aux variable. |
The name -> auxid lookup is done here.
SG::ConstAccessor< T, ALLOC >::ConstAccessor | ( | const std::string & | name, |
const std::string & | clsname | ||
) |
Constructor.
name | Name of this aux variable. |
clsname | The name of its associated class. May be blank. |
The name -> auxid lookup is done here.
SG::ConstAccessor< T, ALLOC >::ConstAccessor | ( | const SG::auxid_t | auxid | ) |
Constructor taking an auxid directly.
auxid | ID for this auxiliary variable. |
Will throw SG::ExcAuxTypeMismatch
if the types don't match.
|
protected |
Constructor.
name | Name of this aux variable. |
clsname | The name of its associated class. May be blank. |
flags | Optional flags qualifying the type. See AuxTypeRegistry. |
The name -> auxid lookup is done here.
|
protected |
Constructor taking an auxid directly.
auxid | ID for this auxiliary variable. |
flags | Optional flags qualifying the type. See AuxTypeRegistry. |
Will throw SG::ExcAuxTypeMismatch
if the types don't match.
SG::auxid_t SG::ConstAccessor< T, ALLOC >::auxid | ( | ) | const |
Return the aux id for this variable.
const_container_pointer_type SG::ConstAccessor< T, ALLOC >::getDataArray | ( | const AuxVectorData & | container | ) | const |
Get a pointer to the start of the auxiliary data array.
container | The container from which to fetch the variable. |
const_span SG::ConstAccessor< T, ALLOC >::getDataSpan | ( | const AuxVectorData & | container | ) | const |
Get a span over the auxilary data array.
container | The container from which to fetch the variable. |
bool SG::ConstAccessor< T, ALLOC >::isAvailable | ( | const AuxVectorData & | c | ) | const |
Test to see if this variable exists in the store.
c | The container in which to test the variable. |
bool SG::ConstAccessor< T, ALLOC >::isAvailable | ( | const ELT & | e | ) | const |
Test to see if this variable exists in the store.
e | An element of the container in which to test the variable. |
const_reference_type SG::ConstAccessor< T, ALLOC >::operator() | ( | const AuxVectorData & | container, |
size_t | index | ||
) | const |
Fetch the variable for one element, as a const reference.
container | The container from which to fetch the variable. |
index | The 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.
const_reference_type SG::ConstAccessor< T, ALLOC >::operator() | ( | const ELT & | e | ) | const |
Fetch the variable for one element, as a const reference.
e | The element for which to fetch the variable. |
const_reference_type SG::ConstAccessor< T, ALLOC >::withDefault | ( | const AuxVectorData & | container, |
size_t | index, | ||
const T & | deflt | ||
) | const |
Fetch the variable for one element, as a const reference.
container | The container from which to fetch the variable. |
index | The index of the desired element. |
deflt | Default value. |
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 this variable is not available, then return deflt
instead.
const_reference_type SG::ConstAccessor< T, ALLOC >::withDefault | ( | const ELT & | e, |
const T & | deflt | ||
) | const |
Fetch the variable for one element, as a const reference, with a default.
e | The element for which to fetch the variable. |
deflt | Default value. |
If this variable is not available, then return deflt
instead.
|
protected |
The cached auxid
.
Definition at line 214 of file ConstAccessor.h.