1 #ifndef GAUDIKERNEL_IINTERFACE_H 2 #define GAUDIKERNEL_IINTERFACE_H 13 #define DeclareInterfaceID( iface, major, minor ) \ 14 static const InterfaceID& interfaceID() { return iid::interfaceID(); } \ 15 using iid = Gaudi::InterfaceId<iface, major, minor>; \ 16 using ext_iids = iid::iids 32 #if defined( GAUDI_V20_COMPAT ) && !defined( G21_NEW_INTERFACES ) 35 : m_id( lid & 0xFFFF ), m_major_ver( ( lid & 0xFF000000 ) >> 24 ), m_minor_ver( ( lid & 0xFF0000 ) >> 16 )
39 constexpr InterfaceID(
unsigned long id,
unsigned long major,
unsigned long minor = 0 )
41 : m_id(
id ), m_major_ver( major ), m_minor_ver( minor )
46 : m_id( hash32( name ) ), m_major_ver( major ), m_minor_ver( minor )
49 #if defined( GAUDI_V20_COMPAT ) && !defined( G21_NEW_INTERFACES ) 50 constexpr
operator unsigned long()
const {
return ( m_major_ver << 24 ) + ( m_minor_ver << 16 ) + m_id; }
53 constexpr
unsigned long id()
const {
return m_id; }
56 constexpr
unsigned long majorVersion()
const {
return m_major_ver; }
58 constexpr
unsigned long minorVersion()
const {
return m_minor_ver; }
67 constexpr
bool fullMatch(
const InterfaceID& iid )
const 72 constexpr
bool operator==(
const InterfaceID& iid )
const {
return fullMatch( iid ); }
74 static unsigned int hash32(
const char* key )
76 unsigned int hash = 0;
77 for (
const char* k = key; *k; ++k ) {
79 hash += ( hash << 10 );
80 hash ^= ( hash >> 6 );
82 hash += ( hash << 3 );
83 hash ^= ( hash >> 11 );
84 hash += ( hash << 15 );
97 template <
typename... I>
104 template <
typename T>
111 template <
typename... Is>
115 template <
typename List,
typename I>
121 template <
typename... Is,
typename I>
123 :
id_<typename std::conditional<std::is_base_of<id_<I>, inherit_from<id_<Is>...>>::value,
124 interface_list<Is...>, interface_list<Is..., I>>::type> {
127 template <
typename,
typename>
131 template <
typename State>
135 template <
typename... Is,
typename I,
typename List>
140 template <
typename... Is>
145 template <
typename... I>
149 template <
typename... I>
154 template <
typename... I1,
typename... I2>
159 template <
typename... I1,
typename... I2,
typename... Others>
165 template <
typename... I>
168 template <
typename... Is,
typename I>
174 namespace iid_cast_details
176 template <
typename I>
179 return const_cast<I*
>( i );
182 template <
typename... Is>
187 template <
typename P>
194 template <
typename I,
typename... Is>
196 template <
typename P>
205 template <
typename... Is>
211 template <
typename... Is,
typename P>
215 return iid_cast_( tid, ptr );
221 template <
typename INTERFACE,
unsigned long majVers,
unsigned long minVers>
242 template <
typename IFACE1,
typename IFACE2,
unsigned long major1,
unsigned long major2,
unsigned long minor1,
243 unsigned long minor2>
248 template <
typename IFACE,
unsigned long major,
unsigned long minor>
256 template <
typename IFACE1,
typename IFACE2,
unsigned long major1,
unsigned long major2,
unsigned long minor1,
257 unsigned long minor2>
262 template <
typename IFACE,
unsigned long major,
unsigned long minor1,
unsigned long minor2>
291 #if defined( GAUDI_V20_COMPAT ) && !defined( G21_NEW_INTERFACES ) 301 #if defined( GAUDI_V20_COMPAT ) && !defined( G21_NEW_INTERFACES ) 310 virtual unsigned long addRef() = 0;
313 virtual unsigned long release() = 0;
316 virtual unsigned long refCount()
const 317 #if defined( GAUDI_V20_COMPAT ) && !defined( G21_NEW_INTERFACES ) 353 template <
typename TARGET>
356 return reinterpret_cast<TARGET*
>( i->
i_cast( TARGET::interfaceID() ) );
360 template <
typename TARGET>
363 return reinterpret_cast<const TARGET*
>( i->
i_cast( TARGET::interfaceID() ) );
382 StatusCode sc = i->queryInterface( I::interfaceID(), &ii );
390 s <<
"IID_" <<
id.id();
405 template <
class DEST,
class SRC>
408 return reinterpret_cast<DEST**
>( ptr );
415 #endif // GAUDIKERNEL_IINTERFACE_H
std::ostream & operator<<(std::ostream &s, const InterfaceID &id)
ostream operator for InterfaceID. Needed by PluginSvc
constexpr bool operator()(InterfaceId< IFACE, major, minor1 >, InterfaceId< IFACE, major, minor2 >) const
constexpr bool operator()(InterfaceId< IFACE1, major1, minor1 >, InterfaceId< IFACE2, major2, minor2 >) const
constexpr void * operator()(const InterfaceID &, P *) const
const TARGET * Cast(const IInterface *i)
Cast a IInterface pointer to an IInterface specialization (TARGET).
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
static unsigned int hash32(const char *key)
Jenkins one-at-time hash function – see https://en.wikipedia.org/wiki/Jenkins_hash_function.
#define STATUSCODE_ENUM_DECL(ENUM)
Declare an enum to be used as StatusCode value.
bool isValidInterface(I *i)
Templated function that throws an exception if the version if the interface implemented by the object...
State
Allowed states for classes implementing the state machine (ApplicationMgr, Algorithm, Service, AlgTool).
INTERFACE interface_type
interface type
static constexpr unsigned long majorVersion()
Class to handle automatically the versioning of the interfaces when they are inheriting from other in...
DEST ** pp_cast(SRC **ptr)
Small function to be used instead of the construct (void**)&pointer, which produces, on gcc 4.1 optimized, the warning warning: dereferencing type-punned pointer will break strict-aliasing rules The assempler code produced is equivalent to the one with the direct cast.
virtual void * i_cast(const InterfaceID &) const =0
main cast function
unsigned long m_minor_ver
TupleObj.h GaudiAlg/TupleObj.h namespace with few technical implementations.
constexpr bool operator()(InterfaceId< IFACE, major, minor >, InterfaceId< IFACE, major, minor >) const
This class is used for returning status codes from appropriate routines.
Definition of the basic interface.
constexpr unsigned long minorVersion() const
get the minor version of the interface
constexpr bool versionMatch(const InterfaceID &iid) const
check compatibility.
static std::string name()
static constexpr unsigned long minorVersion()
unsigned long m_major_ver
virtual unsigned long release()=0
Release Interface instance.
constexpr bool operator()(InterfaceId< IFACE1, major1, minor1 >, InterfaceId< IFACE2, major2, minor2 >) const
void * operator()(const InterfaceID &tid, P *ptr) const
static const InterfaceID & interfaceID()
constexpr unsigned long id() const
get the interface identifier
constexpr bool operator==(const InterfaceID &iid) const
compare operator
virtual unsigned long addRef()=0
Increment the reference count of Interface instance.
Gaudi::interface_list< iid > ext_iids
Extra interfaces.
std::vector< std::string > getInterfaceNames(Gaudi::interface_list< Is... >)
constexpr void * void_cast(const I *i)
constexpr unsigned long majorVersion() const
get the major version of the interface
StatusCode queryInterface(const InterfaceID &iid, void **pinterface) override
constexpr bool fullMatch(const InterfaceID &iid) const
check full compatibility.
InterfaceID(const char *name, unsigned long major, unsigned long minor=0)
constructor from components
void * iid_cast(const InterfaceID &tid, Gaudi::interface_list< Is... >, P *ptr)
static const InterfaceID & interfaceID()
Return an instance of InterfaceID identifying the interface.
typename Gaudi::interface_list_append< typename interface_type::ext_iids, InterfaceId >::type iids
List of interfaces.
Helper functions to set/get the application return code.
unsigned long code_t
type of StatusCode value
Gaudi::InterfaceId< IInterface, 0, 0 > iid
Interface ID.
static const std::type_info & TypeInfo()