ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
AthAlgStartVisitor Class Reference

Call start() on all ReadCondHandle's of an algorithm. More...

#include <AthAlgStartVisitor.h>

Inheritance diagram for AthAlgStartVisitor:
Collaboration diagram for AthAlgStartVisitor:

Public Member Functions

virtual void visit (const IDataHandleHolder *holder) override
 Visit a component and start() any read conditions handles. More...
 
 AthAlgStartVisitor ()=default
 
 AthAlgStartVisitor (INamedInterface *)
 Figure out where we're called from. More...
 

Private Attributes

std::unordered_set< const IDataHandleHolder * > m_seen
 figure out where we're called from More...
 
bool m_recursive {true}
 
bool m_ignore {false}
 process recursively (for Algs) More...
 

Detailed Description

Call start() on all ReadCondHandle's of an algorithm.

For efficient conditions handling, a CondHandleKey needs to cache a pointer to the conditions container. initialize() is too early for this as conditions containers made by CondInputLoader are not created until start(). So during the start() of an algorithm, we visit all read conditions handle keys and call start() on them, to give them the opportunity to look up the conditions object.

We use IDataHandleVisitor to do this recursively for all owned tools as well.

FIXME: this should probably be moved to GaudiKernel, and have all AlgTools started by their parent Algorithms

Definition at line 39 of file AthAlgStartVisitor.h.

Constructor & Destructor Documentation

◆ AthAlgStartVisitor() [1/2]

AthAlgStartVisitor::AthAlgStartVisitor ( )
default

◆ AthAlgStartVisitor() [2/2]

AthAlgStartVisitor::AthAlgStartVisitor ( INamedInterface *  n)

Figure out where we're called from.

Only want to process holders recursively if caller is a real Algorithm. If it's an AlgTool, don't recurse. If it's a Sequence, don't do anything.

Parameters
nback pointer to parent

Definition at line 26 of file AthAlgStartVisitor.cxx.

26  {
27  // only do recursive traversal if we are called from a real Algorithm
28  IAlgorithm* ia = dynamic_cast<IAlgorithm*>(n);
29  if ( ia == nullptr) {
30  m_recursive = false;
31  } else if ( ia->isSequence() ) {
32  m_recursive = false;
33  m_ignore = true;
34  }
35 }

Member Function Documentation

◆ visit()

void AthAlgStartVisitor::visit ( const IDataHandleHolder *  holder)
overridevirtual

Visit a component and start() any read conditions handles.

Parameters
holderThe component to visit.

Definition at line 42 of file AthAlgStartVisitor.cxx.

43 {
44  if (m_ignore) return;
45 
46  // Make sure we process a component only once.
47  if (m_seen.insert (holder).second) {
48 
49  // Check all input handles are initialised
50  for (Gaudi::DataHandle* h : holder->inputHandles()) {
51 
52  auto vhk = dynamic_cast<SG::VarHandleKey*> (h);
53  if (!vhk) throw SG::ExcNullHandleKey();
54 
55  if (!vhk->storeHandle().get() && !vhk->key().empty()) {
56  throw SG::ExcUninitKey (vhk->clid(), vhk->key(), vhk->storeHandle().name(), holder->name());
57  }
58 
59  // Call start() on all read conditions handle keys.
60  if (h->isCondition()) {
61  vhk->start().ignore();
62  }
63  }
64 
65  // Check all output handles are initialised
66  for (Gaudi::DataHandle* h : holder->outputHandles()) {
67 
68  auto vhk = dynamic_cast< SG::VarHandleKey* > (h);
69  if (!vhk) throw SG::ExcNullHandleKey();
70 
71  if (!vhk->storeHandle().get() && !vhk->key().empty()) {
72  throw SG::ExcUninitKey (vhk->clid(), vhk->key(), vhk->storeHandle().name(), holder->name());
73  }
74  }
75 
76  if (m_recursive) {
77  holder->acceptDHVisitor (this);
78  }
79  }
80 }

Member Data Documentation

◆ m_ignore

bool AthAlgStartVisitor::m_ignore {false}
private

process recursively (for Algs)

Definition at line 56 of file AthAlgStartVisitor.h.

◆ m_recursive

bool AthAlgStartVisitor::m_recursive {true}
private

Definition at line 55 of file AthAlgStartVisitor.h.

◆ m_seen

std::unordered_set<const IDataHandleHolder*> AthAlgStartVisitor::m_seen
private

figure out where we're called from

Keep track of components we've already processed.

Definition at line 54 of file AthAlgStartVisitor.h.


The documentation for this class was generated from the following files:
SG::ExcNullHandleKey
Exception — Attempt to dereference a Read/Write/UpdateHandle with a null key.
Definition: Control/StoreGate/StoreGate/exceptions.h:38
AthAlgStartVisitor::m_seen
std::unordered_set< const IDataHandleHolder * > m_seen
figure out where we're called from
Definition: AthAlgStartVisitor.h:54
AthAlgStartVisitor::m_ignore
bool m_ignore
process recursively (for Algs)
Definition: AthAlgStartVisitor.h:56
beamspotman.n
n
Definition: beamspotman.py:731
extractSporadic.h
list h
Definition: extractSporadic.py:97
AthAlgStartVisitor::m_recursive
bool m_recursive
Definition: AthAlgStartVisitor.h:55
SG::VarHandleKey
A property holding a SG store/key/clid from which a VarHandle is made.
Definition: StoreGate/StoreGate/VarHandleKey.h:62
h
SG::ExcUninitKey
Exception — Tried to create a handle from an uninitialized key.
Definition: Control/StoreGate/StoreGate/exceptions.h:111