ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
D3PDMaker
D3PDMakerUtils
src
CollectionGetterToolImpl.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// $Id$
12
13
14
#include "
D3PDMakerUtils/CollectionGetterToolImpl.h
"
15
#include "
D3PDMakerInterfaces/ICollectionGetterRegistryTool.h
"
16
#include "
AthenaKernel/errorcheck.h
"
17
18
19
namespace
D3PD
{
20
21
28
CollectionGetterToolImpl::CollectionGetterToolImpl
(
const
std::string&
type
,
29
const
std::string& name,
30
const
IInterface* parent)
31
: base_class (
type
, name, parent)
32
{
33
declareProperty (
"Label"
,
m_label
,
34
"Label to assign to this getter, to be able to reference "
35
"it from an association tool. Leave blank if no label "
36
"is needed."
);
37
declareProperty (
"CollectionGetterRegistry"
,
m_registry
,
38
"Collection getter registry tool"
);
39
}
40
41
45
StatusCode
CollectionGetterToolImpl::initialize
()
46
{
47
// If a label was provided, add ourselves to the registry.
48
if
(!
m_label
.empty()) {
49
CHECK
(
m_registry
.retrieve() );
50
CHECK
(
m_registry
->add (
m_label
,
this
) );
51
}
52
else
{
53
m_registry
.disable();
54
}
55
return
ObjGetterToolImpl::initialize();
56
}
57
58
67
const
void
*
68
CollectionGetterToolImpl::nextTypeinfo
(
const
std::type_info& ti)
69
{
70
// Configure the converter.
71
if
(!this->
m_converter
.isValid() ||
72
this->m_converter.dstTypeinfo() != ti)
73
{
74
if
(this->
configureElementTypeinfo
(ti).isFailure())
75
return
0;
76
}
77
78
// Get the next object. If the conversion fails, loop until we get
79
// a good one.
80
while
(
true
) {
81
const
void
* p = this->
nextUntyped
();
82
if
(!p)
return
0;
83
const
void
* pconv = this->
m_converter
.convertUntyped (p);
84
if
(pconv)
return
pconv;
85
this->
releaseElementUntyped
(p);
86
REPORT_MESSAGE
(MSG::WARNING)
87
<<
"Pointer conversion from "
<<
m_converter
.srcName() <<
" to "
88
<<
m_converter
.dstName() <<
"failed."
;
89
}
90
}
91
92
103
void
104
CollectionGetterToolImpl::releaseElementTypeinfo
(
const
void
* p,
105
const
std::type_info& ti)
106
{
107
if
(!p)
108
return
;
109
110
// Configure the converter if needed.
111
if
(!this->
m_backConverter
.isValid() ||
112
this->m_backConverter.srcTypeinfo() != ti)
113
{
114
if
(this->
m_backConverter
.init (ti, this->typeinfo()).isFailure()) {
115
REPORT_MESSAGE
(MSG::WARNING)
116
<<
"Can't configure pointer conversion from "
117
<< System::typeinfoName (ti) <<
" to "
118
<< System::typeinfoName (this->typeinfo());
119
return
;
120
}
121
}
122
123
// Convert to the desired type.
124
p = this->
m_backConverter
.convertUntyped (p);
125
126
// Release.
127
if
(p)
128
this->
releaseElementUntyped
(p);
129
else
{
130
REPORT_MESSAGE
(MSG::WARNING)
131
<<
"Pointer conversion from "
<<
m_backConverter
.srcName() <<
" to "
132
<<
m_backConverter
.dstName() <<
"failed."
;
133
}
134
}
135
136
145
StatusCode
146
CollectionGetterToolImpl::configureElementTypeinfo
147
(
const
std::type_info& ti)
148
{
149
return
this->
m_converter
.init(this->elementTypeinfo(), ti);
150
}
151
152
153
}
// namespace D3PD
CollectionGetterToolImpl.h
Non-template parts of CollectionGetterTool.
errorcheck.h
Helpers for checking error return status codes and reporting errors.
REPORT_MESSAGE
#define REPORT_MESSAGE(LVL)
Report a message.
Definition
Control/AthenaKernel/AthenaKernel/errorcheck.h:365
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition
Control/AthenaKernel/AthenaKernel/errorcheck.h:422
ICollectionGetterRegistryTool.h
Abstract interface to keep a registry of collection getter tools.
D3PD::CollectionGetterToolImpl::nextTypeinfo
const void * nextTypeinfo(const std::type_info &ti)
Return the next object cast to a different pointer type.
Definition
CollectionGetterToolImpl.cxx:68
D3PD::CollectionGetterToolImpl::m_converter
TypeConverter m_converter
Helper to convert pointers.
Definition
CollectionGetterToolImpl.h:103
D3PD::CollectionGetterToolImpl::initialize
StatusCode initialize()
Standard Gaudi initialize method.
Definition
CollectionGetterToolImpl.cxx:45
D3PD::CollectionGetterToolImpl::m_label
std::string m_label
Property: label to assign to this getter (or null).
Definition
CollectionGetterToolImpl.h:97
D3PD::CollectionGetterToolImpl::releaseElementTypeinfo
void releaseElementTypeinfo(const void *p, const std::type_info &ti)
Release an element retrieved from the getter.
Definition
CollectionGetterToolImpl.cxx:104
D3PD::CollectionGetterToolImpl::configureElementTypeinfo
StatusCode configureElementTypeinfo(const std::type_info &ti)
Test type compatibility.
Definition
CollectionGetterToolImpl.cxx:147
D3PD::CollectionGetterToolImpl::m_registry
ToolHandle< ICollectionGetterRegistryTool > m_registry
The collection getter registry tool.
Definition
CollectionGetterToolImpl.h:100
D3PD::CollectionGetterToolImpl::m_backConverter
TypeConverter m_backConverter
Helper to convert pointers back, for releaseElement.
Definition
CollectionGetterToolImpl.h:106
D3PD::CollectionGetterToolImpl::CollectionGetterToolImpl
CollectionGetterToolImpl(const std::string &type, const std::string &name, const IInterface *parent)
Standard Gaudi tool constructor.
Definition
CollectionGetterToolImpl.cxx:28
D3PD::CollectionGetterTool< CaloCalibrationHitContainer >::nextUntyped
virtual const void * nextUntyped()
D3PD
Block filler tool for noisy FEB information.
Definition
CaloCellDetailsFillerTool.cxx:29
D3PD::m_registry
ToolHandle< ICollectionGetterRegistryTool > m_registry
Property: The ICollectionGetterRegistryTool instance.
Definition
IndexAssociationFillerTool.h:145
D3PD::releaseElementUntyped
m_associator releaseElementUntyped(m_next)
type
Generated on
for ATLAS Offline Software by
1.17.0