ATLAS Offline Software
IObjGetterTool.icc
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$
6 /**
7  * @file D3PDMakerInterfaces/IObjGetterTool.icc
8  * @author scott snyder <snyder@bnl.gov>
9  * @date Jul, 2009
10  * @brief Template implementations for IObjGetterTool.
11  */
12 
13 
14 namespace D3PD {
15 
16 
17 /**
18  * @brief Type-safe wrapper for @c get.
19  * @param allowMissing If true, then we should not generate errors
20  * if the requested object is missing.
21  *
22  * Return the object as a pointer to @c T.
23  * Return 0 if the get fails or if the pointer can't be converted.
24  *
25  * This is implemented in terms of @c getTypeinfo().
26  */
27 template <class T>
28 const T* IObjGetterTool::get (bool allowMissing /*= false*/)
29 {
30  return reinterpret_cast<const T*> (this->getTypeinfo (typeid(T),
31  allowMissing));
32 }
33 
34 
35 /**
36  * @brief Test type compatibility.
37  *
38  * Test to see if the object being returned by the tool can be converted
39  * to a pointer to @c T. This can be used to perform type checks during job
40  * initialization.
41  *
42  * This is implemented in terms of @c configureTypeinfo.
43  */
44 template <class T>
45 StatusCode IObjGetterTool::configureD3PD()
46 {
47  return this->configureTypeinfo (typeid(T));
48 }
49 
50 
51 /**
52  * @brief Release an object retrieved from the getter.
53  * @param p The object to release.
54  *
55  * Call this when you are done with the object returned by
56  * @c getUntyped(). The default implementation is a no-op,
57  * but if the getter dynamically allocated the object which
58  * it returned, this gives it a chance to free it.
59  */
60 inline
61 void IObjGetterTool::releaseObjectUntyped (const void* /*p*/)
62 {
63 }
64 
65 
66 /**
67  * @brief Release an object retrieved from the getter.
68  * @param p The object to release.
69  * @param ti The type of p.
70  *
71  * Call this when you are done with the object returned by
72  * @c getUntyped(). The default implementation is a no-op,
73  * but if the getter dynamically allocated the object which
74  * it returned, this gives it a chance to free it.
75  */
76 inline
77 void IObjGetterTool::releaseObjectTypeinfo (const void* /*p*/,
78  const std::type_info& /*ti*/)
79 {
80 }
81 
82 
83 /**
84  * @brief Type-safe wrapper for @c releaseObjectUntyped.
85  * @param p The object to release.
86  *
87  * Call this when you are done with the object returned by
88  * @c get(). The default implementation is a no-op,
89  * but if the getter dynamically allocated the object which
90  * it returned, this gives it a chance to free it.
91  *
92  * This is implemented in terms of @c releaseObjectTypeinfo().
93  */
94 template <class T>
95 void IObjGetterTool::releaseObject (const T* p)
96 {
97  this->releaseObjectTypeinfo (p, typeid(T));
98 }
99 
100 
101 } // namespace D3PD