The Gaudi Framework
v41r0 (bdbe7744)
Toggle main menu visibility
Loading...
Searching...
No Matches
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
>
16
#include <
GaudiKernel/DataObjectHandle.h
>
17
#include <
GaudiKernel/IIncidentSvc.h
>
18
#include <
GaudiKernel/Incident.h
>
19
20
// Static Factory declaration
21
DECLARE_COMPONENT
(
IncidentAsyncTestAlg
)
22
23
//=============================================================================
24
StatusCode
IncidentAsyncTestAlg
::
initialize
() {
25
StatusCode
sc =
Algorithm::initialize
();
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
//=============================================================================
46
StatusCode
IncidentAsyncTestAlg::execute
() {
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
//=============================================================================
66
StatusCode
IncidentAsyncTestAlg::finalize
() {
67
info
() <<
"Finalizing "
<<
endmsg
;
68
return
Algorithm::finalize
();
69
}
DataObject.h
DataObjectHandle.h
IIncidentAsyncTestSvc.h
IIncidentSvc.h
Incident.h
IncidentAsyncTestAlg.h
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition
MsgStream.h:198
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition
PluginServiceV1.h:45
CommonMessagingBase::msgSvc
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition
CommonMessaging.h:79
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition
CommonMessaging.h:118
CommonMessagingBase::info
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Definition
CommonMessaging.h:115
DataHandleHolderBase< PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > > >::declare
void declare(Gaudi::DataHandle &handle) override
Definition
DataHandleHolderBase.h:47
DataObjectHandle
DataObjectHandle.h GaudiKernel/DataObjectHandle.h.
Definition
DataObjectHandle.h:110
DataObject
A DataObject is the base class of any identifiable object on any data store.
Definition
DataObject.h:37
Gaudi::Algorithm::initialize
StatusCode initialize() override
the default (empty) implementation of IStateful::initialize() method
Definition
Algorithm.h:175
Gaudi::Algorithm::finalize
StatusCode finalize() override
the default (empty) implementation of IStateful::finalize() method
Definition
Algorithm.h:181
Gaudi::Algorithm::name
const std::string & name() const override
The identifying name of the algorithm object.
Definition
Algorithm.cpp:518
Gaudi::Algorithm::service
SmartIF< IService > service(std::string_view name, const bool createIf=true, const bool quiet=false) const
Return a pointer to the service identified by name (or "type/name").
Definition
Algorithm.cpp:621
Gaudi::DataHandle::Reader
@ Reader
Definition
DataHandle.h:45
Gaudi::DataHandle::Writer
@ Writer
Definition
DataHandle.h:45
IncidentAsyncTestAlg
Definition
IncidentAsyncTestAlg.h:21
IncidentAsyncTestAlg::execute
StatusCode execute() override
Definition
IncidentAsyncTestAlg.cpp:46
IncidentAsyncTestAlg::m_outKeys
Gaudi::Property< std::vector< std::string > > m_outKeys
Definition
IncidentAsyncTestAlg.h:36
IncidentAsyncTestAlg::initialize
StatusCode initialize() override
Definition
IncidentAsyncTestAlg.cpp:24
IncidentAsyncTestAlg::m_service
SmartIF< IIncidentAsyncTestSvc > m_service
Definition
IncidentAsyncTestAlg.h:37
IncidentAsyncTestAlg::m_serviceName
Gaudi::Property< std::string > m_serviceName
Definition
IncidentAsyncTestAlg.h:34
IncidentAsyncTestAlg::m_inpKeys
Gaudi::Property< std::vector< std::string > > m_inpKeys
Definition
IncidentAsyncTestAlg.h:35
IncidentAsyncTestAlg::finalize
StatusCode finalize() override
Definition
IncidentAsyncTestAlg.cpp:66
IncidentAsyncTestAlg::m_inputObjHandles
std::vector< std::unique_ptr< DataObjectHandle< DataObject > > > m_inputObjHandles
Definition
IncidentAsyncTestAlg.h:38
IncidentAsyncTestAlg::m_outputObjHandles
std::vector< std::unique_ptr< DataObjectHandle< DataObject > > > m_outputObjHandles
Definition
IncidentAsyncTestAlg.h:39
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition
MsgStream.h:29
StatusCode
This class is used for returning status codes from appropriate routines.
Definition
StatusCode.h:64
StatusCode::isFailure
bool isFailure() const
Definition
StatusCode.h:118
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition
StatusCode.h:99
MSG::ERROR
@ ERROR
Definition
IMessageSvc.h:22
GaudiTestSuite
src
IncidentSvc
IncidentAsyncTestAlg.cpp
Generated on
for The Gaudi Framework by
1.17.0