The Gaudi Framework  v33r1 (b1225454)
DataHandleHolderVisitor.cpp
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
12 #include "GaudiKernel/DataHandle.h"
13 #include "GaudiKernel/DataObjID.h"
15 #include <functional>
16 #include <tuple>
17 #include <typeinfo>
18 
19 namespace {
20  using std::make_tuple;
21 }
22 
23 DHHVisitor::DHHVisitor( DataObjIDColl& ido, DataObjIDColl& odo ) : m_ido( ido ), m_odo( odo ) {}
24 
26  if ( !v ) { return; }
27 
28  // Loop over inputs and outputs of handles, extra dependiencies and objects to
29  // collect all of them.
30  // Handles and extra dependencies are those of a specific algorith or tool, while
31  // the collection of data objects also contains those of the tree of tools and
32  // algorithms below it.
33 
34  // Loop over input handles and output handles and store those with with non-empty keys
35  // in the container of input objects passed to us and the others in a container of those
36  // we ignore for debug purposes. To avoid multiple for loops, make some tuples and loop
37  // over those.
38  for ( auto& hs : {make_tuple( v->inputHandles(), std::ref( m_ido ), std::ref( m_ign_i ) ),
39  make_tuple( v->outputHandles(), std::ref( m_odo ), std::ref( m_ign_o ) )} ) {
40  for ( const auto& h : std::get<0>( hs ) ) {
41  if ( !h->objKey().empty() ) {
42  std::get<1>( hs ).emplace( h->fullKey() );
43  } else {
44  std::get<2>( hs ).emplace( h->fullKey() );
45  }
46  }
47  }
48 
49  // The containers of handles are a different type than the on of input deps and input
50  // objects, so we need another loop here.
51  // NOTE: perhaps a view from range v3 can be used to also avoid this second loop.
52  for ( auto& hs : {make_tuple( v->extraInputDeps(), std::ref( m_ido ), std::ref( m_ign_i ) ),
53  make_tuple( v->extraOutputDeps(), std::ref( m_odo ), std::ref( m_ign_o ) ),
54  make_tuple( v->inputDataObjs(), std::ref( m_ido ), std::ref( m_ign_i ) ),
55  make_tuple( v->outputDataObjs(), std::ref( m_odo ), std::ref( m_ign_o ) )} ) {
56  for ( const auto& h : std::get<0>( hs ) ) {
57  if ( !h.key().empty() ) {
58  std::get<1>( hs ).emplace( h );
59  } else {
60  std::get<2>( hs ).emplace( h );
61  }
62  }
63  }
64 }
void visit(const IDataHandleHolder *visitee) override
virtual std::vector< Gaudi::DataHandle * > inputHandles() const =0
virtual const DataObjIDColl & extraOutputDeps() const =0
DataObjIDColl m_ign_o
virtual const DataObjIDColl & inputDataObjs() const =0
T make_tuple(T... args)
DataObjIDColl m_ign_i
DataObjIDColl & m_ido
T ref(T... args)
virtual std::vector< Gaudi::DataHandle * > outputHandles() const =0
DataObjIDColl & m_odo
DHHVisitor(DataObjIDColl &ido, DataObjIDColl &odo)
virtual const DataObjIDColl & outputDataObjs() const =0
virtual const DataObjIDColl & extraInputDeps() const =0