All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
GetAlg.h
Go to the documentation of this file.
1 // $Id: GetAlg.h,v 1.2 2007/11/20 13:01:06 marcocle Exp $
2 // ============================================================================
3 #ifndef GAUDIALG_GETALG_H
4 #define GAUDIALG_GETALG_H 1
5 // ============================================================================
6 // Include files
7 // ============================================================================
8 // GaudiKernnel
9 // ============================================================================
10 #include "GaudiKernel/IAlgorithm.h"
11 // ============================================================================
12 // forward declarations
13 // ============================================================================
14 class IAlgContextSvc ;
15 // ============================================================================
16 namespace Gaudi
17 {
18  namespace Utils
19  {
20  // ========================================================================
27  {
28  public:
30  virtual bool operator() ( const IAlgorithm* ) const = 0 ;
31  // virtual destructor
32  virtual ~AlgSelector () ;
33  };
34  // ========================================================================
41  template <class TYPE>
43  {
44  public:
46  virtual bool operator() ( const IAlgorithm* a ) const
47  { return dynamic_cast<const TYPE*>( a ) != 0; }
48  } ;
49  // ========================================================================
50  template <class TYPE>
51  class AlgTypeSelector<TYPE*> : public AlgTypeSelector<TYPE> {} ;
52  // ========================================================================
53  template <class TYPE>
54  class AlgTypeSelector<const TYPE*> : public AlgTypeSelector<TYPE> {} ;
55  // ========================================================================
56  template <class TYPE>
57  class AlgTypeSelector<TYPE&> : public AlgTypeSelector<TYPE> {} ;
58  // ========================================================================
59  template <class TYPE>
60  class AlgTypeSelector<const TYPE&> : public AlgTypeSelector<TYPE> {} ;
61  // ========================================================================
62  template <class TYPE>
63  class AlgTypeSelector<const TYPE> : public AlgTypeSelector<TYPE> {} ;
64  // ========================================================================
72  {
73  public:
75  AlgNameSelector ( const std::string& name ) : m_name ( name ) {}
77  virtual bool operator() ( const IAlgorithm* a ) const
78  { return 0 != a ? a->name() == m_name : false ; }
79  private:
80  // the default constructor is disabled
81  AlgNameSelector() ;
82  private:
83  // algorithm name
84  std::string m_name ;
85  } ;
86  // ========================================================================
87  } // end of namespace Gaudi::Utils
88 } // end of namespace Gaudi
89 // ============================================================================
90 namespace Gaudi
91 {
92  namespace Utils
93  {
94  // ========================================================================
118  ( const IAlgContextSvc* svc ,
119  const AlgSelector& sel ) ;
120  // ========================================================================
144  ( const std::vector<IAlgorithm*>& lst ,
145  const AlgSelector& sel ) ;
146  // ========================================================================
147  } // end of namespace Gaudi::Utils
148 } // end of namespace Gaudi
149 // ============================================================================
150 // The END
151 // ============================================================================
152 #endif // GAUDIALG_GETALG_H
153 // ============================================================================
AlgNameSelector(const std::string &name)
constructor form the name
Definition: GetAlg.h:75
The trivial selector of algorithm by type.
Definition: GetAlg.h:71
virtual const std::string & name() const =0
Retrieve the name of the instance.
GAUDI_API IAlgorithm * getAlgorithm(const IAlgContextSvc *svc, const AlgSelector &sel)
simple function to get the algorithm from Context Service
Definition: GetAlg.cpp:29
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:20
The trivial selector of algorithm by type.
Definition: GetAlg.h:42
An abstract interface for Algorithm Context Service.
Simple interface class for selection of algorithms.
Definition: GetAlg.h:26
This is a number of static methods for bootstrapping the Gaudi framework.
Definition: Bootstrap.h:14
#define GAUDI_API
Definition: Kernel.h:108
std::string m_name
algorithm name
Definition: GetAlg.h:84