The Gaudi Framework  master (b9786168)
Loading...
Searching...
No Matches
extends.h
Go to the documentation of this file.
1/***********************************************************************************\
2* (c) Copyright 1998-2025 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#pragma once
12
14
18template <typename BASE, typename... Interfaces>
19class GAUDI_API extends : public BASE, virtual public extend_interfaces<Interfaces...> {
20
21public:
27 using BASE::BASE;
28
29 using extend_interfaces_base::i_cast;
30
32 void const* i_cast( const InterfaceID& tid ) const override {
33 using iids = typename extend_interfaces_base::ext_iids;
34 void* ptr = Gaudi::iid_cast( tid, iids{}, this );
35 return ptr ? ptr : BASE::i_cast( tid );
36 }
37
39 StatusCode queryInterface( const InterfaceID& ti, void** pp ) override {
40 if ( !pp ) return StatusCode::FAILURE;
41 *pp = i_cast( ti );
42 // if cast failed, try the base class
43 if ( !*pp ) return BASE::queryInterface( ti, pp );
44 this->addRef();
46 }
47
49 std::vector<std::string> getInterfaceNames() const override {
50 using iids = typename extend_interfaces_base::ext_iids;
51 auto vb = BASE::getInterfaceNames();
52 auto vi = Gaudi::getInterfaceNames( iids{} );
53 // start with base, and move the rest...
54 vb.insert( vb.end(), std::make_move_iterator( vi.begin() ), std::make_move_iterator( vi.end() ) );
55 return vb;
56 }
57};
58
59template <typename BASE, typename I1>
61template <typename BASE, typename I1, typename I2>
63template <typename BASE, typename I1, typename I2, typename I3>
65template <typename BASE, typename I1, typename I2, typename I3, typename I4>
#define GAUDI_API
Definition Kernel.h:49
Interface ID class.
Definition IInterface.h:38
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64
constexpr static const auto SUCCESS
Definition StatusCode.h:99
constexpr static const auto FAILURE
Definition StatusCode.h:100
Base class used to extend a class implementing other interfaces.
Definition extends.h:19
void const * i_cast(const InterfaceID &tid) const override
Implementation of IInterface::i_cast.
Definition extends.h:32
extend_interfaces< Interfaces... > extend_interfaces_base
Definition extends.h:25
StatusCode queryInterface(const InterfaceID &ti, void **pp) override
Implementation of IInterface::queryInterface.
Definition extends.h:39
std::vector< std::string > getInterfaceNames() const override
Implementation of IInterface::getInterfaceNames.
Definition extends.h:49
extends< BASE, I1, I2, I3 > extends3
Definition extends.h:64
extends< BASE, I1, I2 > extends2
Definition extends.h:62
extends< BASE, I1, I2, I3, I4 > extends4
Definition extends.h:66
extends< BASE, I1 > extends1
Definition extends.h:60
void * iid_cast(const InterfaceID &tid, Gaudi::interface_list< Is... >, P *ptr)
Definition IInterface.h:163
std::vector< std::string > getInterfaceNames(Gaudi::interface_list< Is... >)
Definition IInterface.h:158
Base class to be used to extend an interface.
typename Gaudi::interface_list_cat< typename Interfaces::ext_iids... >::type ext_iids