ATLAS Offline Software
AsgServiceWrapper.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 
15 #include <EventLoop/MessageCheck.h>
16 #include <RootCoreUtils/Assert.h>
17 
18 //
19 // method implementations
20 //
21 
22 namespace EL
23 {
25  testInvariant () const
26  {
27  RCU_INVARIANT (!m_config.name().empty());
28  }
29 
30 
31 
34  : m_config (std::move (val_config))
35  {
36  RCU_NEW_INVARIANT (this);
37  }
38 
39 
40 
41  std::string_view AsgServiceWrapper ::
42  getName () const
43  {
44  RCU_READ_INVARIANT (this);
45  return m_config.name();
46  }
47 
48 
49 
51  hasName (const std::string& name) const
52  {
53  RCU_READ_INVARIANT (this);
54  return m_config.name() == name;
55  }
56 
57 
58 
59  std::unique_ptr<IAlgorithmWrapper> AsgServiceWrapper ::
60  makeClone() const
61  {
62  RCU_READ_INVARIANT (this);
63  return std::make_unique<AsgServiceWrapper> (m_config);
64  }
65 
66 
67 
69  initialize (const AlgorithmWorkerData& /*workerData*/)
70  {
71  using namespace msgEventLoop;
72  RCU_CHANGE_INVARIANT (this);
73  if (m_config.makeService (m_service).isFailure())
74  {
75  ANA_MSG_ERROR ("failed to create AsgService: " << m_config.name());
76  return StatusCode::FAILURE;
77  }
78  return StatusCode::SUCCESS;
79  }
80 
81 
82 
84  execute ()
85  {
86  RCU_READ_INVARIANT (this);
87  return StatusCode::SUCCESS;
88  }
89 
90 
91 
93  finalize ()
94  {
95  using namespace msgEventLoop;
96  RCU_READ_INVARIANT (this);
97  if (m_service->finalize().isFailure())
98  {
99  ANA_MSG_ERROR ("failed to call finalize() on service: " << m_config.name());
100  return StatusCode::FAILURE;
101  }
102  return StatusCode::SUCCESS;
103  }
104 
105 
106 
108  fileExecute ()
109  {
110  RCU_READ_INVARIANT (this);
111  return StatusCode::SUCCESS;
112  }
113 
114 
115 
118  {
119  RCU_READ_INVARIANT (this);
120  return StatusCode::SUCCESS;
121  }
122 
123 
124 
126  endInputFile ()
127  {
128  // no-op
129  return StatusCode::SUCCESS;
130  }
131 }
EL::AsgServiceWrapper::testInvariant
void testInvariant() const
test the invariant of this object
Definition: AsgServiceWrapper.cxx:25
EL::AsgServiceWrapper::getName
virtual std::string_view getName() const override
Definition: AsgServiceWrapper.cxx:42
EL::AsgServiceWrapper::hasName
virtual bool hasName(const std::string &name) const override
whether this algorithm has the given name
Definition: AsgServiceWrapper.cxx:51
EL::AsgServiceWrapper::m_config
asg::AsgServiceConfig m_config
the algorithm configuration
Definition: AsgServiceWrapper.h:69
ANA_MSG_ERROR
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:294
EL::AsgServiceWrapper::fileExecute
virtual ::StatusCode fileExecute() override
call fileExecute on the algorithm
Definition: AsgServiceWrapper.cxx:108
EL::AsgServiceWrapper::AsgServiceWrapper
AsgServiceWrapper()
standard default constructor for serialization
Definition: AsgServiceWrapper.h:33
Assert.h
MessageCheck.h
EL::AsgServiceWrapper::initialize
virtual StatusCode initialize(const AlgorithmWorkerData &workerData) override
call initialize on the algorithm
Definition: AsgServiceWrapper.cxx:69
EL::AsgServiceWrapper::endInputFile
virtual ::StatusCode endInputFile() override
call endInputFile on the algorithm
Definition: AsgServiceWrapper.cxx:126
EL::AsgServiceWrapper::execute
virtual StatusCode execute() override
call execute on the algorithm
Definition: AsgServiceWrapper.cxx:84
EL::AsgServiceWrapper::finalize
virtual StatusCode finalize() override
call finalize on the algorithm
Definition: AsgServiceWrapper.cxx:93
EL::AsgServiceWrapper::beginInputFile
virtual ::StatusCode beginInputFile() override
call beginInputFile on the algorithm
Definition: AsgServiceWrapper.cxx:117
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
EL::AsgServiceWrapper::m_service
std::shared_ptr< asg::AsgService > m_service
the actual service (once instantiated)
Definition: AsgServiceWrapper.h:76
EL
This module defines the arguments passed from the BATCH driver to the BATCH worker.
Definition: AlgorithmWorkerData.h:24
RCU_INVARIANT
#define RCU_INVARIANT(x)
Definition: Assert.h:201
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
asg::AsgServiceConfig
an object that can create a AsgService
Definition: AsgServiceConfig.h:25
EL::AsgServiceWrapper::makeClone
virtual std::unique_ptr< IAlgorithmWrapper > makeClone() const override
make a clone of this algorithm
Definition: AsgServiceWrapper.cxx:60
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
asg::AsgServiceConfig::makeService
::StatusCode makeService(std::shared_ptr< T > &service) const
make a service with the given configuration
RCU_READ_INVARIANT
#define RCU_READ_INVARIANT(x)
Definition: Assert.h:229
AsgServiceWrapper.h
RCU_NEW_INVARIANT
#define RCU_NEW_INVARIANT(x)
Definition: Assert.h:233