Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-21 10:00:29

0001 /***********************************************************************************\
0002 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
0003 *                                                                                   *
0004 * This software is distributed under the terms of the Apache version 2 licence,     *
0005 * copied verbatim in the file "LICENSE".                                            *
0006 *                                                                                   *
0007 * In applying this licence, CERN does not waive the privileges and immunities       *
0008 * granted to it by virtue of its status as an Intergovernmental Organization        *
0009 * or submit itself to any jurisdiction.                                             *
0010 \***********************************************************************************/
0011 #ifndef GAUDIKERNEL_EXTENDS_H
0012 #define GAUDIKERNEL_EXTENDS_H
0013 
0014 #include "GaudiKernel/IInterface.h"
0015 
0016 /// Base class used to extend a class implementing other interfaces.
0017 /// Version for one interface.
0018 /// @author Marco Clemencic
0019 template <typename BASE, typename... Interfaces>
0020 class GAUDI_API extends : public BASE, virtual public extend_interfaces<Interfaces...> {
0021 
0022 public:
0023   /// Typedef to this class.
0024   using base_class = extends;
0025   /// Typedef to the base of this class.
0026   using extend_interfaces_base = extend_interfaces<Interfaces...>;
0027   /// forward constructor(s)
0028   using BASE::BASE;
0029 
0030   /// Implementation of IInterface::i_cast.
0031   void* i_cast( const InterfaceID& tid ) const override {
0032     using iids = typename extend_interfaces_base::ext_iids;
0033     void* ptr  = Gaudi::iid_cast( tid, iids{}, this );
0034     return ptr ? ptr : BASE::i_cast( tid );
0035   }
0036 
0037   /// Implementation of IInterface::queryInterface.
0038   StatusCode queryInterface( const InterfaceID& ti, void** pp ) override {
0039     if ( !pp ) return StatusCode::FAILURE;
0040     using iids = typename extend_interfaces_base::ext_iids;
0041     *pp        = Gaudi::iid_cast( ti, iids{}, this );
0042     // if cast failed, try the base class
0043     if ( !*pp ) return BASE::queryInterface( ti, pp );
0044     this->addRef();
0045     return StatusCode::SUCCESS;
0046   }
0047 
0048   /// Implementation of IInterface::getInterfaceNames.
0049   std::vector<std::string> getInterfaceNames() const override {
0050     using iids = typename extend_interfaces_base::ext_iids;
0051     auto vb    = BASE::getInterfaceNames();
0052     auto vi    = Gaudi::getInterfaceNames( iids{} );
0053     // start with base, and move the rest...
0054     vb.insert( vb.end(), std::make_move_iterator( vi.begin() ), std::make_move_iterator( vi.end() ) );
0055     return vb;
0056   }
0057 };
0058 
0059 template <typename BASE, typename I1>
0060 using extends1 = extends<BASE, I1>;
0061 template <typename BASE, typename I1, typename I2>
0062 using extends2 = extends<BASE, I1, I2>;
0063 template <typename BASE, typename I1, typename I2, typename I3>
0064 using extends3 = extends<BASE, I1, I2, I3>;
0065 template <typename BASE, typename I1, typename I2, typename I3, typename I4>
0066 using extends4 = extends<BASE, I1, I2, I3, I4>;
0067 
0068 #endif /* GAUDIKERNEL_EXTENDS_H */