The Gaudi Framework  v30r3 (a5ef0a68)
GetAlg.h
Go to the documentation of this file.
1 #ifndef GAUDIALG_GETALG_H
2 #define GAUDIALG_GETALG_H 1
3 // ============================================================================
4 // Include files
5 // ============================================================================
6 #include <type_traits>
7 // ============================================================================
8 // GaudiKernel
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() = default;
33  };
34  // ========================================================================
41  template <class TYPE>
43  {
44  public:
46  bool operator()( const IAlgorithm* a ) const override
47  {
48  using TYPE_ = std::decay_t<TYPE>;
49  using CTYPE = std::add_const_t<TYPE_>;
50  using cptr = std::add_pointer_t<CTYPE>;
51  return dynamic_cast<cptr>( a );
52  }
53  };
54  // ========================================================================
62  {
63  public:
64  AlgNameSelector() = delete;
66  AlgNameSelector( std::string name ) : m_name( std::move( name ) ) {}
68  bool operator()( const IAlgorithm* a ) const override { return a && a->name() == m_name; }
69 
70  private:
71  // algorithm name
73  };
74  // ========================================================================
75  } // end of namespace Gaudi::Utils
76 } // end of namespace Gaudi
77 // ============================================================================
78 namespace Gaudi
79 {
80  namespace Utils
81  {
82  // ========================================================================
106  // ========================================================================
130  // ========================================================================
131  } // end of namespace Gaudi::Utils
132 } // end of namespace Gaudi
133 // ============================================================================
134 // The END
135 // ============================================================================
136 #endif // GAUDIALG_GETALG_H
The trivial selector of algorithm by type.
Definition: GetAlg.h:61
sel
Definition: IOTest.py:95
STL namespace.
bool operator()(const IAlgorithm *a) const override
the only one essential method:
Definition: GetAlg.h:46
STL class.
GAUDI_API IAlgorithm * getAlgorithm(const IAlgContextSvc *svc, const AlgSelector &sel)
simple function to get the algorithm from Context Service
Definition: GetAlg.cpp:24
bool operator()(const IAlgorithm *a) const override
the only one essential method:
Definition: GetAlg.h:68
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:28
The trivial selector of algorithm by type.
Definition: GetAlg.h:42
AlgNameSelector(std::string name)
constructor form the name
Definition: GetAlg.h:66
virtual Out operator()(const vector_of_const_< In > &inputs) const =0
An abstract interface for Algorithm Context Service.
Simple interface class for selection of algorithms.
Definition: GetAlg.h:26
#define GAUDI_API
Definition: Kernel.h:104
Helper functions to set/get the application return code.
Definition: __init__.py:1
std::string m_name
algorithm name
Definition: GetAlg.h:72