3#include <Infinity/api.h>
4#include <Infinity/Types/TypeID.hpp>
5#include <Infinity/Types/Core/Base.hpp>
6#include <Infinity/Util/unordered_dense.h>
28 template<
typename F,
typename T>
125 return _converters.find(hashIDs(fromType, toType)) != _converters.end();
197 template<
typename F,
typename T>
200 const TypeID& fid = getTypeID<F>();
201 const TypeID& tid = getTypeID<T>();
202 return static_cast<T*
>(convert(fid, tid, from));
221 template<
typename F,
typename T>
224 const TypeID& fid = getTypeID<F>();
225 const TypeID& tid = getTypeID<T>();
226 return canConvert(fid, tid);
257 template<
typename F,
typename T>
260 const TypeID& fid = getTypeID<F>();
261 const TypeID& tid = getTypeID<T>();
263 _converters[hashIDs(fid, tid)] = fn;
314 ankerl::unordered_dense::map<TypeHash, ConverterFn> _converters;
Global registry for type conversion functions.
Definition Converters.hpp:95
static Converters & instance()
Gets the global Converters singleton instance.
bool canConvert()
Checks if conversion is possible (compile-time version).
Definition Converters.hpp:222
Core::Base * convert(const TypeID &fromType, const TypeID &toType, const Core::Base *from)
Performs type conversion using registered converter (runtime version).
bool canConvert(const TypeID &fromType, const TypeID &toType)
Checks if conversion between two types is possible (runtime version).
Definition Converters.hpp:123
T * convert(F *from)
Performs type conversion with compile-time type safety.
Definition Converters.hpp:198
void registerConversion(ConverterFn fn)
Registers a conversion function between two types.
Definition Converters.hpp:258
ConverterFn converter(const TypeID &fromType, const TypeID &toType)
Retrieves the converter function for a type pair.
Abstract base class for all Infinity Engine data types.
Definition Base.hpp:43
std::function< Core::Base *(const Core::Base *)> ConverterFn
Type-erased function wrapper for runtime type conversion.
Definition Converters.hpp:41
T(const F &) Converter
Function signature for type conversion between two specific types.
Definition Converters.hpp:29
uint64_t TypeHash
64-bit hash value computed from a type's name.
Definition TypeID.hpp:30
Runtime type identifier for the Infinity type system.
Definition TypeID.hpp:71