The Gaudi Framework  master (37c0b60a)
Interface.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 // ============================================================================
12 #ifndef GAUDIPYTHON_INTERFACE_H
13 #define GAUDIPYTHON_INTERFACE_H 1
14 // ============================================================================
15 // Include files
16 // ============================================================================
17 // STD & STL
18 // ============================================================================
19 #include <functional>
20 // ============================================================================
21 // GaudiKernel
22 // ============================================================================
23 #include <GaudiKernel/IInterface.h>
24 #include <GaudiKernel/SmartIF.h>
25 // ============================================================================
26 // GaudiPython
27 // ============================================================================
29 // ============================================================================
30 
31 namespace GaudiPython {
42  template <class TYPE>
43  struct Interface {
48  TYPE* operator()( const IInterface* in ) const {
49  return SmartIF<TYPE>( TYPE::interfaceID(), const_cast<IInterface*>( in ) );
50  }
51 
56  static TYPE* cast( const IInterface* in ) { return SmartIF<TYPE>( const_cast<IInterface*>( in ) ); }
57 
63  static TYPE* cast( const InterfaceID& iid, const IInterface* in ) {
64  return SmartIF<TYPE>( iid, const_cast<IInterface*>( in ) );
65  }
66  };
67 
68  template <>
70  typedef IInterface TYPE;
75  TYPE* operator()( const IInterface* in ) const { return SmartIF<TYPE>( const_cast<IInterface*>( in ) ); }
76 
81  static TYPE* cast( const IInterface* in ) { return SmartIF<TYPE>( const_cast<IInterface*>( in ) ); }
82 
88  static TYPE* cast( const InterfaceID& /* iid */, const IInterface* in ) {
89  return SmartIF<TYPE>( const_cast<IInterface*>( in ) );
90  }
91  };
92 
93 } // end of namespace GaudiPython
94 
95 #endif // GAUDIPYTHON_INTERFACE_H
GaudiPython::Interface::cast
static TYPE * cast(const InterfaceID &iid, const IInterface *in)
the only one important method (static)
Definition: Interface.h:63
GaudiPython::Interface::cast
static TYPE * cast(const IInterface *in)
the only one important method (static)
Definition: Interface.h:56
SmartIF.h
IInterface.h
GaudiPython.h
GaudiPython::Interface< IInterface >::cast
static TYPE * cast(const InterfaceID &, const IInterface *in)
the only one important method (static)
Definition: Interface.h:88
SmartIF
Definition: IConverter.h:25
GaudiPython::Interface< IInterface >::TYPE
IInterface TYPE
Definition: Interface.h:70
GaudiPython
Namespace for all classes interfacing Gaudi to Python.
Definition: Algorithm.h:30
IInterface
Definition: IInterface.h:239
GaudiPython::Interface
Definition: Interface.h:43
GaudiPython::Interface< IInterface >::operator()
TYPE * operator()(const IInterface *in) const
the only one important method
Definition: Interface.h:75
InterfaceID
Definition: IInterface.h:39
GaudiPython::Interface< IInterface >::cast
static TYPE * cast(const IInterface *in)
the only one important method (static)
Definition: Interface.h:81
GaudiPython::Interface::operator()
TYPE * operator()(const IInterface *in) const
the only one important method
Definition: Interface.h:48