The Gaudi Framework  master (d98a2936)
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 
13 #include <GaudiKernel/IInterface.h>
14 
18 template <typename BASE, typename... Interfaces>
19 class GAUDI_API extends : public BASE, virtual public extend_interfaces<Interfaces...> {
20 
21 public:
25  using extend_interfaces_base = extend_interfaces<Interfaces...>;
27  using BASE::BASE;
28 
30  void const* i_cast( const InterfaceID& tid ) const override {
31  using iids = typename extend_interfaces_base::ext_iids;
32  void* ptr = Gaudi::iid_cast( tid, iids{}, this );
33  return ptr ? ptr : BASE::i_cast( tid );
34  }
35 
37  StatusCode queryInterface( const InterfaceID& ti, void** pp ) override {
38  if ( !pp ) return StatusCode::FAILURE;
39  using iids = typename extend_interfaces_base::ext_iids;
40  *pp = Gaudi::iid_cast( ti, iids{}, this );
41  // if cast failed, try the base class
42  if ( !*pp ) return BASE::queryInterface( ti, pp );
43  this->addRef();
44  return StatusCode::SUCCESS;
45  }
46 
48  std::vector<std::string> getInterfaceNames() const override {
49  using iids = typename extend_interfaces_base::ext_iids;
50  auto vb = BASE::getInterfaceNames();
51  auto vi = Gaudi::getInterfaceNames( iids{} );
52  // start with base, and move the rest...
53  vb.insert( vb.end(), std::make_move_iterator( vi.begin() ), std::make_move_iterator( vi.end() ) );
54  return vb;
55  }
56 };
57 
58 template <typename BASE, typename I1>
60 template <typename BASE, typename I1, typename I2>
62 template <typename BASE, typename I1, typename I2, typename I3>
64 template <typename BASE, typename I1, typename I2, typename I3, typename I4>
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:25
extends::i_cast
void const * i_cast(const InterfaceID &tid) const override
Implementation of IInterface::i_cast.
Definition: extends.h:30
extend_interfaces
Base class to be used to extend an interface.
Definition: extend_interfaces.h:14
StatusCode
Definition: StatusCode.h:64
IInterface.h
CommonMessaging
Definition: CommonMessaging.h:65
extends
Base class used to extend a class implementing other interfaces.
Definition: extends.h:19
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:99
Gaudi::iid_cast
void * iid_cast(const InterfaceID &tid, Gaudi::interface_list< Is... >, P *ptr)
Definition: IInterface.h:163
Gaudi::getInterfaceNames
std::vector< std::string > getInterfaceNames(Gaudi::interface_list< Is... >)
Definition: IInterface.h:158
extends::queryInterface
StatusCode queryInterface(const InterfaceID &ti, void **pp) override
Implementation of IInterface::queryInterface.
Definition: extends.h:37
extends::getInterfaceNames
std::vector< std::string > getInterfaceNames() const override
Implementation of IInterface::getInterfaceNames.
Definition: extends.h:48
InterfaceID
Definition: IInterface.h:38
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:100
compareOutputFiles.pp
pp
Definition: compareOutputFiles.py:507
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:49