![]() |
ATLAS Offline Software
|
This is helper for converting between pointers of different types, given dynamically by std::type_info
.
More...
#include <TypeConverter.h>
Public Member Functions | |
TypeConverter () | |
Default constructor. More... | |
StatusCode | init (const std::type_info &src_ti, const std::type_info &dst_ti) |
Initialize the converter. More... | |
StatusCode | init (const std::type_info &src_ti, const std::vector< const std::type_info * > &dst_tis, size_t &which) |
Initialize the converter. More... | |
template<typename T > | |
StatusCode | init (const std::type_info &src_ti) |
Alternate form of init , passing the destination type as a template argument. More... | |
const void * | convertUntyped (const void *p) const |
Convert pointer. More... | |
template<class T > | |
const T * | convert (const void *p) const |
Convert pointer. More... | |
bool | isValid () const |
Test to see if this converter has been properly initialized. More... | |
const std::type_info & | srcTypeinfo () const |
Return the configured source type. More... | |
const std::type_info & | dstTypeinfo () const |
Return the configured destination type. More... | |
std::string | srcName () const |
Return the name of the source type, or an empty string. More... | |
std::string | dstName () const |
Return the name of the destination type, or an empty string. More... | |
Private Types | |
enum | Strategy { INVALID, IDENTICAL, SRC_BASE, DST_BASE } |
Private Member Functions | |
StatusCode | tryInit (const std::type_info &src_ti, const std::type_info &dst_ti) |
Initialize the converter. More... | |
Private Attributes | |
const std::type_info * | m_srcTypeinfo |
The source type. More... | |
const std::type_info * | m_dstTypeinfo |
The destination type. More... | |
const SG::BaseInfoBase * | m_srcBIB |
BaseInfo for the source type. More... | |
const SG::BaseInfoBase * | m_dstBIB |
BaseInfo for the destination type. More... | |
Strategy | m_strategy |
Strategy to use for the conversion. More... | |
This is helper for converting between pointers of different types, given dynamically by std::type_info
.
The converter must first be initialized by calling init()
with the source and destination types. If the conversion is allowable, then this will return SUCCESS
, and isValid()
will return true
. Pointers can them be converted by calling convert()
or convertUntyped()
.
The remaining methods retrieve the data that was passed to init()
.
Definition at line 44 of file TypeConverter.h.
|
private |
Definition at line 185 of file TypeConverter.h.
D3PD::TypeConverter::TypeConverter | ( | ) |
Default constructor.
This will create the object in an invalid state.
Definition at line 29 of file TypeConverter.cxx.
Convert pointer.
The | pointer to convert, as a pointer to the source type. |
T*
.T
must be the same as the previously configured destination type.
Will return 0 if the converter isn't properly initialized, or if the conversion fails (for a base -> derived conversion).
Convert pointer.
The | pointer to convert, as a pointer to the source type. |
Will return 0 if the converter isn't properly initialized, or if the conversion fails (for a base -> derived conversion).
Definition at line 116 of file TypeConverter.cxx.
std::string D3PD::TypeConverter::dstName | ( | ) | const |
Return the name of the destination type, or an empty string.
Definition at line 151 of file TypeConverter.cxx.
const std::type_info& D3PD::TypeConverter::dstTypeinfo | ( | ) | const |
Return the configured destination type.
StatusCode D3PD::TypeConverter::init | ( | const std::type_info & | src_ti | ) |
Alternate form of init
, passing the destination type as a template argument.
src_ti | The source type for the conversion. |
The types should be for the pointer value types. I.e, if we want to convert from T* to U*, pass typeid(T) as src_ti
and U
as the template argument.
Returns FAILURE
if the conversion is not allowable. Either derived -> base or base -> derived conversions are allowed.
StatusCode D3PD::TypeConverter::init | ( | const std::type_info & | src_ti, |
const std::type_info & | dst_ti | ||
) |
Initialize the converter.
src_ti | The source type for the conversion. |
dst_ti | The destination type for the conversion. |
The types should be for the pointer value types. I.e, if we want to convert from T* to U*, pass typeid(T) and typeid(U) as src_ti
and dst_ti
, respectively.
Returns FAILURE
if the conversion is not allowable. Either derived -> base or base -> derived conversions are allowed.
Definition at line 51 of file TypeConverter.cxx.
StatusCode D3PD::TypeConverter::init | ( | const std::type_info & | src_ti, |
const std::vector< const std::type_info * > & | dst_tis, | ||
size_t & | which | ||
) |
Initialize the converter.
src_ti | The source type for the conversion. | |
dst_tis | List of possible destination types for the conversion. | |
[out] | which | Index of accepted conversion. |
The types should be for the pointer value types. I.e, if we want to convert from T* to U*, pass typeid(T) and typeid(U) as src_ti
and dst_ti
, respectively.
All possible destination types are tried; the first one that succeeds is accepted, and WHICH is set to the index of that type. Either derived -> base or base -> derived conversions are allowed.
Returns FAILURE
if no candidate conversions are allowable.
Definition at line 82 of file TypeConverter.cxx.
bool D3PD::TypeConverter::isValid | ( | ) | const |
Test to see if this converter has been properly initialized.
std::string D3PD::TypeConverter::srcName | ( | ) | const |
Return the name of the source type, or an empty string.
Definition at line 141 of file TypeConverter.cxx.
const std::type_info& D3PD::TypeConverter::srcTypeinfo | ( | ) | const |
Return the configured source type.
|
private |
Initialize the converter.
src_ti | The source type for the conversion. |
dst_ti | The destination type for the conversion. |
The types should be for the pointer value types. I.e, if we want to convert from T* to U*, pass typeid(T) and typeid(U) as src_ti
and dst_ti
, respectively.
Returns FAILURE
if the conversion is not allowable. Either derived -> base or base -> derived conversions are allowed.
Helper: this doesn't print error messages.
Definition at line 172 of file TypeConverter.cxx.
|
private |
BaseInfo for the destination type.
Definition at line 183 of file TypeConverter.h.
|
private |
The destination type.
Definition at line 177 of file TypeConverter.h.
|
private |
BaseInfo for the source type.
Definition at line 180 of file TypeConverter.h.
|
private |
The source type.
Definition at line 174 of file TypeConverter.h.
|
private |
Strategy to use for the conversion.
Definition at line 200 of file TypeConverter.h.