The Gaudi Framework  master (37c0b60a)
IncidentAsyncTestAlg.cpp
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2024 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 \***********************************************************************************/
11 #include "IncidentAsyncTestAlg.h"
12 
13 #include "IIncidentAsyncTestSvc.h"
14 
15 #include <GaudiKernel/DataObject.h>
18 #include <GaudiKernel/Incident.h>
19 
20 // Static Factory declaration
22 
23 //=============================================================================
26  if ( sc.isFailure() ) return sc;
27  // get service containing event data
28  m_service = service( m_serviceName, true );
29  // Copied from CPUCruncher.cpp
30  for ( auto k : m_inpKeys ) {
31  debug() << "adding input key " << k << endmsg;
32  m_inputObjHandles.emplace_back( new DataObjectHandle<DataObject>( k, Gaudi::DataHandle::Reader, this ) );
33  declare( *m_inputObjHandles.back() );
34  }
35 
36  for ( auto k : m_outKeys ) {
37  debug() << "adding output key " << k << endmsg;
38  m_outputObjHandles.emplace_back( new DataObjectHandle<DataObject>( k, Gaudi::DataHandle::Writer, this ) );
39  declare( *m_outputObjHandles.back() );
40  }
41 
42  return StatusCode::SUCCESS;
43 }
44 
45 //=============================================================================
47  uint64_t data = 0;
48  MsgStream logstream( msgSvc(), name() );
49  for ( auto& inputHandle : m_inputObjHandles ) {
50  if ( !inputHandle->isValid() ) continue;
51 
52  DataObject* obj = nullptr;
53  obj = inputHandle->get();
54  if ( !obj ) logstream << MSG::ERROR << "A read object was a null pointer." << endmsg;
55  }
56 
57  m_service->getData( &data );
58  for ( auto& outputHandle : m_outputObjHandles ) {
59  if ( !outputHandle->isValid() ) continue;
60  outputHandle->put( std::make_unique<DataObject>() );
61  }
62  info() << "Read data " << data << endmsg;
63  return StatusCode::SUCCESS;
64 }
65 
66 //=============================================================================
68  info() << "Finalizing " << endmsg;
69  return Algorithm::finalize();
70 }
IncidentAsyncTestAlg::m_inputObjHandles
std::vector< std::unique_ptr< DataObjectHandle< DataObject > > > m_inputObjHandles
Definition: IncidentAsyncTestAlg.h:39
Gaudi::Algorithm::name
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:526
Gaudi::Algorithm::initialize
StatusCode initialize() override
the default (empty) implementation of IStateful::initialize() method
Definition: Algorithm.h:178
IncidentAsyncTestAlg::finalize
StatusCode finalize() override
Definition: IncidentAsyncTestAlg.cpp:67
IncidentAsyncTestAlg::m_service
SmartIF< IIncidentAsyncTestSvc > m_service
Definition: IncidentAsyncTestAlg.h:38
DataObjectHandle< DataObject >
Gaudi::DataHandle::Writer
@ Writer
Definition: DataHandle.h:40
AvalancheSchedulerErrorTest.msgSvc
msgSvc
Definition: AvalancheSchedulerErrorTest.py:80
IIncidentSvc.h
IIncidentAsyncTestSvc.h
StatusCode
Definition: StatusCode.h:65
IncidentAsyncTestAlg
Definition: IncidentAsyncTestAlg.h:22
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202
MsgStream
Definition: MsgStream.h:33
IncidentAsyncTestAlg::m_outputObjHandles
std::vector< std::unique_ptr< DataObjectHandle< DataObject > > > m_outputObjHandles
Definition: IncidentAsyncTestAlg.h:40
IncidentAsyncTestAlg::execute
StatusCode execute() override
Definition: IncidentAsyncTestAlg.cpp:46
StatusCode::isFailure
bool isFailure() const
Definition: StatusCode.h:129
Gaudi::Algorithm::finalize
StatusCode finalize() override
the default (empty) implementation of IStateful::finalize() method
Definition: Algorithm.h:184
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
DataObject.h
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition: PluginServiceV1.h:46
MSG::ERROR
@ ERROR
Definition: IMessageSvc.h:25
DataObject
Definition: DataObject.h:36
Gaudi::DataHandle::Reader
@ Reader
Definition: DataHandle.h:40
Incident.h
DataObjectHandle.h
IncidentAsyncTestAlg.h