ATLAS Offline Software
AnaReentrantAlgorithmWrapper.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 
8 
9 //
10 // includes
11 //
12 
14 
17 #include "RootCoreUtils/Assert.h"
18 
19 
20 
21 //
22 // method implementations
23 //
24 
25 namespace EL
26 {
28  testInvariant () const
29  {
30  RCU_INVARIANT (!m_config.name().empty());
31  }
32 
33 
34 
37  : m_config (std::move (val_config))
38  {
39  RCU_NEW_INVARIANT (this);
40  }
41 
42 
43 
45  getName () const
46  {
47  RCU_READ_INVARIANT (this);
48  return m_config.name();
49  }
50 
51 
52 
54  hasName (const std::string& name) const
55  {
56  RCU_READ_INVARIANT (this);
57  return m_config.name() == name;
58  }
59 
60 
61 
62  std::unique_ptr<IAlgorithmWrapper> AnaReentrantAlgorithmWrapper ::
63  makeClone() const
64  {
65  RCU_READ_INVARIANT (this);
66  return std::make_unique<AnaReentrantAlgorithmWrapper> (m_config);
67  }
68 
69 
70 
72  initialize (const AlgorithmWorkerData& workerData)
73  {
74  using namespace msgAlgorithmConfig;
75  RCU_CHANGE_INVARIANT (this);
76  if (m_config.makeAlgorithm (m_algorithm, workerData).isFailure())
77  {
78  ANA_MSG_ERROR ("failed to create AnaReentrantAlgorithm: " << m_config.name());
79  return StatusCode::FAILURE;
80  }
81  return StatusCode::SUCCESS;
82  }
83 
84 
85 
87  execute ()
88  {
89  using namespace msgAlgorithmConfig;
90  RCU_READ_INVARIANT (this);
91  if (m_algorithm->sysExecute(Gaudi::Hive::currentContext()).isFailure())
92  {
93  ANA_MSG_ERROR ("failed to call execute() on algorithm: " << m_config.name());
94  return StatusCode::FAILURE;
95  }
96  return StatusCode::SUCCESS;
97  }
98 
99 
100 
102  finalize ()
103  {
104  using namespace msgAlgorithmConfig;
105  RCU_READ_INVARIANT (this);
106  if (m_algorithm->sysFinalize().isFailure())
107  {
108  ANA_MSG_ERROR ("failed to call finalize() on algorithm: " << m_config.name());
109  return StatusCode::FAILURE;
110  }
111  return StatusCode::SUCCESS;
112  }
113 
114 
115 
117  fileExecute ()
118  {
119  // no-op
120  return StatusCode::SUCCESS;
121  }
122 
123 
124 
127  {
128  // no-op
129  return StatusCode::SUCCESS;
130  }
131 
132 
133 
135  endInputFile ()
136  {
137  // no-op
138  return StatusCode::SUCCESS;
139  }
140 }
CurrentContext.h
EL::AnaReentrantAlgorithmWrapper::finalize
virtual StatusCode finalize() override
call finalize on the algorithm
Definition: AnaReentrantAlgorithmWrapper.cxx:102
ANA_MSG_ERROR
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:294
EL::AnaReentrantAlgorithmWrapper::m_config
AnaReentrantAlgorithmConfig m_config
the algorithm configuration
Definition: AnaReentrantAlgorithmWrapper.h:69
Assert.h
EL::AnaReentrantAlgorithmWrapper::m_algorithm
std::unique_ptr< AnaReentrantAlgorithm > m_algorithm
the actual algorithm (once instantiated)
Definition: AnaReentrantAlgorithmWrapper.h:76
EL::AnaReentrantAlgorithmWrapper::hasName
virtual bool hasName(const std::string &name) const override
whether this algorithm has the given name
Definition: AnaReentrantAlgorithmWrapper.cxx:54
EL::AnaReentrantAlgorithmWrapper::initialize
virtual StatusCode initialize(const AlgorithmWorkerData &workerData) override
call initialize on the algorithm
Definition: AnaReentrantAlgorithmWrapper.cxx:72
EL::AnaReentrantAlgorithmConfig::makeAlgorithm
::StatusCode makeAlgorithm(std::unique_ptr< AnaReentrantAlgorithm > &algorithm, const AlgorithmWorkerData &workerData) const
make an algorithm from this configuration
Definition: AnaReentrantAlgorithmConfig.cxx:50
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
AnaReentrantAlgorithmWrapper.h
EL::AnaReentrantAlgorithmWrapper::getName
virtual std::string_view getName() const override
Definition: AnaReentrantAlgorithmWrapper.cxx:45
EL
This module defines the arguments passed from the BATCH driver to the BATCH worker.
Definition: AlgorithmWorkerData.h:24
EL::AnaReentrantAlgorithmWrapper::AnaReentrantAlgorithmWrapper
AnaReentrantAlgorithmWrapper()
standard default constructor for serialization
Definition: AnaReentrantAlgorithmWrapper.h:33
EL::AnaReentrantAlgorithmWrapper::testInvariant
void testInvariant() const
test the invariant of this object
Definition: AnaReentrantAlgorithmWrapper.cxx:28
RCU_INVARIANT
#define RCU_INVARIANT(x)
Definition: Assert.h:201
EL::AnaReentrantAlgorithmWrapper::beginInputFile
virtual ::StatusCode beginInputFile() override
call beginInputFile on the algorithm
Definition: AnaReentrantAlgorithmWrapper.cxx:126
MessageCheck.h
EL::AnaReentrantAlgorithmWrapper::endInputFile
virtual ::StatusCode endInputFile() override
call endInputFile on the algorithm
Definition: AnaReentrantAlgorithmWrapper.cxx:135
EL::AnaReentrantAlgorithmWrapper::fileExecute
virtual ::StatusCode fileExecute() override
call fileExecute on the algorithm
Definition: AnaReentrantAlgorithmWrapper.cxx:117
EL::AnaReentrantAlgorithmWrapper::makeClone
virtual std::unique_ptr< IAlgorithmWrapper > makeClone() const override
make a clone of this algorithm
Definition: AnaReentrantAlgorithmWrapper.cxx:63
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
EL::AlgorithmWorkerData
all the external components an algorithm needs before initialization (in EventLoop)
Definition: AlgorithmWorkerData.h:34
EL::AnaReentrantAlgorithmWrapper::execute
virtual StatusCode execute() override
call execute on the algorithm
Definition: AnaReentrantAlgorithmWrapper.cxx:87
RCU_CHANGE_INVARIANT
#define RCU_CHANGE_INVARIANT(x)
Definition: Assert.h:231
asg::AsgComponentConfig::name
const std::string & name() const noexcept
the name of the component
Definition: AsgComponentConfig.cxx:90
EL::AnaReentrantAlgorithmConfig
an object that can create a AnaReentrantAlgorithm
Definition: AnaReentrantAlgorithmConfig.h:29
RCU_READ_INVARIANT
#define RCU_READ_INVARIANT(x)
Definition: Assert.h:229
RCU_NEW_INVARIANT
#define RCU_NEW_INVARIANT(x)
Definition: Assert.h:233