The Gaudi Framework
master (37c0b60a)
implements.h
Go to the documentation of this file.
1
/***********************************************************************************\
2
* (c) Copyright 1998-2024 CERN for the benefit of the LHCb and ATLAS collaborations *
3
* *
4
* This software is distributed under the terms of the Apache version 2 licence, *
5
* copied verbatim in the file "LICENSE". *
6
* *
7
* In applying this licence, CERN does not waive the privileges and immunities *
8
* granted to it by virtue of its status as an Intergovernmental Organization *
9
* or submit itself to any jurisdiction. *
10
\***********************************************************************************/
11
#ifndef GAUDIKERNEL_IMPLEMENTS_H
12
#define GAUDIKERNEL_IMPLEMENTS_H
13
14
#include <
GaudiKernel/IInterface.h
>
15
#include <atomic>
16
18
template
<
typename
... Interfaces>
19
struct
GAUDI_API
implements
:
virtual
public
extend_interfaces
<Interfaces...> {
21
using
base_class
=
implements
<Interfaces...>;
23
using
extend_interfaces_base
=
extend_interfaces
<Interfaces...>;
24
using
iids
=
typename
extend_interfaces_base::ext_iids
;
25
26
public
:
28
void
*
i_cast
(
const
InterfaceID
& tid )
const override
{
return
Gaudi::iid_cast
( tid,
iids
{}, this ); }
30
StatusCode
queryInterface
(
const
InterfaceID
& ti,
void
**
pp
)
override
{
31
if
( !
pp
)
return
StatusCode::FAILURE
;
32
*
pp
=
Gaudi::iid_cast
( ti,
iids
{}, this );
33
if
( !*
pp
)
return
StatusCode::FAILURE
;
/* cast failed */
34
this->addRef();
35
return
StatusCode::SUCCESS
;
36
}
38
std::vector<std::string>
getInterfaceNames
()
const override
{
return
Gaudi::getInterfaceNames
(
iids
{} ); }
40
implements
() =
default
;
42
implements
(
const
implements
&
/*other*/
) : m_refCount{ 0 } {}
44
implements
&
operator=
(
const
implements
&
/*other*/
) {
return
*
this
; }
// cppcheck-suppress operatorEqVarError
45
46
public
:
48
unsigned
long
addRef
()
override
{
return
++m_refCount; }
50
unsigned
long
release
()
override
{
51
/* Avoid to decrement 0 */
52
auto
count = ( m_refCount ? --m_refCount : m_refCount.load() );
53
if
( count == 0 )
delete
this
;
54
return
count;
55
}
57
unsigned
long
refCount
()
const override
{
return
m_refCount.load(); }
58
59
protected
:
61
std::atomic_ulong m_refCount = { 0 };
62
};
63
64
template
<
typename
I1>
65
using
implements1
=
implements<I1>
;
66
template
<
typename
I1,
typename
I2>
67
using
implements2
=
implements<I1, I2>
;
68
template
<
typename
I1,
typename
I2,
typename
I3>
69
using
implements3
=
implements<I1, I2, I3>
;
70
template
<
typename
I1,
typename
I2,
typename
I3,
typename
I4>
71
using
implements4
=
implements<I1, I2, I3, I4>
;
72
73
#endif
/* GAUDIKERNEL_IMPLEMENTS_H_ */
implements::queryInterface
StatusCode queryInterface(const InterfaceID &ti, void **pp) override
Implementation of IInterface::queryInterface.
Definition:
implements.h:30
extend_interfaces< Interfaces... >::ext_iids
typename Gaudi::interface_list_cat< typename Interfaces::ext_iids... >::type ext_iids
take union of the ext_iids of all Interfaces...
Definition:
extend_interfaces.h:26
implements::operator=
implements & operator=(const implements &)
Assignment operator (do not touch the reference count).
Definition:
implements.h:44
implements::refCount
unsigned long refCount() const override
Current reference count
Definition:
implements.h:57
implements< IInterface >::iids
typename extend_interfaces_base::ext_iids iids
Definition:
implements.h:24
std::vector< std::string >
implements::getInterfaceNames
std::vector< std::string > getInterfaceNames() const override
Implementation of IInterface::getInterfaceNames.
Definition:
implements.h:38
extend_interfaces
Base class to be used to extend an interface.
Definition:
extend_interfaces.h:15
StatusCode
Definition:
StatusCode.h:65
IInterface.h
implements::implements
implements()=default
Default constructor.
implements::implements
implements(const implements &)
Copy constructor (zero the reference count)
Definition:
implements.h:42
implements::addRef
unsigned long addRef() override
Reference Interface instance
Definition:
implements.h:48
implements
Base class used to implement the interfaces.
Definition:
implements.h:19
implements::release
unsigned long release() override
Release Interface instance
Definition:
implements.h:50
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition:
StatusCode.h:100
Gaudi::iid_cast
void * iid_cast(const InterfaceID &tid, Gaudi::interface_list< Is... >, P *ptr)
Definition:
IInterface.h:177
Gaudi::getInterfaceNames
std::vector< std::string > getInterfaceNames(Gaudi::interface_list< Is... >)
Definition:
IInterface.h:172
implements::i_cast
void * i_cast(const InterfaceID &tid) const override
Implementation of IInterface::i_cast.
Definition:
implements.h:28
InterfaceID
Definition:
IInterface.h:39
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition:
StatusCode.h:101
compareOutputFiles.pp
pp
Definition:
compareOutputFiles.py:507
GAUDI_API
#define GAUDI_API
Definition:
Kernel.h:81
GaudiKernel
include
GaudiKernel
implements.h
Generated on Thu Dec 19 2024 15:35:01 for The Gaudi Framework by
1.8.18