Go to the documentation of this file.
   11 #ifndef GAUDIKERNEL_IINTERFACE_H 
   12 #define GAUDIKERNEL_IINTERFACE_H 
   19 #include <type_traits> 
   23 #define DeclareInterfaceID( iface, major, minor )                                                                      \ 
   24   static const InterfaceID& interfaceID() { return iid::interfaceID(); }                                               \ 
   25   using iid      = Gaudi::InterfaceId<iface, major, minor>;                                                            \ 
   26   using ext_iids = typename iid::iids 
   41 #if defined( GAUDI_V20_COMPAT ) && !defined( G21_NEW_INTERFACES ) 
   42   [[deprecated( 
"use InterfaceID(id, major, minor) instead" )]] constexpr 
InterfaceID( 
unsigned long lid )
 
   44       : m_id( lid & 0xFFFF ), m_major_ver( ( lid & 0xFF000000 ) >> 24 ), m_minor_ver( ( lid & 0xFF0000 ) >> 16 ) {}
 
   46   constexpr 
InterfaceID( 
unsigned long id, 
unsigned long major, 
unsigned long minor = 0 )
 
   48       : m_id( 
id ), m_major_ver( major ), m_minor_ver( minor ) {}
 
   51       : m_id( hash32( 
name ) ), m_major_ver( major ), m_minor_ver( minor ) {}
 
   52 #if defined( GAUDI_V20_COMPAT ) && !defined( G21_NEW_INTERFACES ) 
   53   [[deprecated]] constexpr 
operator unsigned long()
 const {
 
   55     return ( m_major_ver << 24 ) + ( m_minor_ver << 16 ) + m_id;
 
   58   constexpr 
unsigned long id()
 const { 
return m_id; }
 
   61   constexpr 
unsigned long majorVersion()
 const { 
return m_major_ver; }
 
   63   constexpr 
unsigned long minorVersion()
 const { 
return m_minor_ver; }
 
   78     unsigned int hash = 0;
 
   79     for ( 
const char* k = 
key; *k; ++k ) {
 
   81       hash += ( hash << 10 );
 
   82       hash ^= ( hash >> 6 );
 
   84     hash += ( hash << 3 );
 
   85     hash ^= ( hash >> 11 );
 
   86     hash += ( hash << 15 );
 
   93     s << 
"IID_" << 
id.id();
 
  106   template <
typename... I>
 
  111     template <
typename T>
 
  117       template <
typename... Is>
 
  120       template <
typename List, 
typename I>
 
  125       template <
typename... Is, 
typename I>
 
  127           : 
id_<std::conditional_t<std::is_base_of_v<id_<I>, inherit_from<id_<Is>...>>, interface_list<Is...>,
 
  128                                    interface_list<Is..., I>>> {};
 
  130       template <
typename, 
typename>
 
  133       template <
typename State>
 
  136       template <
typename... Is, 
typename I, 
typename List>
 
  141     template <
typename... Is>
 
  146   template <
typename... I>
 
  150   template <
typename... I>
 
  154   template <
typename... I1, 
typename... I2>
 
  159   template <
typename... I1, 
typename... I2, 
typename... Others>
 
  164   template <
typename... I>
 
  167   template <
typename... Is, 
typename I>
 
  171   template <
typename... Is>
 
  176   template <
typename... Is, 
typename P>
 
  178     const void* 
target = 
nullptr;
 
  180         ( 
target = 
static_cast<typename Is::interface_type const*
>( ptr ), 
true ) ) ||
 
  182     return const_cast<void*
>( 
target );
 
  188   template <
typename INTERFACE, 
unsigned long majVers, 
unsigned long minVers>
 
  208     template <
typename IFACE1, 
typename IFACE2, 
unsigned long major1, 
unsigned long major2, 
unsigned long minor1,
 
  209               unsigned long minor2>
 
  213     template <
typename IFACE, 
unsigned long major, 
unsigned long minor>
 
  220     template <
typename IFACE1, 
typename IFACE2, 
unsigned long major1, 
unsigned long major2, 
unsigned long minor1,
 
  221               unsigned long minor2>
 
  225     template <
typename IFACE, 
unsigned long major, 
unsigned long minor1, 
unsigned long minor2>
 
  252 #if defined( GAUDI_V20_COMPAT ) && !defined( G21_NEW_INTERFACES ) 
  262 #if defined( GAUDI_V20_COMPAT ) && !defined( G21_NEW_INTERFACES ) 
  278 #if defined( GAUDI_V20_COMPAT ) && !defined( G21_NEW_INTERFACES ) 
  313   template <
typename TARGET>
 
  315     return reinterpret_cast<TARGET*
>( i->
i_cast( TARGET::interfaceID() ) );
 
  319   template <
typename TARGET>
 
  321     return reinterpret_cast<const TARGET*
>( i->
i_cast( TARGET::interfaceID() ) );
 
  335 template <
class IFace>
 
  338   return i->queryInterface( IFace::interfaceID(), &ii ).isSuccess();
 
  351 template <
class DEST, 
class SRC>
 
  353   return reinterpret_cast<DEST**
>( ptr );
 
  360 #endif // GAUDIKERNEL_IINTERFACE_H 
  
 
Class to handle automatically the versioning of the interfaces when they are inheriting from other in...
constexpr bool fullMatch(const InterfaceID &iid) const
check full compatibility.
constexpr struct Gaudi::fullMatch_t fullMatch
static constexpr unsigned long majorVersion()
virtual StatusCode queryInterface(const InterfaceID &ti, void **pp)=0
Set the void** to the pointer to the requested interface of the instance.
static constexpr unsigned long minorVersion()
unsigned long code_t
type of StatusCode value
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
constexpr unsigned long id() const
get the interface identifier
State
Allowed states for classes implementing the state machine (ApplicationMgr, Algorithm,...
virtual ~IInterface()=default
Virtual destructor.
static const InterfaceID & interfaceID()
virtual void * i_cast(const InterfaceID &) const =0
main cast function
static const InterfaceID & interfaceID()
Return an instance of InterfaceID identifying the interface.
unsigned long m_minor_ver
constexpr unsigned long majorVersion() const
get the major version of the interface
INTERFACE interface_type
interface type
unsigned long m_major_ver
constexpr bool operator==(const InterfaceID &iid) const
compare operator
constexpr bool operator()(InterfaceId< IFACE, major, minor >, InterfaceId< IFACE, major, minor >) const
static std::string name()
constexpr struct Gaudi::majorMatch_t majorMatch
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
DEST ** pp_cast(SRC **ptr)
Small function to be used instead of the construct (void**)&pointer, which produces,...
constexpr unsigned long minorVersion() const
get the minor version of the interface
static const std::type_info & TypeInfo()
constexpr bool operator()(InterfaceId< IFACE1, major1, minor1 >, InterfaceId< IFACE2, major2, minor2 >) const
#define STATUSCODE_ENUM_DECL(ENUM)
Declare an enum to be used as StatusCode value.
void * iid_cast(const InterfaceID &tid, Gaudi::interface_list< Is... >, P *ptr)
std::vector< std::string > getInterfaceNames(Gaudi::interface_list< Is... >)
constexpr bool versionMatch(const InterfaceID &iid) const
check compatibility.
static unsigned int hash32(const char *key)
Jenkins one-at-time hash function – see https://en.wikipedia.org/wiki/Jenkins_hash_function.
virtual std::vector< std::string > getInterfaceNames() const =0
Returns a vector of strings containing the names of all the implemented interfaces.
bool isValidInterface(IFace *i)
Templated function that throws an exception if the version if the interface implemented by the object...
typename Gaudi::interface_list_append< typename interface_type::ext_iids, InterfaceId >::type iids
List of interfaces.
constexpr bool operator()(InterfaceId< IFACE1, major1, minor1 >, InterfaceId< IFACE2, major2, minor2 >) const
constexpr bool operator()(InterfaceId< IFACE, major, minor1 >, InterfaceId< IFACE, major, minor2 >) const
InterfaceID(const char *name, unsigned long major, unsigned long minor=0)
constructor from components
virtual unsigned long refCount() const =0
Current reference count.
virtual unsigned long release()=0
Release Interface instance.
friend std::ostream & operator<<(std::ostream &s, const InterfaceID &id)
ostream operator for InterfaceID. Needed by PluginSvc
TARGET * Cast(IInterface *i)
Cast a IInterface pointer to an IInterface specialization (TARGET).
virtual unsigned long addRef()=0
Increment the reference count of Interface instance.