ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
StoreGateTests
src
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
20
#include "
StoreGate/StoreGateSvc.h
"
21
22
// DataModel includes
23
#include "
AthAllocators/DataPool.h
"
24
25
// StoreGateTests includes
26
#include "
StoreGateTests/PayLoad.h
"
27
#include "
SgStressProducer.h
"
28
29
typedef
DataPool<SgTests::PayLoad>
PayLoadPool_t
;
30
32
// Public methods:
34
35
// Constructors
37
SgStressProducer::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
66
SgStressProducer::~SgStressProducer
()
67
{
68
ATH_MSG_DEBUG
(
"Calling destructor"
);
69
}
70
71
// Athena Algorithm's Hooks
73
StatusCode
SgStressProducer::initialize
()
74
{
75
// configure our MsgStream
76
msg
().setLevel( msgLevel() );
77
78
ATH_MSG_INFO
(
"Initializing "
<< name() <<
"..."
);
79
return
StatusCode::SUCCESS;
80
}
81
82
StatusCode
SgStressProducer::finalize
()
83
{
84
ATH_MSG_INFO
(
"Finalizing "
<< name() <<
"..."
);
85
return
StatusCode::SUCCESS;
86
}
87
88
StatusCode
SgStressProducer::execute
(
const
EventContext&
/*ctx*/
)
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
104
StatusCode
SgStressProducer::createData
()
105
{
106
bool
allGood =
true
;
107
PayLoadPool_t
pool
;
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;
117
SgTests::PayLoad
* data = 0;
118
SgTests::PayLoadDv
* dv =
new
SgTests::PayLoadDv
;
119
120
if
(
m_useDataPool
) {
121
dv->clear(
SG::VIEW_ELEMENTS
);
122
data =
pool
.nextElementPtr();
123
}
else
{
124
dv->clear(
SG::OWN_ELEMENTS
);
125
data =
new
SgTests::PayLoad
;
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
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
DataPool.h
PayLoad.h
PayLoadPool_t
DataPool< SgTests::PayLoad > PayLoadPool_t
Definition
SgStressProducer.cxx:29
SgStressProducer.h
StoreGateSvc.h
AthAlgorithm::AthAlgorithm
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
AthAlgorithm.cxx:10
AthCommonAlgorithm< Gaudi::Algorithm >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
AthCommonAlgorithm< Gaudi::Algorithm >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
Definition
AthCommonDataStore.h:85
AthCommonAlgorithm< Gaudi::Algorithm >::msg
MsgStream & msg() const
Definition
AthCommonMsg.h:24
DataPool
a typed memory pool that saves time spent allocation small object.
Definition
DataPool.h:63
SgStressProducer::m_dataName
std::string m_dataName
Name of the input data.
Definition
SgStressProducer.h:76
SgStressProducer::m_dataSize
std::size_t m_dataSize
Size of the payload objects.
Definition
SgStressProducer.h:82
SgStressProducer::execute
virtual StatusCode execute(const EventContext &ctx)
Execute method.
Definition
SgStressProducer.cxx:88
SgStressProducer::createData
StatusCode createData()
Create data.
Definition
SgStressProducer.cxx:104
SgStressProducer::m_useDataPool
bool m_useDataPool
switch to use or not an arena (memory pool) to allocate payload
Definition
SgStressProducer.h:85
SgStressProducer::finalize
virtual StatusCode finalize()
Definition
SgStressProducer.cxx:82
SgStressProducer::initialize
virtual StatusCode initialize()
Definition
SgStressProducer.cxx:73
SgStressProducer::m_nObjs
std::size_t m_nObjs
Number of payload objects.
Definition
SgStressProducer.h:79
SgStressProducer::SgStressProducer
SgStressProducer()
Default constructor:
SgStressProducer::~SgStressProducer
virtual ~SgStressProducer()
Destructor:
Definition
SgStressProducer.cxx:66
SG::OWN_ELEMENTS
@ OWN_ELEMENTS
this data object owns its elements
Definition
OwnershipPolicy.h:17
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition
OwnershipPolicy.h:18
pool
Framework include files.
Definition
libname.h:15
SgTests::PayLoadDv
Definition
PayLoad.h:34
SgTests::PayLoad
is a very simple class to exercize the basic features of the StoreGateSvc class: publishing and retri...
Definition
PayLoad.h:28
Generated on
for ATLAS Offline Software by
1.17.0