2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
7 * @file D3PDMakerUtils/SingleAssociationTool.icc
8 * @author scott snyder <snyder@bnl.gov>
10 * @brief Type-safe wrapper for single associator tools.
18 * @brief Standard Gaudi tool constructor.
19 * @param type The name of the tool type.
20 * @param name The tool name.
21 * @param parent The tool's Gaudi parent.
23 template <typename TO_T>
24 SingleAssociationToolTo<TO_T>::SingleAssociationToolTo
25 (const std::string& type,
26 const std::string& name,
27 const IInterface* parent)
28 : SingleAssociationToolImpl (type, name, parent)
34 * @brief Return the type of object retrieved by this tool.
36 template <typename TO_T>
38 SingleAssociationToolTo<TO_T>::typeinfo () const
45 * @brief Release an object retrieved from the association.
46 * @param p The object to release.
48 * Call this when you are done with the object returned by
49 * @c get(). The default implementation is a no-op,
50 * but if the association dynamically allocated the object which
51 * it returned, this gives it a chance to free it.
53 template <typename TO_T>
55 SingleAssociationToolTo<TO_T>::releaseObject (const typename SelectType<TO_T, 0>::type* /*p*/)
61 * @brief Release an object retrieved from the association.
62 * @param p The object to release.
64 * Call this when you are done with the object returned by
65 * @c getUntyped(). The default implementation is a no-op,
66 * but if the association dynamically allocated the object which
67 * it returned, this gives it a chance to free it.
69 template <typename TO_T>
71 SingleAssociationToolTo<TO_T>::releaseObjectUntyped (const void* p)
73 releaseObject (reinterpret_cast<const typename SelectType<TO_T, 0>::type*> (p));
77 //=========================================================================
81 * @brief Standard Gaudi tool constructor.
82 * @param type The name of the tool type.
83 * @param name The tool name.
84 * @param parent The tool's Gaudi parent.
86 template <typename FROM_T, typename TO_T>
87 SingleAssociationTool<FROM_T, TO_T>::SingleAssociationTool
88 (const std::string& type,
89 const std::string& name,
90 const IInterface* parent)
91 : SingleAssociationToolTo<TO_T> (type, name, parent)
97 * @brief Return the target object.
98 * @param p The source object for the association.
100 * Return the target of the association, or 0.
101 * Should be of the type given by @c typeinfo.
103 template <typename FROM_T, typename TO_T>
105 SingleAssociationTool<FROM_T, TO_T>::getUntyped (const void* p)
108 reinterpret_cast<const FROM_T*> (this->doConversion (p));
115 * @brief Return the @c std::type_info for the source of the association.
117 template <typename FROM_T, typename TO_T>
118 const std::type_info&
119 SingleAssociationTool<FROM_T, TO_T>::fromTypeinfo () const
121 return typeid (FROM_T);