Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  master (d98a2936)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
IInterface Class Referenceabstract

#include <GaudiKernel/IInterface.h>

Inheritance diagram for IInterface:

Public Types

enum  Status : StatusCode::code_t {
  Status::FAILURE = 0, Status::SUCCESS = 1, Status::NO_INTERFACE, Status::VERSMISMATCH,
  Status::LAST_ERROR
}
 Return status. More...
 
using iid = Gaudi::InterfaceId< IInterface, 0, 0 >
 Interface ID. More...
 
using ext_iids = Gaudi::interface_list< iid >
 Extra interfaces. More...
 

Public Member Functions

template<Gaudi::IsInterface TARGET>
TARGET * cast ()
 
template<Gaudi::IsInterface TARGET>
TARGET const * cast () const
 
template<typename TARGET >
 requires (!Gaudi::IsInterface< TARGET >) TARGET *cast()
 
template<typename TARGET >
 requires (!Gaudi::IsInterface< TARGET >) TARGET const *cast() const
 
virtual std::vector< std::string > getInterfaceNames () const =0
 Returns a vector of strings containing the names of all the implemented interfaces. More...
 
virtual unsigned long addRef () const =0
 Increment the reference count of Interface instance. More...
 
virtual unsigned long release () const =0
 Release Interface instance. More...
 
virtual unsigned long refCount () const =0
 Current reference count. More...
 
virtual StatusCode queryInterface (const InterfaceID &ti, void **pp)=0
 Set the void** to the pointer to the requested interface of the instance. More...
 
virtual ~IInterface ()=default
 Virtual destructor. More...
 
virtual void const * i_cast (const InterfaceID &) const =0
 
void * i_cast (const InterfaceID &iid)
 

Static Public Member Functions

static const InterfaceIDinterfaceID ()
 Return an instance of InterfaceID identifying the interface. More...
 

Protected Member Functions

virtual unsigned long decRef () const =0
 Decrement reference count and return the new reference count. More...
 

Detailed Description

Definition of the basic interface

Author
Pere Mato
Markus Frank
Marco Clemencic

Definition at line 225 of file IInterface.h.

Member Typedef Documentation

◆ ext_iids

Extra interfaces.

Definition at line 231 of file IInterface.h.

◆ iid

Interface ID.

Definition at line 228 of file IInterface.h.

Member Enumeration Documentation

◆ Status

Return status.

Enumerator
FAILURE 

Failure.

SUCCESS 

Normal successful completion.

NO_INTERFACE 

Requested interface is not available.

VERSMISMATCH 

Requested interface version is incompatible.

LAST_ERROR 

Last error.

Definition at line 300 of file IInterface.h.

302  FAILURE = 0,
304  SUCCESS = 1,
306  NO_INTERFACE,
308  VERSMISMATCH,
310  LAST_ERROR
311  };

Constructor & Destructor Documentation

◆ ~IInterface()

virtual IInterface::~IInterface ( )
virtualdefault

Virtual destructor.

Member Function Documentation

◆ addRef()

virtual unsigned long IInterface::addRef ( ) const
pure virtual

Increment the reference count of Interface instance.

◆ cast() [1/2]

template<Gaudi::IsInterface TARGET>
TARGET* IInterface::cast ( )
inline

Definition at line 237 of file IInterface.h.

237  {
238  if ( auto output = i_cast( TARGET::interfaceID() ) ) { return reinterpret_cast<TARGET*>( output ); }
239  if constexpr ( Gaudi::IsInterface<TARGET> ) {
240  void* tgt = nullptr;
241  queryInterface( TARGET::interfaceID(), &tgt ).ignore();
242  if ( tgt ) {
243  // queryInterface bumps the reference count of the target object, but we should not
244  auto* target = reinterpret_cast<TARGET*>( tgt );
245  // we cannot use release() because we may be called with an object with initial reference count of 0 and that
246  // would delete the object
247  static_cast<const IInterface*>( target )->decRef();
248  return target;
249  }
250  }
251  return nullptr;
252  }

◆ cast() [2/2]

template<Gaudi::IsInterface TARGET>
TARGET const* IInterface::cast ( ) const
inline

Definition at line 255 of file IInterface.h.

255  {
256  if ( auto output = i_cast( TARGET::interfaceID() ) ) { return reinterpret_cast<TARGET const*>( output ); }
257  if constexpr ( Gaudi::IsInterface<TARGET> ) {
258  void* tgt = nullptr;
259  const_cast<IInterface*>( this )->queryInterface( TARGET::interfaceID(), &tgt ).ignore();
260  if ( tgt ) {
261  // queryInterface bumps the reference count of the target object, but we should not
262  auto* target = reinterpret_cast<const TARGET*>( tgt );
263  // we cannot use release() because we may be called with an object with initial reference count of 0 and that
264  // would delete the object
265  static_cast<const IInterface*>( target )->decRef();
266  return target;
267  }
268  }
269  return nullptr;
270  }

◆ decRef()

virtual unsigned long IInterface::decRef ( ) const
protectedpure virtual

Decrement reference count and return the new reference count.

◆ getInterfaceNames()

virtual std::vector<std::string> IInterface::getInterfaceNames ( ) const
pure virtual

Returns a vector of strings containing the names of all the implemented interfaces.

◆ i_cast() [1/2]

virtual void const* IInterface::i_cast ( const InterfaceID ) const
pure virtual

◆ i_cast() [2/2]

void* IInterface::i_cast ( const InterfaceID iid)
inline

Definition at line 320 of file IInterface.h.

320  {
321  return const_cast<void*>( const_cast<const IInterface*>( this )->i_cast( iid ) );
322  }

◆ interfaceID()

static const InterfaceID& IInterface::interfaceID ( )
inlinestatic

Return an instance of InterfaceID identifying the interface.

Definition at line 234 of file IInterface.h.

234 { return iid::interfaceID(); }

◆ queryInterface()

virtual StatusCode IInterface::queryInterface ( const InterfaceID ti,
void **  pp 
)
pure virtual

Set the void** to the pointer to the requested interface of the instance.

◆ refCount()

virtual unsigned long IInterface::refCount ( ) const
pure virtual

Current reference count.

◆ release()

virtual unsigned long IInterface::release ( ) const
pure virtual

Release Interface instance.

◆ requires() [1/2]

template<typename TARGET >
IInterface::requires ( !Gaudi::IsInterface< TARGET >  )
inline

Definition at line 273 of file IInterface.h.

274  {
275  return dynamic_cast<TARGET*>( this );
276  }

◆ requires() [2/2]

template<typename TARGET >
IInterface::requires ( !Gaudi::IsInterface< TARGET >  ) const
inline

Definition at line 279 of file IInterface.h.

280  {
281  return dynamic_cast<TARGET const*>( this );
282  }

The documentation for this class was generated from the following file:
GaudiPython.Bindings.FAILURE
FAILURE
Definition: Bindings.py:84
IInterface::iid
Gaudi::InterfaceId< IInterface, 0, 0 > iid
Interface ID.
Definition: IInterface.h:228
IInterface::queryInterface
virtual StatusCode queryInterface(const InterfaceID &ti, void **pp)=0
Set the void** to the pointer to the requested interface of the instance.
IInterface::i_cast
virtual void const * i_cast(const InterfaceID &) const =0
StatusCode::code_t
unsigned long code_t
type of StatusCode value
Definition: StatusCode.h:66
gaudirun.output
output
Definition: gaudirun.py:521
compareOutputFiles.target
target
Definition: compareOutputFiles.py:489
Gaudi::InterfaceId::interfaceID
static const InterfaceID & interfaceID()
Definition: IInterface.h:187
GaudiPython.Bindings.SUCCESS
SUCCESS
Definition: Bindings.py:83
StatusCode::ignore
const StatusCode & ignore() const
Allow discarding a StatusCode without warning.
Definition: StatusCode.h:139
IInterface
Definition: IInterface.h:225
IInterface::decRef
virtual unsigned long decRef() const =0
Decrement reference count and return the new reference count.