ATLAS Offline Software
Loading...
Searching...
No Matches
ICollectionGetterTool.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/ICollectionGetterTool.icc
8 * @author scott snyder <snyder@bnl.gov>
9 * @date Jul, 2009
10 * @brief Template implementations for ICollectionGetterTool.
11 */
12
13
14namespace D3PD {
15
16
17/**
18 * @brief Type-safe wrapper for @c next.
19 *
20 * Return the next element from the collection as a pointer to @c T.
21 * Return 0 if the pointer can't be converted or at the end of the
22 * iteration.
23 *
24 * This is implemented in terms of @c nextTypeinfo().
25 */
26template <class T>
27const T* ICollectionGetterTool::next()
28{
29 return reinterpret_cast<const T*> (nextTypeinfo (typeid(T)));
30}
31
32
33/**
34 * @brief Test type compatibility.
35 *
36 * Test to see if the object being returned by the tool can be converted
37 * to a pointer to @c T. This can be used to perform type checks during job
38 * initialization.
39 *
40 * This is implemented in terms of @c configureElementTypeinfo.
41 */
42template <class T>
43StatusCode ICollectionGetterTool::configureD3PD()
44{
45 return configureElementTypeinfo (typeid(T));
46}
47
48
49/**
50 * @brief Type-safe wrapper for @c releaseElementUntyped.
51 * @param p The element to release.
52 *
53 * Call this when you are done with the object returned by
54 * @c next(). The default implementation is a no-op,
55 * but if the getter dynamically allocated the object which
56 * it returned, this gives it a chance to free it.
57 *
58 * This is implemented in terms of @c releaseElementTypeinfo().
59 */
60template <class T>
61void ICollectionGetterTool::releaseElement (const T* p)
62{
63 this->releaseElementTypeinfo (p, typeid(T));
64}
65
66
67/**
68 * @brief Release an element retrieved from the getter.
69 * @param p The element to release.
70 * @param ti The type of p.
71 *
72 * Call this when you are done with the element returned by
73 * @c nextUntyped(). The default implementation is a no-op,
74 * but if the getter dynamically allocated the object which
75 * it returned, this gives it a chance to free it.
76 */
77inline
78void
79ICollectionGetterTool::releaseElementTypeinfo (const void* /*p*/,
80 const std::type_info& /*ti*/)
81{
82}
83
84
85} // namespace D3PD