The Gaudi Framework  master (01b473db)
IncidentAsyncTestAlg.cpp
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2025 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 const* obj = inputHandle->get();
53  if ( !obj ) logstream << MSG::ERROR << "A read object was a null pointer." << endmsg;
54  }
55 
56  m_service->getData( &data );
57  for ( auto& outputHandle : m_outputObjHandles ) {
58  if ( !outputHandle->isValid() ) continue;
59  outputHandle->put( std::make_unique<DataObject>() );
60  }
61  info() << "Read data " << data << endmsg;
62  return StatusCode::SUCCESS;
63 }
64 
65 //=============================================================================
67  info() << "Finalizing " << endmsg;
68  return Algorithm::finalize();
69 }
IncidentAsyncTestAlg::m_inputObjHandles
std::vector< std::unique_ptr< DataObjectHandle< DataObject > > > m_inputObjHandles
Definition: IncidentAsyncTestAlg.h:38
Gaudi::Algorithm::name
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:524
Gaudi::Algorithm::initialize
StatusCode initialize() override
the default (empty) implementation of IStateful::initialize() method
Definition: Algorithm.h:175
IncidentAsyncTestAlg::finalize
StatusCode finalize() override
Definition: IncidentAsyncTestAlg.cpp:66
IncidentAsyncTestAlg::m_service
SmartIF< IIncidentAsyncTestSvc > m_service
Definition: IncidentAsyncTestAlg.h:37
DataObjectHandle< DataObject >
Gaudi::DataHandle::Writer
@ Writer
Definition: DataHandle.h:39
AvalancheSchedulerErrorTest.msgSvc
msgSvc
Definition: AvalancheSchedulerErrorTest.py:80
IIncidentSvc.h
IIncidentAsyncTestSvc.h
StatusCode
Definition: StatusCode.h:64
IncidentAsyncTestAlg
Definition: IncidentAsyncTestAlg.h:21
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:198
MsgStream
Definition: MsgStream.h:29
IncidentAsyncTestAlg::m_outputObjHandles
std::vector< std::unique_ptr< DataObjectHandle< DataObject > > > m_outputObjHandles
Definition: IncidentAsyncTestAlg.h:39
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:181
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:99
DataObject.h
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition: PluginServiceV1.h:45
MSG::ERROR
@ ERROR
Definition: IMessageSvc.h:22
DataObject
Definition: DataObject.h:37
Gaudi::DataHandle::Reader
@ Reader
Definition: DataHandle.h:39
Incident.h
DataObjectHandle.h
IncidentAsyncTestAlg.h