184#ifndef ATHENAKERNEL_BASEINFO_H
185#define ATHENAKERNEL_BASEINFO_H
189#include "GaudiKernel/ClassID.h"
192#include <type_traits>
211#define SG_VIRTUAL(T) Virtual<T>
224#define SG_BASES(D, ...) \
226 template<> struct Bases<D >{ \
227 using bases = BaseList<__VA_ARGS__>; \
229 template struct RegisterBaseInit<D >; \
230 template struct BaseInit<D >; \
243#define SG_BASE(D, B) SG_BASES(D, B)
256#define SG_BASES1(D, B) SG_BASES(D, B)
270#define SG_BASES2(D, B1, B2) SG_BASES(D, B1, B2)
285#define SG_BASES3(D, B1, B2, B3) SG_BASES(D, B1, B2, B3)
301#define SG_BASES4(D, B1, B2, B3, B4) SG_BASES(D, B1, B2, B3, B4)
325#define SG_ADD_BASE(D, B) \
327 template struct AddBaseInit<D, B >; \
336#define SG_ADD_COPY_CONVERSION(D, C) \
338 template struct AddCopyConversionInit<D, C >; \
405template <
class SRC,
class DST>
414 virtual void*
create()
const override {
return new DST; }
417 virtual void destroy (
void* p)
const override {
delete reinterpret_cast<DST*
>(p); }
423 convert (*
reinterpret_cast<const SRC*
>(src),
424 *
reinterpret_cast<DST*
>(dst));
430 virtual void convert (
const SRC& src, DST& dst)
const = 0;
441template <
class D,
class B>
443template <
class D,
class B>
453 template <
class D,
class B>
455 template <
class D,
class B>
468 const std::type_info&
typeinfo()
const;
489 void*
cast (
void* p,
const std::type_info& tinfo)
const;
512 void*
castTo (
void* p,
const std::type_info& tinfo)
const;
570 const std::vector<CLID>&
get_bases ()
const;
576 std::vector<const std::type_info*>
get_ti_bases ()
const;
592 bool is_base (
const std::type_info& tinfo)
const;
609 bool is_virtual (
const std::type_info& tinfo)
const;
661 void add_info (
const std::type_info& tinfo,
697 static void addInit (
const std::type_info* tinfo,
753 template <
class D,
class B>
755 template <
class D,
class B>
777 static void*
cast (T* p,
const std::type_info& tinfo);
800 static T*
castTo (
void* p,
const std::type_info& tinfo);
875 static bool is_base (
const std::type_info& tinfo);
Traits class for representing derivation.
uint32_t CLID
The Class ID type.
Define macros for attributes used to control the static checker.
The non-template portion of the BaseInfo implementation.
static BaseInfoBase * find1(const std::type_info &tinfo)
Helper for find.
const CopyConversionBase * copy_conversion(const std::type_info &tinfo) const
Search for a copy conversion to tinfo.
void add_info(const std::type_info &tinfo, castfn_t *converter, castfn_t *converterTo, bool is_virtual)
Add information about one base class.
BaseInfoBase(const BaseInfoBase &)
void add_copy_conversion(const std::type_info &tinfo, const CopyConversionBase *cnv)
Add a new copy conversion.
void maybeInit()
Run initializations for this class, if needed.
void init_func_t(BaseInfoBase *bib)
Type for an initialization function.
BaseInfoBase & operator=(const BaseInfoBase &)
~BaseInfoBase()
Destructor.
std::vector< const std::type_info * > get_ti_bases() const
Return the type_info's of all known bases of T.
castfn_t * castfnTo(CLID clid) const
Return a function for casting to a derived pointer.
void * castTo(void *p, CLID clid) const
Cast to a derived pointer.
CLID clid() const
Return the CLID for this class.
static void addInit(const std::type_info *tinfo, init_func_t *init_func)
Register an initialization function.
friend struct RegisterAddCopyConversionInit
static const BaseInfoBase * find(CLID clid)
Find the BaseInfoBase instance for clid.
friend struct RegisterAddBaseInit
const std::type_info & typeinfo() const
Return the std::type_info for this class.
void * cast(void *p, CLID clid) const
Cast to a base pointer.
BaseInfoBase(const std::type_info &tinfo)
Constructor.
castfn_t * castfn(CLID clid) const
Return a function for casting to a base pointer.
const std::vector< CLID > & get_bases() const
Return the class IDs of all known bases of T (that have class IDs).
bool is_base(CLID clid) const
Return true if clid is the ID of a class that is known to be a base of T.
bool is_virtual(CLID clid) const
Return true if clid is the ID of a class that is known to be a virtual base of T.
std::vector< CLID > get_copy_conversions() const
Return known copy conversions.
BaseInfoBaseImpl * m_impl
Pointer to internal state.
void * castfn_t(void *p)
Type of a pointer conversion function.
Provide an interface for finding inheritance information at run time.
static bool is_virtual(CLID clid)
Return true if clid is the ID of a class that is known to be a virtual base of T.
static BaseInfoBase::castfn_t * castfnTo(CLID clid)
Return a function for casting to a derived pointer.
static bool is_base(const std::type_info &tinfo)
Return true if tinfo is the std::type_info of a class that is known to be a base of T.
static const std::vector< CLID > & get_bases()
Return the class IDs of all known bases of T (that have class IDs).
static BaseInfoBase::castfn_t * castfnTo(const std::type_info &tinfo)
Return a function for casting to a derived pointer.
static bool is_base(CLID clid)
Return true if clid is the ID of a class that is known to be a base of T.
static std::vector< const std::type_info * > get_ti_bases()
Return the type_info's of all known bases of T.
static BaseInfoBase::castfn_t * castfn(CLID clid)
Return a function for casting to a base pointer.
static BaseInfoBase::castfn_t * castfn(const std::type_info &tinfo)
Return a function for casting to a base pointer.
static void * cast(T *p, const std::type_info &tinfo)
Cast to a base pointer.
friend struct RegisterAddCopyConversionInit
friend struct RegisterAddBaseInit
static bool is_virtual(const std::type_info &tinfo)
Return true if tinfo is the std::type_info of a class that is known to be a virtual base of T.
static T * castTo(void *p, const std::type_info &tinfo)
Cast to a derived pointer.
static T * castTo(void *p, CLID clid)
Cast to a derived pointer.
static BaseInfoImpl< T > & instance()
Return a reference to the (singleton) implementation object for this class.
static BaseInfoImpl< T > s_instance ATLAS_THREAD_SAFE
static const BaseInfoBase & baseinfo()
Return the non-templated BaseInfoBase object for this type.
static void * cast(T *p, CLID clid)
Cast to a base pointer.
Base class for copy conversions.
virtual void convertUntyped(const void *src, void *dst) const =0
Convert the contents of an instance of the source class SRC to an instance of the destination class D...
virtual void * create() const =0
Create an instance of the destination class.
virtual ~CopyConversionBase()
Destructor.
virtual void destroy(void *p) const =0
Destroy an instance of the destination class.
Base class for copy conversions, templated on source and destination classes.
virtual void convertUntyped(const void *src, void *dst) const override
Convert the contents of an instance of the source class SRC to an instance of the destination class D...
DST target_type
The destination class.
virtual void * create() const override
Create an instance of the destination class.
virtual void destroy(void *p) const override
Destroy an instance of the destination class.
virtual void convert(const SRC &src, DST &dst) const =0
Convert the contents of an instance of the source class SRC to an instance of the destination class D...