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

Handle class for reading a decoration on an object. More...

#include <ReadDecorHandle.h>

Inheritance diagram for SG::ReadDecorHandle< T, D >:
Collaboration diagram for SG::ReadDecorHandle< T, D >:

Public Types

using Base = ReadHandle< T >
 Base class. More...
 
using accessor_t = SG::AuxElement::ConstAccessor< D >
 Accessor type for aux data. More...
 
using const_reference_type = typename accessor_t::const_reference_type
 Type referencing an aux data item. More...
 
using const_container_pointer_type = typename accessor_t::const_container_pointer_type
 Pointer into the vector holding an aux data item. More...
 
using const_span = typename accessor_t::const_span
 Span of aux data items. More...
 

Public Member Functions

 ReadDecorHandle (const ReadDecorHandleKey< T > &key)
 Constructor from a ReadDecorHandleKey. More...
 
 ReadDecorHandle (const ReadDecorHandleKey< T > &key, const EventContext &ctx)
 Constructor from a ReadDecorHandleKey and an explicit event context. More...
 
 ReadDecorHandle (const ReadDecorHandle &rhs)
 Copy constructor. More...
 
 ReadDecorHandle (ReadDecorHandle &&rhs)
 Move constructor. More...
 
ReadDecorHandleoperator= (const ReadDecorHandle &rhs)
 Assignment operator. More...
 
ReadDecorHandleoperator= (ReadDecorHandle &&rhs)
 Move operator. More...
 
bool isPresent () const
 Is the referenced container present in SG? More...
 
const_reference_type operator() (const AuxElement &e) const
 Fetch the variable for one element, as a const reference. More...
 
const_reference_type withDefault (size_t index, const D &deflt)
 Fetch the variable for one element, as a const reference. More...
 
const_reference_type withDefault (const AuxElement &e, const D &deflt) const
 Fetch the variable for one element, as a const reference. More...
 
const_reference_type operator() (size_t index)
 Fetch the variable for one element, as a const reference. More...
 
template<class POINTER_TYPE = const_container_pointer_type, typename = std::enable_if_t<!std::is_void_v<POINTER_TYPE> >>
POINTER_TYPE getDataArray ()
 Get a pointer to the start of the auxiliary data array, for the referenced object. More...
 
const_span getDataSpan ()
 Get a span over the auxilary data array, for the referenced object. More...
 
bool isAvailable ()
 Test to see if this variable exists in the store, for the referenced object. More...
 
SG::auxid_t auxid () const
 Return the aux id for this variable. More...
 
const std::string & decorKey () const
 Return the name of the decoration alias (CONT.DECOR). More...
 

Private Member Functions

const SG::AuxVectorDatavectorData (std::true_type)
 Return the referenced object as a SG::AuxVectorData. More...
 
const SG::AuxVectorDatavectorData (std::false_type)
 Return the referenced object as a SG::AuxVectorData. More...
 
const SG::AuxVectorDatavectorData ()
 Return the referenced object as a SG::AuxVectorData. More...
 

Private Attributes

std::string m_decorKey
 Name of the decoration alias. More...
 
accessor_t m_acc
 Accessor for the aux data item. More...
 

Detailed Description

template<class T, class D>
class SG::ReadDecorHandle< T, D >

Handle class for reading a decoration on an object.

This (and the corresponding WriteDecorHandle class) allow the scheduler to track dependencies on decorations on objects, in addition to the objects themselves. For example, one algorithm could produce a container C, a second could read C and add a decoration to it C.d, and a third algorithm could read the decoration C.d. This allows the scheduler to know that the third algorithm must be executed after the second completes.

A ReadDecorHandle<T, D> works just like a ReadHandle<T> (except that using it as a property directly is not supported). In addition, it has functionality for accessing a decoration of type D, similarly to the interface provided by Accessor objects. You can either read the decoration from a SG::AuxElement object:

x = handle(o);

or reference the element by its index in the container:

x = handle(i);

Example:

class MyAlgorithm : public AthReentrantAlgorithm {
...
};
...
MyAlgorithm::MyAlgorithm (const std::string& name, ISvcLocator* svcloc)
: AthReentrantAlgorithm (name, svcloc), ...
{
declareProperty ("Key", m_key = "container.decor");
...
}
{
ATH_CHECK( m_key.initialize() );
...
}
StatusCode MyAlgorithm::execute (const EventContext& ctx) const
{
for (const MyObj& o : *h) { // Access the container.
doSomething (h (o)); // Access the decoration.
...

Implementation note: we keep track of decorations using aliases. For a container C with decoration d, the WriteDecorHandle will make an alias C.d for C. The ReadDecorHandle will then retrieve C.d from StoreGate. The alias C.d is also what enters into scheduling decisions.

The key() method will return the key of the container. Use decorKey() to get the name used for the decoration alias.

Definition at line 92 of file StoreGate/StoreGate/ReadDecorHandle.h.

Member Typedef Documentation

◆ accessor_t

template<class T , class D >
using SG::ReadDecorHandle< T, D >::accessor_t = SG::AuxElement::ConstAccessor<D>

Accessor type for aux data.

Definition at line 100 of file StoreGate/StoreGate/ReadDecorHandle.h.

◆ Base

template<class T , class D >
using SG::ReadDecorHandle< T, D >::Base = ReadHandle<T>

Base class.

Definition at line 97 of file StoreGate/StoreGate/ReadDecorHandle.h.

◆ const_container_pointer_type

template<class T , class D >
using SG::ReadDecorHandle< T, D >::const_container_pointer_type = typename accessor_t::const_container_pointer_type

Pointer into the vector holding an aux data item.

Definition at line 106 of file StoreGate/StoreGate/ReadDecorHandle.h.

◆ const_reference_type

template<class T , class D >
using SG::ReadDecorHandle< T, D >::const_reference_type = typename accessor_t::const_reference_type

Type referencing an aux data item.

Definition at line 103 of file StoreGate/StoreGate/ReadDecorHandle.h.

◆ const_span

template<class T , class D >
using SG::ReadDecorHandle< T, D >::const_span = typename accessor_t::const_span

Span of aux data items.

Definition at line 109 of file StoreGate/StoreGate/ReadDecorHandle.h.

Constructor & Destructor Documentation

◆ ReadDecorHandle() [1/4]

template<class T , class D >
SG::ReadDecorHandle< T, D >::ReadDecorHandle ( const ReadDecorHandleKey< T > &  key)
explicit

Constructor from a ReadDecorHandleKey.

Parameters
keyThe key object holding the clid/key/store/attr.

This will raise an exception if the StoreGate key is blank, or if the event store cannot be found.

◆ ReadDecorHandle() [2/4]

template<class T , class D >
SG::ReadDecorHandle< T, D >::ReadDecorHandle ( const ReadDecorHandleKey< T > &  key,
const EventContext &  ctx 
)
explicit

Constructor from a ReadDecorHandleKey and an explicit event context.

Parameters
keyThe key object holding the clid/key.
ctxThe event context.

This will raise an exception if the StoreGate key is blank, or if the event store cannot be found.

If the default event store has been requested, then the thread-specific store from the event context will be used.

◆ ReadDecorHandle() [3/4]

template<class T , class D >
SG::ReadDecorHandle< T, D >::ReadDecorHandle ( const ReadDecorHandle< T, D > &  rhs)

Copy constructor.

◆ ReadDecorHandle() [4/4]

template<class T , class D >
SG::ReadDecorHandle< T, D >::ReadDecorHandle ( ReadDecorHandle< T, D > &&  rhs)

Move constructor.

Member Function Documentation

◆ auxid()

template<class T , class D >
SG::auxid_t SG::ReadDecorHandle< T, D >::auxid ( ) const

Return the aux id for this variable.

◆ decorKey()

template<class T , class D >
const std::string& SG::ReadDecorHandle< T, D >::decorKey ( ) const

Return the name of the decoration alias (CONT.DECOR).

◆ getDataArray()

template<class T , class D >
template<class POINTER_TYPE = const_container_pointer_type, typename = std::enable_if_t<!std::is_void_v<POINTER_TYPE> >>
POINTER_TYPE SG::ReadDecorHandle< T, D >::getDataArray ( )

Get a pointer to the start of the auxiliary data array, for the referenced object.

◆ getDataSpan()

template<class T , class D >
const_span SG::ReadDecorHandle< T, D >::getDataSpan ( )

Get a span over the auxilary data array, for the referenced object.

◆ isAvailable()

template<class T , class D >
bool SG::ReadDecorHandle< T, D >::isAvailable ( )

Test to see if this variable exists in the store, for the referenced object.

◆ isPresent()

template<class T , class D >
bool SG::ReadDecorHandle< T, D >::isPresent ( ) const

Is the referenced container present in SG?

Note that this tests for the presence of the container, not for the decoration.

Const method; the handle does not change as a result of this.

◆ operator()() [1/2]

template<class T , class D >
const_reference_type SG::ReadDecorHandle< T, D >::operator() ( const AuxElement e) const

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

Parameters
eThe element for which to fetch the variable.

◆ operator()() [2/2]

template<class T , class D >
const_reference_type SG::ReadDecorHandle< T, D >::operator() ( size_t  index)

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

Parameters
indexThe index of the desired element.

This looks up the variable in the object referenced by this handle. For a standalone object, pass an index of 0.

◆ operator=() [1/2]

template<class T , class D >
ReadDecorHandle& SG::ReadDecorHandle< T, D >::operator= ( const ReadDecorHandle< T, D > &  rhs)

Assignment operator.

◆ operator=() [2/2]

template<class T , class D >
ReadDecorHandle& SG::ReadDecorHandle< T, D >::operator= ( ReadDecorHandle< T, D > &&  rhs)

Move operator.

◆ vectorData() [1/3]

template<class T , class D >
const SG::AuxVectorData* SG::ReadDecorHandle< T, D >::vectorData ( )
private

Return the referenced object as a SG::AuxVectorData.

If T is a container object, then this should be the object itself. But if it is a standalone object, deriving from SG::AuxElement, then we need to call container() on the object.

◆ vectorData() [2/3]

template<class T , class D >
const SG::AuxVectorData* SG::ReadDecorHandle< T, D >::vectorData ( std::false_type  )
private

Return the referenced object as a SG::AuxVectorData.

Specialization for the case of a container (T does not derive from SG::AuxElement).

◆ vectorData() [3/3]

template<class T , class D >
const SG::AuxVectorData* SG::ReadDecorHandle< T, D >::vectorData ( std::true_type  )
private

Return the referenced object as a SG::AuxVectorData.

Specialization for the case of a standalone object (T derives from SG::AuxElement).

◆ withDefault() [1/2]

template<class T , class D >
const_reference_type SG::ReadDecorHandle< T, D >::withDefault ( const AuxElement e,
const D &  deflt 
) const

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

Parameters
eThe element for which to fetch the variable.
defltDefault value.

If this variable is not available, then return deflt instead.

◆ withDefault() [2/2]

template<class T , class D >
const_reference_type SG::ReadDecorHandle< T, D >::withDefault ( size_t  index,
const D &  deflt 
)

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

Parameters
indexThe index of the desired element.
defltDefault value.

This looks up the variable in the object referenced by this handle. For a standalone object, pass an index of 0. If this variable is not available, then return deflt instead.

Member Data Documentation

◆ m_acc

template<class T , class D >
accessor_t SG::ReadDecorHandle< T, D >::m_acc
private

Accessor for the aux data item.

Definition at line 280 of file StoreGate/StoreGate/ReadDecorHandle.h.

◆ m_decorKey

template<class T , class D >
std::string SG::ReadDecorHandle< T, D >::m_decorKey
private

Name of the decoration alias.

Definition at line 276 of file StoreGate/StoreGate/ReadDecorHandle.h.


The documentation for this class was generated from the following file:
initialize
void initialize()
Definition: run_EoverP.cxx:894
x
#define x
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
LArG4FSStartPointFilterLegacy.execute
execute
Definition: LArG4FSStartPointFilterLegacy.py:20
SG::ReadDecorHandle
Handle class for reading a decoration on an object.
Definition: StoreGate/StoreGate/ReadDecorHandle.h:94
lumiFormat.i
int i
Definition: lumiFormat.py:85
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
extractSporadic.h
list h
Definition: extractSporadic.py:97
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
h
SG::ReadDecorHandleKey
Property holding a SG store/key/clid/attr name from which a ReadDecorHandle is made.
Definition: StoreGate/StoreGate/ReadDecorHandleKey.h:85