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-2020 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
26// Public methods:
28
29// Constructors
31DFlowAlg2::DFlowAlg2( const std::string& name,
32 ISvcLocator* pSvcLocator ) :
33 ::AthAlgorithm( name, pSvcLocator ),
34 m_r_int( "dflow_int" ),
35 m_ints( "dflow_ints" ),
36 m_testUpdate( "testUpdate" )
37{
38 //
39 // Property declaration
40 //
41 //declareProperty( "Property", m_nProperty );
42
43 declareProperty( "RIntFlow", m_r_int, "Data flow of int" );
44
45 declareProperty( "IntsFlow", m_ints, "Data flow of integers" );
46
47 declareProperty( "TestUpdate", m_testUpdate, "Test update handle" );
48}
49
50// Destructor
54
55// Athena Algorithm's Hooks
58{
59 ATH_MSG_INFO ("Initializing " << name() << "...");
60
61 CHECK( m_r_int.initialize() );
62 CHECK( m_ints.initialize() );
63 CHECK( m_testUpdate.initialize() );
64
65 return StatusCode::SUCCESS;
66}
67
69{
70 ATH_MSG_INFO ("Finalizing " << name() << "...");
71
72 return StatusCode::SUCCESS;
73}
74
76{
77 ATH_MSG_DEBUG ("Executing " << name() << "...");
78
79 const EventContext& ctx = getContext();
80
81 SG::ReadHandle< int > inputHandle( m_r_int, ctx );
82 ATH_MSG_INFO("================================");
83 ATH_MSG_INFO("myint r-handle...");
84 ATH_MSG_INFO("name: [" << inputHandle.name() << "]");
85 ATH_MSG_INFO("store [" << inputHandle.store() << "]");
86 ATH_MSG_INFO("clid: [" << inputHandle.clid() << "]");
87
88 ATH_MSG_INFO("ptr: " << inputHandle.cptr());
89 if ( inputHandle.isValid() )
90 {
91 ATH_MSG_INFO("val: " << *( inputHandle.cptr() ) );
92 }
93
94 SG::WriteHandle< std::vector< int > > outputHandle( m_ints, ctx );
95 ATH_MSG_INFO("ints w-handle...");
96 ATH_CHECK( outputHandle.record( std::make_unique< std::vector< int > >() ) );
97 outputHandle->push_back( 10 );
98
99 if ( inputHandle.isValid() )
100 {
101 outputHandle->push_back( *inputHandle );
102 }
103
104 ATH_MSG_INFO( "size:" << outputHandle->size() );
105 for ( int i = 0, imax = outputHandle->size(); i != imax; ++i )
106 {
107 ATH_MSG_INFO( "val[" << i << "]= " << outputHandle->at( i ) );
108 }
109
110 // Test update handles
112 ATH_MSG_INFO( "Update handle before: " << testUpdate->val() );
113 testUpdate->val( 1234 );
114 ATH_MSG_INFO( "Update handle after: " << testUpdate->val() );
115 *testUpdate = 4321;
116 ATH_MSG_INFO( "Update handle new: " << testUpdate->val() );
117
118 return StatusCode::SUCCESS;
119}
120
121} //> 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.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
SG::WriteHandleKey< std::vector< int > > m_ints
SG::ReadHandleKey< int > m_r_int
Containers.
DFlowAlg2()
Default constructor:
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.