ATLAS Offline Software
Loading...
Searching...
No Matches
ObjGetterToolImpl.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
16#include "GaudiKernel/System.h"
17
18
19namespace D3PD {
20
21
29 const std::string& name,
30 const IInterface* parent)
31 : base_class (type, name, parent)
32{
33}
34
35
45const void* ObjGetterToolImpl::getTypeinfo (const std::type_info& ti,
46 bool allowMissing /*= false*/)
47{
48 // Configure the converter if needed.
49 if (!this->m_converter.isValid() ||
50 this->m_converter.dstTypeinfo() != ti)
51 {
52 if (this->configureTypeinfo(ti).isFailure())
53 return 0;
54 }
55
56 // Get the object.
57 const void* p = this->getUntyped (allowMissing);
58
59 // Convert to the desired type.
60 if (p) {
61 p = this->m_converter.convertUntyped (p);
62 if (!p) {
63 REPORT_MESSAGE (MSG::WARNING)
64 << "Pointer conversion from " << m_converter.srcName() << " to "
65 << m_converter.dstName() << "failed.";
66 }
67 }
68 return p;
69}
70
71
83 const std::type_info& ti)
84{
85 if (!p)
86 return;
87
88 // Configure the converter if needed.
89 if (!this->m_backConverter.isValid() ||
90 this->m_backConverter.srcTypeinfo() != ti)
91 {
92 if (this->m_backConverter.init (ti, this->typeinfo()).isFailure()) {
93 REPORT_MESSAGE (MSG::WARNING)
94 << "Can't configure pointer conversion from "
95 << System::typeinfoName (ti) << " to "
96 << System::typeinfoName (this->typeinfo());
97 return;
98 }
99 }
100
101 // Convert to the desired type.
102 p = this->m_backConverter.convertUntyped (p);
103
104 // Release.
105 if (p)
106 this->releaseObjectUntyped (p);
107 else {
108 REPORT_MESSAGE (MSG::WARNING)
109 << "Pointer conversion from " << m_backConverter.srcName() << " to "
110 << m_backConverter.dstName() << "failed.";
111 }
112}
113
114
123StatusCode
124ObjGetterToolImpl::configureTypeinfo (const std::type_info& ti)
125{
126 return this->m_converter.init(this->typeinfo(), ti);
127}
128
129
130} // namespace D3PD
Helpers for checking error return status codes and reporting errors.
#define REPORT_MESSAGE(LVL)
Report a message.
Non-template parts of ObjGetterTool.
virtual const void * getTypeinfo(const std::type_info &ti, bool allowMissing=false)
Return the target object cast to a different pointer type.
TypeConverter m_converter
Helper to convert pointers.
ObjGetterToolImpl(const std::string &type, const std::string &name, const IInterface *parent)
Standard Gaudi tool constructor.
TypeConverter m_backConverter
Helper to convert pointers back, for releaseObject.
void releaseObjectTypeinfo(const void *p, const std::type_info &ti)
Release an object retrieved from the getter.
virtual StatusCode configureTypeinfo(const std::type_info &ti)
Test type compatibility.
Block filler tool for noisy FEB information.