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-2020 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
26// Public methods:
28
29// Constructors
31DFlowAlg1::DFlowAlg1( const std::string& name,
32 ISvcLocator* pSvcLocator ) :
33 ::AthAlgorithm( name, pSvcLocator ),
34 m_r_int( "view_start" ),
35 m_w_int( "dflow_int" ),
36 m_testUpdate( "testUpdate" )
37{
38 //
39 // Property declaration
40 //
41 //declareProperty( "Property", m_nProperty );
42
43 declareProperty( "IntFlow", m_w_int, "Data flow of int" );
44
45 declareProperty( "ViewStart", m_r_int, "Seed data of view" );
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_w_int.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 > inputData( m_r_int, ctx );
82 if ( !inputData.isValid() )
83 {
84 ATH_MSG_ERROR( "Failed to retrieve initial view data from store " << inputData.store() );
85 return StatusCode::FAILURE;
86 }
87 int seedData = *inputData;
88
89 SG::WriteHandle< int > outputData( m_w_int, ctx );
90 ATH_MSG_INFO("myint handle...");
91 ATH_MSG_INFO("name: [" << outputData.name() << "]");
92 ATH_MSG_INFO("store [" << outputData.store() << "]");
93 ATH_MSG_INFO("clid: [" << outputData.clid() << "]");
94
95 ATH_CHECK( outputData.record( std::make_unique< int >( seedData ) ) );
96
97 //redundant check as op = would throw if outputData was not valid (e.g. because if clid/key combo was duplicated)
98 if ( outputData.isValid() )
99 {
100 ATH_MSG_INFO("ptr: " << outputData.cptr());
101 ATH_MSG_INFO("val: " << *outputData);
102
103 ATH_MSG_INFO("modify myint by value...");
104
105 ATH_MSG_INFO("ptr: " << outputData.cptr());
106 ATH_MSG_INFO("val: " << *outputData);
107 }
108
109 // Test update handles
111 ATH_CHECK( testUpdate.recordNonConst( std::make_unique< HiveDataObj >( 123 ) ) );
112 ATH_MSG_INFO( "Update handle initial: " << testUpdate->val() );
113
114 return StatusCode::SUCCESS;
115}
116
117} //> 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.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
DFlowAlg1()
Default constructor:
SG::WriteHandleKey< HiveDataObj > m_testUpdate
SG::ReadHandleKey< int > m_r_int
Containers.
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?