ATLAS Offline Software
Loading...
Searching...
No Matches
MultiAssociationTool.icc
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4/**
5 * @file D3PDMakerUtils/MultiAssociationTool.icc
6 * @author scott snyder <snyder@bnl.gov>
7 * @date Aug, 2009
8 * @brief Type-safe wrapper for multiple-target associator tools.
9 */
10
11
12namespace D3PD {
13
14
15/**
16 * @brief Return the element type for the target of the association.
17 *
18 * I.e., @c nextUntyped returns a pointer to this type.
19 */
20template <typename TO_T>
21const std::type_info&
22MultiAssociationToolTo<TO_T>::elementTypeinfo () const
23{
24 return typeid (TO_T);
25}
26
27
28/**
29 * @brief Return a pointer to the next element in the association.
30 *
31 * Return 0 when the association has been exhausted.
32 */
33template <typename TO_T>
34const void*
35MultiAssociationToolTo<TO_T>::nextUntyped ()
36{
37 return next();
38}
39
40
41/**
42 * @brief Release an object retrieved from the association.
43 * @param p The object to release.
44 *
45 * Call this when you are done with the object returned by
46 * @c next(). The default implementation is a no-op,
47 * but if the association dynamically allocated the object which
48 * it returned, this gives it a chance to free it.
49 */
50template <typename TO_T>
51void MultiAssociationToolTo<TO_T>::releaseElement (const TO_T* /*p*/)
52{
53}
54
55
56/**
57 * @brief Release an object retrieved from the association.
58 * @param p The object to release.
59 *
60 * Call this when you are done with the object returned by
61 * @c nextUntyped(). The default implementation is a no-op,
62 * but if the association dynamically allocated the object which
63 * it returned, this gives it a chance to free it.
64 */
65template <typename TO_T>
66void
67MultiAssociationToolTo<TO_T>::releaseElementUntyped (const void* p)
68{
69 return releaseElement (reinterpret_cast<const TO_T*> (p));
70}
71
72
73//=========================================================================
74
75
76/**
77 * @brief Return the @c std::type_info for the source of the association.
78 */
79template <typename FROM_T, typename TO_T>
80const std::type_info&
81MultiAssociationTool<FROM_T, TO_T>::fromTypeinfo () const
82{
83 return typeid (FROM_T);
84}
85
86
87/**
88 * @brief Start the iteration for a new association.
89 * @param p The object from which to associate.
90 */
91template <typename FROM_T, typename TO_T>
92StatusCode
93MultiAssociationTool<FROM_T, TO_T>::resetUntyped (const void* p)
94{
95 const FROM_T* pp = reinterpret_cast<const FROM_T*> (this->doConversion (p));
96 if (!pp) return StatusCode::FAILURE;
97 return reset (*pp);
98}
99
100
101} // namespace D3PD