ATLAS Offline Software
Loading...
Searching...
No Matches
D3PD::ObjGetterToolImpl Class Reference

Non-template parts of ObjGetterTool. More...

#include <ObjGetterToolImpl.h>

Inheritance diagram for D3PD::ObjGetterToolImpl:
Collaboration diagram for D3PD::ObjGetterToolImpl:

Public Member Functions

 ObjGetterToolImpl (const std::string &type, const std::string &name, const IInterface *parent)
 Standard Gaudi tool constructor.
virtual const void * getTypeinfo (const std::type_info &ti, bool allowMissing=false)
 Return the target object cast to a different pointer type.
virtual StatusCode configureTypeinfo (const std::type_info &ti)
 Test type compatibility.
void releaseObjectTypeinfo (const void *p, const std::type_info &ti)
 Release an object retrieved from the getter.

Private Attributes

TypeConverter m_converter
 Helper to convert pointers.
TypeConverter m_backConverter
 Helper to convert pointers back, for releaseObject.

Detailed Description

Non-template parts of ObjGetterTool.

The class ObjGetterTool provides a type-safe wrapper for the IObjGetterTool interface; it is templated on the type of object on which it retrieves. This class serves as a common base class for the ObjGetterToolTool instantiations, and factors out all the code that doesn't depend on the template argument. It may also be useful for other getter classes that don't use ObjGetterTool.

Definition at line 39 of file ObjGetterToolImpl.h.

Constructor & Destructor Documentation

◆ ObjGetterToolImpl()

D3PD::ObjGetterToolImpl::ObjGetterToolImpl ( const std::string & type,
const std::string & name,
const IInterface * parent )

Standard Gaudi tool constructor.

Parameters
typeThe name of the tool type.
nameThe tool name.
parentThe tool's Gaudi parent.

Definition at line 28 of file ObjGetterToolImpl.cxx.

31 : base_class (type, name, parent)
32{
33}

Member Function Documentation

◆ configureTypeinfo()

StatusCode D3PD::ObjGetterToolImpl::configureTypeinfo ( const std::type_info & ti)
virtual

Test type compatibility.

Parameters
tiThe desired type.

Test to see if the object being returned by the tool can be converted to a pointer to T. This can be used to perform type checks during job initialization.

Definition at line 124 of file ObjGetterToolImpl.cxx.

125{
126 return this->m_converter.init(this->typeinfo(), ti);
127}
TypeConverter m_converter
Helper to convert pointers.

◆ getTypeinfo()

const void * D3PD::ObjGetterToolImpl::getTypeinfo ( const std::type_info & ti,
bool allowMissing = false )
virtual

Return the target object cast to a different pointer type.

Parameters
tiThe desired type.
allowMissingIf true, then we should not generate errors if the requested object is missing.

Return the object as a pointer to the ti type. Return 0 if the get fails or if the pointer can't be converted.

Definition at line 45 of file ObjGetterToolImpl.cxx.

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}
#define REPORT_MESSAGE(LVL)
Report a message.
virtual StatusCode configureTypeinfo(const std::type_info &ti)
Test type compatibility.

◆ releaseObjectTypeinfo()

void D3PD::ObjGetterToolImpl::releaseObjectTypeinfo ( const void * p,
const std::type_info & ti )

Release an object retrieved from the getter.

Parameters
pThe object to release.
tiThe type of p.

Call this when you are done with the object returned by getUntyped(). The default implementation is a no-op, but if the getter dynamically allocated the object which it returned, this gives it a chance to free it.

Definition at line 82 of file ObjGetterToolImpl.cxx.

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}
TypeConverter m_backConverter
Helper to convert pointers back, for releaseObject.

Member Data Documentation

◆ m_backConverter

TypeConverter D3PD::ObjGetterToolImpl::m_backConverter
private

Helper to convert pointers back, for releaseObject.

Definition at line 97 of file ObjGetterToolImpl.h.

◆ m_converter

TypeConverter D3PD::ObjGetterToolImpl::m_converter
private

Helper to convert pointers.

Definition at line 94 of file ObjGetterToolImpl.h.


The documentation for this class was generated from the following files: