00001 // $Id: Interface.h,v 1.8 2005/11/08 16:31:03 mato Exp $ 00002 // ============================================================================ 00003 #ifndef GAUDIPYTHON_INTERFACE_H 00004 #define GAUDIPYTHON_INTERFACE_H 1 00005 // ============================================================================ 00006 // Include files 00007 // ============================================================================ 00008 // STD & STL 00009 // ============================================================================ 00010 #include <functional> 00011 // ============================================================================ 00012 // GaudiKernel 00013 // ============================================================================ 00014 #include "GaudiKernel/IInterface.h" 00015 #include "GaudiKernel/SmartIF.h" 00016 // ============================================================================ 00017 // GaudiPython 00018 // ============================================================================ 00019 #include "GaudiPython/GaudiPython.h" 00020 // ============================================================================ 00021 00022 namespace GaudiPython 00023 { 00034 template <class TYPE> 00035 struct Interface /* : 00036 public std::unary_function<const IInterface*,TYPE*> */ 00037 { 00042 TYPE* operator() ( const IInterface* in ) const 00043 { return SmartIF<TYPE>( TYPE::interfaceID() , 00044 const_cast<IInterface*> ( in ) ) ; } 00045 00050 static TYPE* cast ( const IInterface* in ) 00051 { return SmartIF<TYPE>( const_cast<IInterface*> ( in ) ) ; } 00052 00058 static TYPE* cast ( const InterfaceID& iid , 00059 const IInterface* in ) 00060 { return SmartIF<TYPE>( iid , const_cast<IInterface*> ( in ) ) ; } 00061 00062 }; 00063 00064 template <> 00065 struct Interface<IInterface> : 00066 public std::unary_function<const IInterface*,IInterface*> 00067 { 00068 typedef IInterface TYPE ; 00073 TYPE* operator() ( const IInterface* in ) const 00074 { return SmartIF<TYPE>( const_cast<IInterface*> ( in ) ) ; } 00075 00080 static TYPE* cast ( const IInterface* in ) 00081 { return SmartIF<TYPE>( const_cast<IInterface*> ( in ) ) ; } 00082 00088 static TYPE* cast ( const InterfaceID& /* iid */ , 00089 const IInterface* in ) 00090 { return SmartIF<TYPE>( const_cast<IInterface*> ( in ) ) ; } 00091 00092 }; 00093 00094 } ; // end of namespace GaudiPython 00095 00096 #endif // GAUDIPYTHON_INTERFACE_H