Gaudi Framework, version v23r4

Home   Generated: Mon Sep 17 2012

AlgDecorators.cpp

Go to the documentation of this file.
00001 // $Id: AlgDecorators.cpp,v 1.2 2005/11/08 16:31:03 mato Exp $
00002 // ============================================================================
00003 // Include files 
00004 // ============================================================================
00005 // GaudiKernel
00006 // ============================================================================
00007 #include "GaudiKernel/IInterface.h"
00008 #include "GaudiKernel/IProperty.h"
00009 #include "GaudiKernel/IAlgorithm.h"
00010 #include "GaudiKernel/IAlgTool.h"
00011 #include "GaudiKernel/SmartIF.h"
00012 #include "GaudiKernel/DataObject.h"
00013 // ============================================================================
00014 // GaudiAlg 
00015 // ============================================================================
00016 #include "GaudiAlg/GaudiAlgorithm.h"
00017 #include "GaudiAlg/GaudiTool.h"
00018 // ============================================================================
00019 // GaudiPython
00020 // ============================================================================
00021 #include "GaudiPython/AlgDecorators.h"
00022 // ============================================================================
00028 // ============================================================================
00029 /*  get the tool from GaudiAlgorithm
00030  *  @param alg GaudiAlgorithm
00031  *  @param type tool type
00032  *  @param name tool name 
00033  *  @param parent tool parent 
00034  *  @param create flag to create 
00035  *  @return the tool 
00036  */
00037 // ============================================================================
00038 IAlgTool* GaudiPython::AlgDecorator::tool_
00039 ( const GaudiAlgorithm* alg    ,
00040   const std::string&    type   , 
00041   const std::string&    name   , 
00042   const IInterface*     parent , 
00043   const bool            create ) 
00044 {
00045   if ( 0 == alg ) { return 0 ; }
00046   return alg -> tool<IAlgTool> ( type , name , parent , create ) ;
00047 }
00048 // ============================================================================
00049 /*  get the tool from GaudiAlgorithm
00050  *  @param alg GaudiAlgorithm
00051  *  @param typeAndName tool type/name 
00052  *  @param parent tool parent 
00053  *  @param create flag to create 
00054  *  @return the tool 
00055  */
00056 // ============================================================================
00057 IAlgTool* GaudiPython::AlgDecorator::tool_
00058 ( const GaudiAlgorithm* alg         ,
00059   const std::string&    typeAndName , 
00060   const IInterface*     parent      , 
00061   const bool            create      ) 
00062 {
00063   if ( 0 == alg ) { return 0 ; }
00064   return alg->tool<IAlgTool>( typeAndName , parent , create ) ;
00065 }
00066 // ============================================================================
00067 /*  get the service from GaudiAlgorithm
00068  *  @param alg GaudiAlgorithm
00069  *  @param name service name 
00070  *  @param create flag to create 
00071  *  @return the tool 
00072  */
00073 // ============================================================================
00074 IInterface* GaudiPython::AlgDecorator::svc_
00075 ( const GaudiAlgorithm* alg    ,
00076   const std::string&    name   ,
00077   const bool            create ) 
00078 {
00079   if ( 0 == alg ) { return 0 ; }
00080   return alg -> svc<IInterface> ( name , create ) ;
00081 }
00082 // ============================================================================
00083 // get all counters form the algorithm
00084 // ============================================================================
00085 size_t GaudiPython::AlgDecorator::_counters_a_
00086 ( const GaudiAlgorithm*                alg   , 
00087   std::vector<std::string>&            names , 
00088   GaudiPython::AlgDecorator::Counters& out   )
00089 {
00090   typedef std::map<std::string,StatEntity> Stats ;
00091   names.clear () ;
00092   out.clear   () ;
00093   if ( 0 == alg ) { return 0 ; }                                      // RETURN 
00094   //
00095   const Stats& counters = alg->counters() ; 
00096   for ( Stats::const_iterator icnt = counters.begin() ; 
00097         counters.end() != icnt ; ++icnt ) 
00098   {
00099     names.push_back (   icnt->first )   ;
00100     out  .push_back ( &(icnt->second) ) ;
00101   }
00102   return out.size() ;
00103 }
00104 // ============================================================================
00105 // get all counters form the tool
00106 // ============================================================================
00107 size_t GaudiPython::AlgDecorator::_counters_t_
00108 ( const GaudiTool*                     alg   , 
00109   std::vector<std::string>&            names , 
00110   GaudiPython::AlgDecorator::Counters& out   )
00111 {
00112   typedef std::map<std::string,StatEntity> Stats ;
00113   names.clear () ;
00114   out.clear   () ;
00115   if ( 0 == alg ) { return 0 ; }                                      // RETURN 
00116   //
00117   const Stats& counters = alg->counters() ; 
00118   for ( Stats::const_iterator icnt = counters.begin() ; 
00119         counters.end() != icnt ; ++icnt ) 
00120   {
00121     names.push_back (   icnt->first )   ;
00122     out  .push_back ( &(icnt->second) ) ;
00123   }
00124   return out.size() ;
00125 }
00126 // ============================================================================
00127 // get all counters form the algorithm
00128 // ============================================================================
00129 size_t GaudiPython::AlgDecorator::_counters_a_
00130 ( const IAlgorithm*                    alg   , 
00131   std::vector<std::string>&            names , 
00132   GaudiPython::AlgDecorator::Counters& out   )
00133 {
00134   names.clear () ;
00135   out.clear   () ;
00136   if ( 0 == alg ) { return 0 ; }                                      // RETURN 
00137   //
00138   return _counters_a_ ( dynamic_cast<const GaudiAlgorithm*>( alg ) , names , out ) ;
00139 }
00140 // ============================================================================
00141 // get all counters form the tool
00142 // ============================================================================
00143 size_t GaudiPython::AlgDecorator::_counters_t_
00144 ( const IAlgTool*                      alg   , 
00145   std::vector<std::string>&            names , 
00146   GaudiPython::AlgDecorator::Counters& out   )
00147 {
00148   names.clear () ;
00149   out.clear   () ;
00150   if ( 0 == alg ) { return 0 ; }                                      // RETURN 
00151   //
00152   return _counters_t_ ( dynamic_cast<const GaudiTool*>( alg ) , names , out ) ;
00153 }
00154 // ============================================================================
00155 // get the counter by name
00156 // ============================================================================
00157 const StatEntity* GaudiPython::AlgDecorator::_counter_a_ 
00158 ( const GaudiAlgorithm* cmp , const std::string& name )
00159 {
00160   if ( 0 == cmp ) { return 0 ; }                                      // RETURN 
00161   return &( cmp -> counter ( name ) ) ;                               // RETURN 
00162 }
00163 // ============================================================================
00164 // get the counter by name
00165 // ============================================================================
00166 const StatEntity* GaudiPython::AlgDecorator::_counter_t_
00167 ( const GaudiTool* cmp , const std::string& name )
00168 {
00169   if ( 0 == cmp ) { return 0 ; }                                      // RETURN 
00170   return &( cmp -> counter ( name ) ) ;                               // RETURN 
00171 }
00172 // ============================================================================
00173 // get the counter by name
00174 // ============================================================================
00175 const StatEntity* GaudiPython::AlgDecorator::_counter_a_ 
00176 ( const IAlgorithm* cmp , const std::string& name )
00177 {
00178   if ( 0 == cmp ) { return 0 ; }                                      // RETURN 
00179   return _counter_a_ ( dynamic_cast<const GaudiAlgorithm*>( cmp ) , name ) ;
00180 }
00181 // ============================================================================
00182 // get the counter by name
00183 // ============================================================================
00184 const StatEntity* GaudiPython::AlgDecorator::_counter_t_ 
00185 ( const IAlgTool* cmp , const std::string& name )
00186 {
00187   if ( 0 == cmp ) { return 0 ; }                                      // RETURN 
00188   return _counter_t_ ( dynamic_cast<const GaudiTool*>( cmp ) , name ) ;
00189 }
00190 // ============================================================================
00191 // get all tools 
00192 // ============================================================================
00193 size_t GaudiPython::AlgDecorator::_tools_a_ 
00194 ( const GaudiAlgorithm* cmp , GaudiPython::AlgDecorator::Tools& tools ) 
00195 {
00196   tools.clear() ;
00197   if ( 0 == cmp ) { return 0 ; }                                      // REUTRN 
00198   tools = cmp->tools() ;
00199   return tools.size() ;                                               // RETURN 
00200 }
00201 // ============================================================================
00202 // get all tools 
00203 // ============================================================================
00204 size_t GaudiPython::AlgDecorator::_tools_t_ 
00205 ( const GaudiTool* cmp , GaudiPython::AlgDecorator::Tools& tools ) 
00206 {
00207   tools.clear() ;
00208   if ( 0 == cmp ) { return 0 ; }                                      // REUTRN 
00209   tools = cmp->tools() ;
00210   return tools.size() ;                                               // RETURN 
00211 }
00212 // ============================================================================
00213 // get all tools 
00214 // ============================================================================
00215 size_t GaudiPython::AlgDecorator::_tools_a_ 
00216 ( const IAlgorithm* cmp , GaudiPython::AlgDecorator::Tools& tools ) 
00217 {
00218   tools.clear() ;
00219   if ( 0 == cmp ) { return 0 ; }                                      // RETURN 
00220   return _tools_a_ ( dynamic_cast<const GaudiAlgorithm*> ( cmp ) , tools ) ;  
00221 }
00222 // ============================================================================
00223 // get all tools 
00224 // ============================================================================
00225 size_t GaudiPython::AlgDecorator::_tools_t_ 
00226 ( const IAlgTool* cmp , GaudiPython::AlgDecorator::Tools& tools ) 
00227 {
00228   tools.clear() ;
00229   if ( 0 == cmp ) { return 0 ; }                                      // RETURN 
00230   return _tools_t_ ( dynamic_cast<const GaudiTool*> ( cmp ) , tools ) ;  
00231 }
00232 // ============================================================================
00233 /*  check the data in Transient Event Store 
00234  *  @param alg          GaudiAlgorithm
00235  *  @param location     data location in TES 
00236  *  @param useRoonInTes flag to respect RootInTes 
00237  *  @return the data 
00238  */
00239 // ============================================================================
00240 bool GaudiPython::AlgDecorator::exist
00241 ( const GaudiAlgorithm*   alg          ,
00242   const std::string&      location     ,
00243   const bool              useRootInTes ) 
00244 {
00245   if ( 0 == alg ) { return false ; } // RETURN
00246   return alg -> exist<DataObject> ( alg->evtSvc() , location , useRootInTes ) ;
00247 }
00248 // ============================================================================
00249 /*  get the data from Transient Event Store 
00250  *  @param alg          GaudiAlgorithm
00251  *  @param location     data location in TES 
00252  *  @param useRoonInTes flag to respect RootInTes 
00253  *  @return the data 
00254  */
00255 // ============================================================================
00256 DataObject* GaudiPython::AlgDecorator::get_
00257 ( const GaudiAlgorithm*   alg          ,
00258   const std::string&      location     ,
00259   const bool              useRootInTes ) 
00260 {
00261   if ( 0 == alg ) { return 0 ; } // RETURN 
00262   return alg->get<DataObject> ( alg->evtSvc() , location , useRootInTes ) ;
00263 }
00264 
00265 
00266 
00267 // ============================================================================
00268 // The END 
00269 // ============================================================================
00270 
00271 
00272 
00273 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines

Generated at Mon Sep 17 2012 13:49:35 for Gaudi Framework, version v23r4 by Doxygen version 1.7.2 written by Dimitri van Heesch, © 1997-2004