The Gaudi Framework  master (82fdf313)
Loading...
Searching...
No Matches
IInterface Class Referenceabstract

Definition of the basic interface. More...

#include <GaudiKernel/IInterface.h>

Inheritance diagram for IInterface:

Public Types

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

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.
 
virtual unsigned long addRef () const =0
 Increment the reference count of Interface instance.
 
virtual unsigned long release () const =0
 Release Interface instance.
 
virtual unsigned long refCount () const =0
 Current reference count.
 
virtual StatusCode queryInterface (const InterfaceID &ti, void **pp)=0
 Set the void** to the pointer to the requested interface of the instance.
 
virtual ~IInterface ()=default
 Virtual destructor.
 
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.
 

Protected Member Functions

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

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 };
unsigned long code_t
type of StatusCode value
Definition StatusCode.h:66

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/4]

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 }
virtual StatusCode queryInterface(const InterfaceID &ti, void **pp)=0
Set the void** to the pointer to the requested interface of the instance.
virtual void const * i_cast(const InterfaceID &) const =0
virtual unsigned long decRef() const =0
Decrement reference count and return the new reference count.
const StatusCode & ignore() const
Allow discarding a StatusCode without warning.
Definition StatusCode.h:139

◆ cast() [2/4]

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

Definition at line 274 of file IInterface.h.

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

◆ cast() [3/4]

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 }

◆ cast() [4/4]

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

Definition at line 280 of file IInterface.h.

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

◆ 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 }
Gaudi::InterfaceId< IInterface, 0, 0 > iid
Interface ID.
Definition IInterface.h:228

◆ 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(); }
static const InterfaceID & interfaceID()
Definition IInterface.h:187

◆ 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.


The documentation for this class was generated from the following file: