ATLAS Offline Software
Loading...
Searching...
No Matches
AthViews/src_dflow/DFlowAlg1.cxx
Go to the documentation of this file.
1
2
3/*
4 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
5*/
6
7// DFlowAlg1.cxx
8// Implementation file for class DFlowAlg1
9// Modifed by bwynne to add simple tests for views
10// Author: S.Binet<binet@cern.ch>
12
13// AthExStoreGateExample includes
14#include "DFlowAlg1.h"
15
16// STL includes
17
18// FrameWork includes
19#include "Gaudi/Property.h"
22
23namespace AthViews {
24
25// Athena Algorithm's Hooks
28{
29 ATH_MSG_INFO ("Initializing " << name() << "...");
30
31 CHECK( m_r_int.initialize() );
32 CHECK( m_w_int.initialize() );
33 CHECK( m_testUpdate.initialize() );
34
35 return StatusCode::SUCCESS;
36}
37
39{
40 ATH_MSG_INFO ("Finalizing " << name() << "...");
41
42 return StatusCode::SUCCESS;
43}
44
45StatusCode DFlowAlg1::execute(const EventContext& ctx) const
46{
47 ATH_MSG_DEBUG ("Executing " << name() << "...");
48
49 SG::ReadHandle< int > inputData( m_r_int, ctx );
50 if ( !inputData.isValid() )
51 {
52 ATH_MSG_ERROR( "Failed to retrieve initial view data from store " << inputData.store() );
53 return StatusCode::FAILURE;
54 }
55 int seedData = *inputData;
56
57 SG::WriteHandle< int > outputData( m_w_int, ctx );
58 ATH_MSG_INFO("myint handle...");
59 ATH_MSG_INFO("name: [" << outputData.name() << "]");
60 ATH_MSG_INFO("store [" << outputData.store() << "]");
61 ATH_MSG_INFO("clid: [" << outputData.clid() << "]");
62
63 ATH_CHECK( outputData.record( std::make_unique< int >( seedData ) ) );
64
65 //redundant check as op = would throw if outputData was not valid (e.g. because if clid/key combo was duplicated)
66 if ( outputData.isValid() )
67 {
68 ATH_MSG_INFO("ptr: " << outputData.cptr());
69 ATH_MSG_INFO("val: " << *outputData);
70
71 ATH_MSG_INFO("modify myint by value...");
72
73 ATH_MSG_INFO("ptr: " << outputData.cptr());
74 ATH_MSG_INFO("val: " << *outputData);
75 }
76
77 // Test update handles
79 ATH_CHECK( testUpdate.recordNonConst( std::make_unique< HiveDataObj >( 123 ) ) );
80 ATH_MSG_INFO( "Update handle initial: " << testUpdate->val() );
81
82 return StatusCode::SUCCESS;
83}
84
85} //> end namespace AthViews
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
#define CHECK(...)
Evaluate an expression and check for errors.
Handle class for reading from StoreGate.
Handle class for recording to StoreGate.
virtual StatusCode execute(const EventContext &ctx) const override
virtual StatusCode initialize() override
SG::WriteHandleKey< HiveDataObj > m_testUpdate
virtual StatusCode finalize() override
SG::ReadHandleKey< int > m_r_int
SG::WriteHandleKey< int > m_w_int
virtual bool isValid() override final
Can the handle be successfully dereferenced?
std::string store() const
Return the name of the store holding the object we are proxying.
CLID clid() const
Return the class ID for the referenced object.
const std::string & name() const
Return the StoreGate ID for the referenced object.
const_pointer_type cptr() const
Dereference the pointer.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
StatusCode recordNonConst(std::unique_ptr< T > data)
Record a non-const object to the store.
virtual bool isValid() override final
Can the handle be successfully dereferenced?