ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
AthenaExamples
AthExStoreGateExample
src
ExampleAlg.cxx
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration.
3
*/
10
11
12
#include "
ExampleAlg.h
"
13
14
15
StatusCode
ExampleAlg::initialize
()
16
{
17
// This will check that the properties were initialized properly
18
// by job condifiguration.
19
ATH_CHECK
(
m_readKey
.initialize() );
20
ATH_CHECK
(
m_writeKey
.initialize() );
21
return
StatusCode::SUCCESS;
22
}
23
24
25
StatusCode
ExampleAlg::execute
(
const
EventContext& ctx)
const
26
{
27
// Construct handles from the keys.
28
// Since this is a reentrant algorithm, we have an explicit event context,
29
// which we pass to the handles.
30
SG::ReadHandle<MyDataObj>
h_read (
m_readKey
, ctx);
31
SG::WriteHandle<MyDataObj>
h_write (
m_writeKey
, ctx);
32
33
// Now we can dereference the read handle to access input data.
34
int
newval = h_read->val()+1;
35
36
// We make a new object, held by a unique_ptr, and record it
37
// in the store using the record method of the handle.
38
ATH_CHECK
( h_write.
record
(std::make_unique<MyDataObj> (newval)) );
39
40
return
StatusCode::SUCCESS;
41
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ExampleAlg.h
Example of using handles for data access.
ExampleAlg::m_writeKey
SG::WriteHandleKey< MyDataObj > m_writeKey
Definition
ExampleAlg.h:36
ExampleAlg::initialize
virtual StatusCode initialize() override
Definition
ExampleAlg.cxx:15
ExampleAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition
ExampleAlg.cxx:25
ExampleAlg::m_readKey
SG::ReadHandleKey< MyDataObj > m_readKey
Definition
ExampleAlg.h:35
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
Generated on
for ATLAS Offline Software by
1.17.0