| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

GetAlgs.cpp

Go to the documentation of this file.
00001 // $Id: GetAlgs.cpp,v 1.1 2007/09/25 16:12:41 marcocle Exp $
00002 // ============================================================================
00003 // Include files
00004 // ============================================================================
00005 // STD&STL
00006 // ============================================================================
00007 #include <algorithm>
00008 #include <functional>
00009 // ============================================================================
00010 // GaudiKernel
00011 // ============================================================================
00012 #include "GaudiKernel/IAlgContextSvc.h"
00013 #include "GaudiKernel/IAlgorithm.h"
00014 // ============================================================================
00015 // GaudiAlg 
00016 // ============================================================================
00017 #include "GaudiAlg/GetAlg.h"
00018 #include "GaudiAlg/GetAlgs.h"
00019 // ============================================================================
00020 #include "GaudiAlg/GaudiAlgorithm.h"
00021 #include "GaudiAlg/GaudiHistoAlg.h"
00022 #include "GaudiAlg/GaudiTupleAlg.h"
00023 #include "GaudiAlg/GaudiSequencer.h"
00024 #include "GaudiAlg/Sequencer.h"
00025 // ============================================================================
00031 // ============================================================================
00032 namespace 
00033 {
00034   template <class TYPE>
00035   TYPE* getAlg (  const IAlgContextSvc* svc ) 
00036   {
00037     if ( 0 == svc            ) { return 0 ; }  // RETURN
00038     typedef IAlgContextSvc::Algorithms ALGS ;
00039     const ALGS& algs = svc->algorithms() ;
00040     ALGS::const_reverse_iterator it = std::find_if 
00041       ( algs.rbegin ()                        , 
00042         algs.rend   ()                        , 
00043         Gaudi::Utils::AlgTypeSelector<TYPE>() ) ;
00044     if ( algs.rend() == it  ) { return 0 ; }  // RETURN 
00045     IAlgorithm* alg = *it ;
00046     return dynamic_cast<TYPE*>(  alg ) ;      // RETURN
00047   }
00048 }
00049 // ============================================================================
00050 /*  simple function to extract the last active
00051  *   GaudiAlgorithm from the context
00052  *
00053  *  @code 
00054  * 
00055  *  // get the context service:
00056  *  const IAlgContextSvc* svc = ... ;
00057  *  
00058  *  GaudiAlgorithm* ga = getGaudiAlg ( svc ) ;
00059  *
00060  *  @endcode 
00061  * 
00062  *  @author Vanya BELYAEV ibelyaev@physics.syr.edu
00063  *  @date 2007-09-07
00064  */
00065 // ============================================================================
00066 GaudiAlgorithm* 
00067 Gaudi::Utils::getGaudiAlg       ( const IAlgContextSvc* svc ) 
00068 { return getAlg<GaudiAlgorithm> ( svc ) ; }
00069 // ============================================================================
00070 /*  simple function to extract the last active
00071  *   GaudiHistoAlg from the context
00072  *
00073  *  @code 
00074  * 
00075  *  // get the context service:
00076  *  const IAlgContextSvc* svc = ... ;
00077  *  
00078  *  GaudiHistoAlg* ha = getHistoAlg ( svc ) ;
00079  *
00080  *  @endcode 
00081  * 
00082  *  @author Vanya BELYAEV ibelyaev@physics.syr.edu
00083  *  @date 2007-09-07
00084  */
00085 // ============================================================================
00086 GaudiHistoAlg*  
00087 Gaudi::Utils::getHistoAlg       ( const IAlgContextSvc* svc ) 
00088 { return getAlg<GaudiHistoAlg> ( svc ) ; }
00089 // ============================================================================
00090 /* simple function to extract the last active
00091  *   GaudiTupleAlg from the context
00092  *
00093  *  @code 
00094  * 
00095  *  // get the context service:
00096  *  const IAlgContextSvc* svc = ... ;
00097  *  
00098  *  GaudiTupleAlg* ta = getTupleAlg ( svc ) ;
00099  *
00100  *  @endcode 
00101  * 
00102  *  @author Vanya BELYAEV ibelyaev@physics.syr.edu
00103  *  @date 2007-09-07
00104  */
00105 // ============================================================================
00106 GaudiTupleAlg*  
00107 Gaudi::Utils::getTupleAlg       ( const IAlgContextSvc* svc )
00108 { return getAlg<GaudiTupleAlg> ( svc ) ; }
00109 // ============================================================================
00110 /*  simple function to extract the last active
00111  *   GaudiSequencer from the context
00112  *
00113  *  @code 
00114  * 
00115  *  // get the context service:
00116  *  const IAlgContextSvc* svc = ... ;
00117  *  
00118  *  GaudiSequencer* sa = getGaudiSequencer ( svc ) ;
00119  *
00120  *  @endcode 
00121  * 
00122  *  @author Vanya BELYAEV ibelyaev@physics.syr.edu
00123  *  @date 2007-09-07
00124  */
00125 // ============================================================================
00126 GaudiSequencer* 
00127 Gaudi::Utils::getGaudiSequencer ( const IAlgContextSvc* svc ) 
00128 { return getAlg<GaudiSequencer> ( svc ) ; }
00129 // ============================================================================
00130 /* simple function to extract the last active
00131  *   Sequencer from the context
00132  *
00133  *  @code 
00134  * 
00135  *  // get the context service:
00136  *  const IAlgContextSvc* svc = ... ;
00137  *  
00138  *  Sequencer* sa = getSequencerAlg ( svc ) ;
00139  *
00140  *  @endcode 
00141  * 
00142  *  @author Vanya BELYAEV ibelyaev@physics.syr.edu
00143  *  @date 2007-09-07
00144  */
00145 Sequencer*      
00146 Gaudi::Utils::getSequencerAlg   ( const IAlgContextSvc* svc ) 
00147 { return getAlg<Sequencer> ( svc ) ; }
00148 // ========================================================================
00149 /* simple function to extract the last active
00150  *   "Sequencer" () GaudiSequencer or Sequencer) 
00151  *   from the context
00152  *
00153  *  @code 
00154  * 
00155  *  // get the context service:
00156  *  const IAlgContextSvc* svc = ... ;
00157  *  
00158  *  IAlgorithm* a = getSequencer ( svc ) ;
00159  *
00160  *  @endcode 
00161  * 
00162  *  @author Vanya BELYAEV ibelyaev@physics.syr.edu
00163  *  @date 2007-09-07
00164  */
00165 // ========================================================================
00166 IAlgorithm*     
00167 Gaudi::Utils::getSequencer ( const IAlgContextSvc* svc ) 
00168 {
00169   if ( 0 == svc            ) { return 0 ; }  // RETURN
00170   //
00171   typedef IAlgContextSvc::Algorithms ALGS ;
00172   const ALGS& algs = svc->algorithms() ;
00173   AlgTypeSelector<GaudiSequencer> sel1 ;
00174   AlgTypeSelector<Sequencer>      sel2 ;
00175   for ( ALGS::const_reverse_iterator it = algs.rbegin() ; 
00176         algs.rend() != it ; ++it ) 
00177   {
00178     if ( sel1 ( *it ) ) { return *it ; }
00179     if ( sel2 ( *it ) ) { return *it ; }
00180   }
00181   return 0 ;                                    // RETURN ;
00182 }
00183 // ========================================================================
00184 
00185 
00186 // ============================================================================
00187 // The END 
00188 // ============================================================================
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 19:58:14 2011 for GaudiAlg by doxygen 1.4.7