22#define DeclareInterfaceID( iface, major, minor ) \
23 static const InterfaceID& interfaceID() { return iid::interfaceID(); } \
24 using iid = Gaudi::InterfaceId<iface, major, minor>; \
25 using ext_iids = typename iid::iids
41 constexpr InterfaceID(
unsigned long id,
unsigned long major,
unsigned long minor = 0 )
44 InterfaceID(
const char* name,
unsigned long major,
unsigned long minor = 0 )
47 constexpr unsigned long id()
const {
return m_id; }
65 static unsigned int hash32(
const char* key ) {
66 unsigned int hash = 0;
67 for (
const char* k = key; *k; ++k ) {
69 hash += ( hash << 10 );
70 hash ^= ( hash >> 6 );
72 hash += ( hash << 3 );
73 hash ^= ( hash >> 11 );
74 hash += ( hash << 15 );
80 s <<
"IID_" <<
id.id();
92 template <
typename... I>
103 template <
typename... Is>
106 template <
typename List,
typename I>
111 template <
typename... Is,
typename I>
113 :
id_<std::conditional_t<std::is_base_of_v<id_<I>, inherit_from<id_<Is>...>>, interface_list<Is...>,
114 interface_list<Is..., I>>> {};
116 template <
typename,
typename>
119 template <
typename State>
122 template <
typename... Is,
typename I,
typename List>
127 template <
typename... Is>
132 template <
typename... I>
136 template <
typename... I>
140 template <
typename... I1,
typename... I2>
145 template <
typename... I1,
typename... I2,
typename... Others>
150 template <
typename... I>
153 template <
typename... Is,
typename I>
157 template <
typename... Is>
159 return { Is::name()... };
162 template <
typename... Is,
typename P>
164 const void* target =
nullptr;
166 ( target =
static_cast<typename Is::interface_type const*
>( ptr ),
true ) ) ||
168 return const_cast<void*
>( target );
174 template <
typename INTERFACE,
unsigned long majVers,
unsigned long minVers>
185 static inline const std::type_info&
TypeInfo() {
return typeid(
typename iids::type ); }
194 template <
typename IFACE1,
typename IFACE2,
unsigned long major1,
unsigned long major2,
unsigned long minor1,
195 unsigned long minor2>
199 template <
typename IFACE,
unsigned long major,
unsigned long minor>
206 template <
typename IFACE1,
typename IFACE2,
unsigned long major1,
unsigned long major2,
unsigned long minor1,
207 unsigned long minor2>
211 template <
typename IFACE,
unsigned long major,
unsigned long minor1,
unsigned long minor2>
236 template <Gaudi::IsInterface TARGET>
238 if (
auto output =
i_cast( TARGET::interfaceID() ) ) {
return reinterpret_cast<TARGET*
>( output ); }
244 auto* target =
reinterpret_cast<TARGET*
>( tgt );
254 template <Gaudi::IsInterface TARGET>
256 if (
auto output =
i_cast( TARGET::interfaceID() ) ) {
return reinterpret_cast<TARGET const*
>( output ); }
262 auto* target =
reinterpret_cast<const TARGET*
>( tgt );
272 template <
typename TARGET>
275 return dynamic_cast<TARGET*
>( this );
278 template <
typename TARGET>
281 return dynamic_cast<TARGET const*
>( this );
288 virtual unsigned long addRef()
const = 0;
326 virtual unsigned long decRef()
const = 0;
332 template <
typename TARGET>
334 return i ? i->
cast<TARGET>() :
nullptr;
337 template <
typename TARGET>
339 return i ? i->
cast<
const TARGET>() :
nullptr;
353template <
class IFace>
356 return i->queryInterface( IFace::interfaceID(), &ii ).isSuccess();
369template <
class DEST,
class SRC>
371 return reinterpret_cast<DEST**
>( ptr );
DEST ** pp_cast(SRC **ptr)
Small function to be used instead of the construct (void**)&pointer, which produces,...
bool isValidInterface(IFace *i)
Templated function that throws an exception if the version if the interface implemented by the object...
#define STATUSCODE_ENUM_DECL(ENUM)
Declare an enum to be used as StatusCode value.
Definition of the basic interface.
virtual StatusCode queryInterface(const InterfaceID &ti, void **pp)=0
Set the void** to the pointer to the requested interface of the instance.
TARGET const * cast() const
TARGET const * cast() const
virtual void const * i_cast(const InterfaceID &) const =0
virtual unsigned long refCount() const =0
Current reference count.
virtual std::vector< std::string > getInterfaceNames() const =0
Returns a vector of strings containing the names of all the implemented interfaces.
@ VERSMISMATCH
Requested interface version is incompatible.
@ NO_INTERFACE
Requested interface is not available.
@ SUCCESS
Normal successful completion.
Gaudi::interface_list< iid > ext_iids
Extra interfaces.
void * i_cast(const InterfaceID &iid)
Gaudi::InterfaceId< IInterface, 0, 0 > iid
Interface ID.
virtual unsigned long decRef() const =0
Decrement reference count and return the new reference count.
virtual unsigned long addRef() const =0
Increment the reference count of Interface instance.
virtual ~IInterface()=default
Virtual destructor.
static const InterfaceID & interfaceID()
Return an instance of InterfaceID identifying the interface.
virtual unsigned long release() const =0
Release Interface instance.
constexpr bool versionMatch(const InterfaceID &iid) const
check compatibility.
unsigned long m_minor_ver
constexpr bool operator==(const InterfaceID &iid) const
compare operator
friend std::ostream & operator<<(std::ostream &s, const InterfaceID &id)
ostream operator for InterfaceID. Needed by PluginSvc
constexpr unsigned long majorVersion() const
get the major version of the interface
constexpr InterfaceID(unsigned long id, unsigned long major, unsigned long minor=0)
constructor from components
constexpr unsigned long id() const
get the interface identifier
InterfaceID(const char *name, unsigned long major, unsigned long minor=0)
constructor from components
unsigned long m_major_ver
constexpr bool fullMatch(const InterfaceID &iid) const
check full compatibility.
static unsigned int hash32(const char *key)
Jenkins one-at-time hash function – see https://en.wikipedia.org/wiki/Jenkins_hash_function.
constexpr unsigned long minorVersion() const
get the minor version of the interface
This class is used for returning status codes from appropriate routines.
unsigned long code_t
type of StatusCode value
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
void * iid_cast(const InterfaceID &tid, Gaudi::interface_list< Is... >, P *ptr)
std::vector< std::string > getInterfaceNames(Gaudi::interface_list< Is... >)
TARGET * Cast(IInterface *i)
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Class to handle automatically the versioning of the interfaces when they are inheriting from other in...
static const InterfaceID & interfaceID()
static constexpr unsigned long minorVersion()
typename Gaudi::interface_list_append< typename interface_type::ext_iids, InterfaceId >::type iids
List of interfaces.
static constexpr unsigned long majorVersion()
INTERFACE interface_type
interface type
static std::string name()
static const std::type_info & TypeInfo()
constexpr bool operator()(InterfaceId< IFACE, major, minor >, InterfaceId< IFACE, major, minor >) const
constexpr bool operator()(InterfaceId< IFACE1, major1, minor1 >, InterfaceId< IFACE2, major2, minor2 >) const
constexpr bool operator()(InterfaceId< IFACE1, major1, minor1 >, InterfaceId< IFACE2, major2, minor2 >) const
constexpr bool operator()(InterfaceId< IFACE, major, minor1 >, InterfaceId< IFACE, major, minor2 >) const