|
ATLAS Offline Software
|
Go to the documentation of this file.
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 >; \
231 } struct sg_dummy // to swallow semicolon
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 >; \
328 } struct sg_dummy // to swallow semicolon
336 #define SG_ADD_COPY_CONVERSION(D, C) \
338 template struct AddCopyConversionInit<D, C >; \
339 } struct sg_dummy // to swallow semicolon
405 template <
class SRC,
class DST>
414 virtual void*
create()
const {
return new DST; }
417 virtual void destroy (
void*
p)
const {
delete reinterpret_cast<DST*
>(
p); }
424 *
reinterpret_cast<DST*
>(dst));
441 template <
class D,
class B>
443 template <
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);
919 #endif // not ATHENAKERNEL_BASEINFO_H
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 BaseInfoBase * find1(const std::type_info &tinfo)
Helper for find.
static void * cast(T *p, const std::type_info &tinfo)
Cast to a base pointer.
static BaseInfoImpl< T > & instance()
Return a reference to the (singleton) implementation object for this class.
static const std::vector< CLID > & get_bases()
Return the class IDs of all known bases of T (that have class IDs).
virtual void * create() const =0
Create an instance of the destination class.
Base class for copy conversions, templated on source and destination classes.
static BaseInfoBase::castfn_t * castfn(CLID clid)
Return a function for casting to a base pointer.
~BaseInfoBase()
Destructor.
void maybeInit()
Run initializations for this class, if needed.
BaseInfoBase(const BaseInfoBase &)
void init_func_t(BaseInfoBase *bib)
Type for an initialization function.
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.
static std::vector< const std::type_info * > get_ti_bases()
Return the type_info's of all known bases of T.
const std::vector< CLID > & get_bases() const
Return the class IDs of all known bases of T (that have class IDs).
static void addInit(const std::type_info *tinfo, init_func_t *init_func)
Register an initialization function.
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 BaseInfoImpl< T > s_instance ATLAS_THREAD_SAFE
void * cast(void *p, CLID clid) const
Cast to a base pointer.
BaseInfoBaseImpl * m_impl
Pointer to internal state.
static T * castTo(void *p, CLID clid)
Cast to a derived pointer.
virtual void destroy(void *p) const =0
Destroy an instance of the destination class.
DST target_type
The destination class.
Base class for copy conversions.
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...
virtual void convertUntyped(const void *src, void *dst) const
Convert the contents of an instance of the source class SRC to an instance of the destination class D...
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.
Provide an interface for finding inheritance information at run time.
static T * castTo(void *p, const std::type_info &tinfo)
Cast to a derived pointer.
std::vector< CLID > get_copy_conversions() const
Return known copy conversions.
const CopyConversionBase * copy_conversion(const std::type_info &tinfo) const
Search for a copy conversion to tinfo.
virtual void * create() const
Create an instance of the destination class.
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.
void * castTo(void *p, CLID clid) const
Cast to a derived pointer.
uint32_t CLID
The Class ID type.
void * castfn_t(void *p)
Type of a pointer conversion function.
static BaseInfoBase::castfn_t * castfnTo(CLID clid)
Return a function for casting to a derived pointer.
BaseInfoBase(const std::type_info &tinfo)
Constructor.
static BaseInfoBase::castfn_t * castfnTo(const std::type_info &tinfo)
Return a function for casting to a derived pointer.
CLID clid() const
Return the CLID for this class.
BaseInfoBase & operator=(const BaseInfoBase &)
static const BaseInfoBase * find(CLID clid)
Find the BaseInfoBase instance for clid.
static void * cast(T *p, CLID clid)
Cast to a base pointer.
virtual ~CopyConversionBase()
Destructor.
static BaseInfoBase::castfn_t * castfn(const std::type_info &tinfo)
Return a function for casting to a base pointer.
The non-template portion of the BaseInfo implementation.
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.
static const BaseInfoBase & baseinfo()
Return the non-templated BaseInfoBase object for this type.
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...
const std::type_info & typeinfo() const
Return the std::type_info for this class.
Define macros for attributes used to control the static checker.
castfn_t * castfn(CLID clid) const
Return a function for casting to a base pointer.
void add_info(const std::type_info &tinfo, castfn_t *converter, castfn_t *converterTo, bool is_virtual)
Add information about one base class.
Helper metafunction to get base class types.
void add_copy_conversion(const std::type_info &tinfo, const CopyConversionBase *cnv)
Add a new copy conversion.
Traits class for representing derivation.
virtual void destroy(void *p) const
Destroy an instance of the destination class.
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.