2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
5 * @file D3PDMakerUtils/MultiAssociationTool.icc
6 * @author scott snyder <snyder@bnl.gov>
8 * @brief Type-safe wrapper for multiple-target associator tools.
16 * @brief Standard Gaudi tool constructor.
17 * @param type The name of the tool type.
18 * @param name The tool name.
19 * @param parent The tool's Gaudi parent.
21 template <typename TO_T>
22 MultiAssociationToolTo<TO_T>::MultiAssociationToolTo
23 (const std::string& type,
24 const std::string& name,
25 const IInterface* parent)
26 : MultiAssociationToolImpl (type, name, parent)
28 // cppcheck-suppress missingReturn; false positive
33 * @brief Return the element type for the target of the association.
35 * I.e., @c nextUntyped returns a pointer to this type.
37 template <typename TO_T>
39 MultiAssociationToolTo<TO_T>::elementTypeinfo () const
46 * @brief Return a pointer to the next element in the association.
48 * Return 0 when the association has been exhausted.
50 template <typename TO_T>
52 MultiAssociationToolTo<TO_T>::nextUntyped ()
59 * @brief Release an object retrieved from the association.
60 * @param p The object to release.
62 * Call this when you are done with the object returned by
63 * @c next(). The default implementation is a no-op,
64 * but if the association dynamically allocated the object which
65 * it returned, this gives it a chance to free it.
67 template <typename TO_T>
68 void MultiAssociationToolTo<TO_T>::releaseElement (const TO_T* /*p*/)
74 * @brief Release an object retrieved from the association.
75 * @param p The object to release.
77 * Call this when you are done with the object returned by
78 * @c nextUntyped(). The default implementation is a no-op,
79 * but if the association dynamically allocated the object which
80 * it returned, this gives it a chance to free it.
82 template <typename TO_T>
84 MultiAssociationToolTo<TO_T>::releaseElementUntyped (const void* p)
86 return releaseElement (reinterpret_cast<const TO_T*> (p));
90 //=========================================================================
94 * @brief Standard Gaudi tool constructor.
95 * @param type The name of the tool type.
96 * @param name The tool name.
97 * @param parent The tool's Gaudi parent.
99 template <typename FROM_T, typename TO_T>
100 MultiAssociationTool<FROM_T, TO_T>::MultiAssociationTool
101 (const std::string& type,
102 const std::string& name,
103 const IInterface* parent)
104 : MultiAssociationToolTo<TO_T> (type, name, parent)
106 // cppcheck-suppress missingReturn; false positive
111 * @brief Return the @c std::type_info for the source of the association.
113 template <typename FROM_T, typename TO_T>
114 const std::type_info&
115 MultiAssociationTool<FROM_T, TO_T>::fromTypeinfo () const
117 return typeid (FROM_T);
122 * @brief Start the iteration for a new association.
123 * @param p The object from which to associate.
125 template <typename FROM_T, typename TO_T>
127 MultiAssociationTool<FROM_T, TO_T>::resetUntyped (const void* p)
129 const FROM_T* pp = reinterpret_cast<const FROM_T*> (this->doConversion (p));
130 if (!pp) return StatusCode::FAILURE;