ATLAS Offline Software
Loading...
Searching...
No Matches
SgStressProducer.cxx
Go to the documentation of this file.
1
2
3/*
4 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
5*/
6
7// SgStressProducer.cxx
8// Implementation file for class SgStressProducer
9// Author: S.Binet<binet@cern.ch>
11
12
13// STL includes
14#include <sstream>
15
16// FrameWork includes
17#include "Gaudi/Property.h"
18
19// StoreGate
21
22// DataModel includes
24
25// StoreGateTests includes
27#include "SgStressProducer.h"
28
30
32// Public methods:
34
35// Constructors
37SgStressProducer::SgStressProducer( const std::string& name,
38 ISvcLocator* pSvcLocator ) :
39 AthAlgorithm( name, pSvcLocator )
40{
41 //
42 // Property declaration
43 //
44 //declareProperty( "Property", m_nProperty );
45
46 declareProperty( "DataName",
47 m_dataName = "MyData",
48 "Output location of 'Data' objects" );
49
50 declareProperty( "NbrOfObjects",
51 m_nObjs = 1000,
52 "Number of 'Data' objects to be stored each event" );
53
54 declareProperty( "ObjectsSize",
55 m_dataSize = 100,
56 "Size of each 'Data' objects to be stored each event" );
57
58 declareProperty( "UseDataPool",
59 m_useDataPool = false,
60 "Switch to use or not an arena (memory pool) to allocate "
61 "payload" );
62}
63
64// Destructor
67{
68 ATH_MSG_DEBUG ( "Calling destructor" );
69}
70
71// Athena Algorithm's Hooks
74{
75 // configure our MsgStream
76 msg().setLevel( msgLevel() );
77
78 ATH_MSG_INFO ( "Initializing " << name() << "..." );
79 return StatusCode::SUCCESS;
80}
81
83{
84 ATH_MSG_INFO ( "Finalizing " << name() << "..." );
85 return StatusCode::SUCCESS;
86}
87
89{
90 ATH_MSG_DEBUG ( "Executing " << name() << "..." );
91
92 if ( !createData().isSuccess() ) {
93 ATH_MSG_ERROR ( "Could not create PayLoad data !!" );
94 return StatusCode::FAILURE;
95 }
96
97 return StatusCode::SUCCESS;
98}
99
101// Non-const methods:
103
105{
106 bool allGood = true;
108 if ( m_useDataPool ) {
110 pool.erase();
111 pool.reserve (m_nObjs);
112 }
113
114 for ( std::size_t iObj = 0; iObj != m_nObjs; ++iObj ) {
115 std::ostringstream outName;
116 outName << m_dataName << "_payload_" << iObj;
119
120 if ( m_useDataPool ) {
121 dv->clear( SG::VIEW_ELEMENTS );
122 data = pool.nextElementPtr();
123 } else {
124 dv->clear( SG::OWN_ELEMENTS );
126 }
127 dv->push_back( data );
128
129 if ( !evtStore()->record(dv, outName.str()).isSuccess() ) {
130 ATH_MSG_ERROR ( "Could not store data at [" << outName.str() << "] !!" );
131 delete dv; dv = 0;
132 allGood = false;
133 continue;
134 }
135 if ( !evtStore()->setConst(dv).isSuccess() ) {
136 ATH_MSG_WARNING( "Could not setConst data at [" << outName.str() << "] !!");
137 }
138
139 // filling data
140 data->m_data.reserve( m_dataSize );
141 for ( std::size_t i = 0; i != static_cast<std::size_t>(m_dataSize); ++i ) {
142 data->m_data.push_back( i );
143 }
144 }
145
146 return allGood ? StatusCode::SUCCESS : StatusCode::FAILURE;
147}
148
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
DataPool< SgTests::PayLoad > PayLoadPool_t
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
MsgStream & msg() const
a typed memory pool that saves time spent allocation small object.
Definition DataPool.h:63
std::string m_dataName
Name of the input data.
virtual StatusCode execute()
std::size_t m_dataSize
Size of the payload objects.
StatusCode createData()
Create data.
bool m_useDataPool
switch to use or not an arena (memory pool) to allocate payload
virtual StatusCode finalize()
virtual StatusCode initialize()
std::size_t m_nObjs
Number of payload objects.
SgStressProducer()
Default constructor:
virtual ~SgStressProducer()
Destructor:
@ OWN_ELEMENTS
this data object owns its elements
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
pool namespace
Definition libname.h:15
is a very simple class to exercize the basic features of the StoreGateSvc class: publishing and retri...
Definition PayLoad.h:28