ATLAS Offline Software
AthAlgStartVisitor.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
3 */
4 /*
5  */
6 // $Id$
16 #include "StoreGate/VarHandleKey.h"
17 #include "StoreGate/exceptions.h"
18 #include "GaudiKernel/IAlgorithm.h"
19 
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 }
36 
37 
42 void AthAlgStartVisitor::visit (const IDataHandleHolder* holder)
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 }
AthAlgStartVisitor::visit
virtual void visit(const IDataHandleHolder *holder) override
Visit a component and start() any read conditions handles.
Definition: AthAlgStartVisitor.cxx:42
SG::ExcNullHandleKey
Exception — Attempt to dereference a Read/Write/UpdateHandle with a null key.
Definition: Control/StoreGate/StoreGate/exceptions.h:38
VarHandleKey.h
A property holding a SG store/key/clid from which a VarHandle is made.
AthAlgStartVisitor::m_seen
std::unordered_set< const IDataHandleHolder * > m_seen
figure out where we're called from
Definition: AthAlgStartVisitor.h:54
AthAlgStartVisitor::AthAlgStartVisitor
AthAlgStartVisitor()=default
AthAlgStartVisitor::m_ignore
bool m_ignore
process recursively (for Algs)
Definition: AthAlgStartVisitor.h:56
exceptions.h
Exceptions that can be thrown from StoreGate.
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
AthAlgStartVisitor.h