00001 // $Id: GetAlg.cpp,v 1.1 2007/09/25 16:12:41 marcocle Exp $ 00002 // ============================================================================ 00003 // Include files 00004 // ============================================================================ 00005 // GaudiKernel 00006 // ============================================================================ 00007 #include "GaudiKernel/IAlgorithm.h" 00008 #include "GaudiKernel/IAlgContextSvc.h" 00009 // ============================================================================ 00010 // GaudiAlg 00011 // ============================================================================ 00012 #include "GaudiAlg/GetAlg.h" 00013 // ============================================================================ 00020 // ============================================================================ 00021 // virtual destructor 00022 // ============================================================================ 00023 Gaudi::Utils::AlgSelector::~AlgSelector(){} 00024 // ============================================================================ 00025 // simple function to get the algorithm from Context Service 00026 // ============================================================================ 00027 IAlgorithm* 00028 Gaudi::Utils::getAlgorithm 00029 ( const IAlgContextSvc* svc , 00030 const AlgSelector& sel ) 00031 { 00032 if ( 0 == svc ) { return 0 ; } // RETURN 00033 return getAlgorithm ( svc->algorithms() , sel ) ; 00034 } 00035 // ============================================================================ 00036 // simple function to get the algorithm from Context Service 00037 // ============================================================================ 00038 IAlgorithm* 00039 Gaudi::Utils::getAlgorithm 00040 ( const std::vector<IAlgorithm*>& lst , 00041 const AlgSelector& sel ) 00042 { 00043 for ( std::vector<IAlgorithm*>::const_reverse_iterator it = lst.rbegin() ; 00044 lst.rend() != it ; ++it ) 00045 { 00046 // use the selector: 00047 if ( sel ( *it ) ) { return *it ; } // return 00048 } 00049 return 0 ; 00050 } 00051 // ============================================================================ 00052 00053 00054 // ============================================================================ 00055 // The END 00056 // ============================================================================