2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
7 * @file D3PDMakerUtils/TypeConverter.icc
8 * @author scott snyder <snyder@bnl.gov>
10 * @brief Template and inline definitions for TypeConverter.
18 * @brief Alternate form of @c init, passing the destination
19 * type as a template argument.
20 * @param src_ti The source type for the conversion.
22 * The types should be for the pointer value types.
23 * I.e, if we want to convert from T* to U*,
24 * pass typeid(T) as @c src_ti and @c U as the template argument.
26 * Returns @c FAILURE if the conversion is not allowable.
27 * Either derived -> base or base -> derived conversions are allowed.
30 StatusCode TypeConverter::init (const std::type_info& src_ti)
32 return this->init (src_ti, typeid(T));
37 * @brief Convert pointer.
38 * @param The pointer to convert, as a pointer to the source type.
39 * @return The converted pointer, as a @c T*.
41 * @c T must be the same as the previously configured destination type.
43 * Will return 0 if the converter isn't properly initialized, or if
44 * the conversion fails (for a base -> derived conversion).
47 const T* TypeConverter::convert (const void* p) const
49 assert (typeid(T) == *m_dstTypeinfo);
50 return reinterpret_cast<const T*> (convertUntyped (p));
55 * @brief Test to see if this converter has been properly initialized.
58 bool TypeConverter::isValid() const
60 return m_strategy != INVALID;
65 * @brief Return the configured source type.
68 const std::type_info& TypeConverter::srcTypeinfo() const
70 return *m_srcTypeinfo;
75 * @brief Return the configured destination type.
78 const std::type_info& TypeConverter::dstTypeinfo() const
80 return *m_dstTypeinfo;