This is a type-safe wrapper for the IObjGetterTool interface.
More...
#include <ObjGetterTool.h>
|
| | ObjGetterTool (const std::string &type, const std::string &name, const IInterface *parent) |
| | Standard Gaudi tool constructor.
|
| virtual const void * | getUntyped (bool allowMissing=false) |
| | Return the target object.
|
| virtual const std::type_info & | typeinfo () const |
| | Return the type of object retrieved by this tool.
|
| virtual const T * | get (bool allowMissing=false)=0 |
| | Return the target object.
|
| virtual void | releaseObject (const T *p) |
| | Release an object retrieved from the getter.
|
| virtual void | releaseObjectUntyped (const void *p) |
| | Release an object retrieved from the getter.
|
| 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.
|
template<class T>
class D3PD::ObjGetterTool< T >
This is a type-safe wrapper for the IObjGetterTool interface.
The template argument gives the type of object being retrieved. Derived classes should implement the get() method, to retrieve an object, and optionally releaseObject() to dispose of an object.
Definition at line 34 of file ObjGetterTool.h.
◆ ObjGetterTool()
template<class T>
| D3PD::ObjGetterTool< T >::ObjGetterTool |
( |
const std::string & | type, |
|
|
const std::string & | name, |
|
|
const IInterface * | parent ) |
Standard Gaudi tool constructor.
- Parameters
-
| type | The name of the tool type. |
| name | The tool name. |
| parent | The tool's Gaudi parent. |
◆ configureTypeinfo()
| StatusCode D3PD::ObjGetterToolImpl::configureTypeinfo |
( |
const std::type_info & | ti | ) |
|
|
virtualinherited |
Test type compatibility.
- Parameters
-
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}
◆ get()
Return the target object.
- Parameters
-
| allowMissing | If true, then we should not generate errors if the requested object is missing. |
Return 0 on failure.
◆ getTypeinfo()
| const void * D3PD::ObjGetterToolImpl::getTypeinfo |
( |
const std::type_info & | ti, |
|
|
bool | allowMissing = false ) |
|
virtualinherited |
Return the target object cast to a different pointer type.
- Parameters
-
| ti | The desired type. |
| allowMissing | If 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
50 this->m_converter.dstTypeinfo() != ti)
51 {
53 return 0;
54 }
55
56
57 const void*
p = this->getUntyped (allowMissing);
58
59
60 if (p) {
62 if (!p) {
64 <<
"Pointer conversion from " <<
m_converter.srcName() <<
" to "
66 }
67 }
69}
#define REPORT_MESSAGE(LVL)
Report a message.
◆ getUntyped()
Return the target object.
- Parameters
-
| allowMissing | If true, then we should not generate errors if the requested object is missing. |
Should be of the type given by typeinfo. Return 0 on failure.
◆ releaseObject()
Release an object retrieved from the getter.
- Parameters
-
Call this when you are done with the object returned by get(). 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.
◆ releaseObjectTypeinfo()
| void D3PD::ObjGetterToolImpl::releaseObjectTypeinfo |
( |
const void * | p, |
|
|
const std::type_info & | ti ) |
|
inherited |
Release an object retrieved from the getter.
- Parameters
-
| p | The object to release. |
| ti | The 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
90 this->m_backConverter.srcTypeinfo() != ti)
91 {
94 << "Can't configure pointer conversion from "
95 << System::typeinfoName (ti) << " to "
96 << System::typeinfoName (this->typeinfo());
97 return;
98 }
99 }
100
101
103
104
105 if (p)
106 this->releaseObjectUntyped (p);
107 else {
111 }
112}
◆ releaseObjectUntyped()
Release an object retrieved from the getter.
- Parameters
-
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.
◆ typeinfo()
Return the type of object retrieved by this tool.
◆ m_backConverter
◆ m_converter
The documentation for this class was generated from the following file: