ATLAS Offline Software
Loading...
Searching...
No Matches
AthViews/src_dflow/DFlowAlg2.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// DFlowAlg2.cxx
8// Implementation file for class DFlowAlg2
9// Author: S.Binet<binet@cern.ch>
11
12// AthExStoreGateExample includes
13#include "DFlowAlg2.h"
14
15// STL includes
16
17// FrameWork includes
18#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_ints.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 DFlowAlg2::execute(const EventContext& ctx) const
46{
47 ATH_MSG_DEBUG ("Executing " << name() << "...");
48
49 SG::ReadHandle< int > inputHandle( m_r_int, ctx );
50 ATH_MSG_INFO("================================");
51 ATH_MSG_INFO("myint r-handle...");
52 ATH_MSG_INFO("name: [" << inputHandle.name() << "]");
53 ATH_MSG_INFO("store [" << inputHandle.store() << "]");
54 ATH_MSG_INFO("clid: [" << inputHandle.clid() << "]");
55
56 ATH_MSG_INFO("ptr: " << inputHandle.cptr());
57 if ( inputHandle.isValid() )
58 {
59 ATH_MSG_INFO("val: " << *( inputHandle.cptr() ) );
60 }
61
62 SG::WriteHandle< std::vector< int > > outputHandle( m_ints, ctx );
63 ATH_MSG_INFO("ints w-handle...");
64 ATH_CHECK( outputHandle.record( std::make_unique< std::vector< int > >() ) );
65 outputHandle->push_back( 10 );
66
67 if ( inputHandle.isValid() )
68 {
69 outputHandle->push_back( *inputHandle );
70 }
71
72 ATH_MSG_INFO( "size:" << outputHandle->size() );
73 for ( int i = 0, imax = outputHandle->size(); i != imax; ++i )
74 {
75 ATH_MSG_INFO( "val[" << i << "]= " << outputHandle->at( i ) );
76 }
77
78 // Test update handles
80 ATH_MSG_INFO( "Update handle before: " << testUpdate->val() );
81 testUpdate->val( 1234 );
82 ATH_MSG_INFO( "Update handle after: " << testUpdate->val() );
83 *testUpdate = 4321;
84 ATH_MSG_INFO( "Update handle new: " << testUpdate->val() );
85
86 return StatusCode::SUCCESS;
87}
88
89} //> end namespace AthViews
#define ATH_CHECK
Evaluate an expression and check for errors.
#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.
int imax(int i, int j)
Handle class for modifying an existing object in StoreGate.
virtual StatusCode initialize() override
SG::WriteHandleKey< std::vector< int > > m_ints
SG::ReadHandleKey< int > m_r_int
virtual StatusCode execute(const EventContext &ctx) const override
virtual StatusCode finalize() override
SG::UpdateHandleKey< HiveDataObj > m_testUpdate
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
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.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.