Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v31r0 (aeb156f0)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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  namespace Utils {
18  // ========================================================================
25  public:
27  virtual bool operator()( const IAlgorithm* ) const = 0;
28  // virtual destructor
29  virtual ~AlgSelector() = default;
30  };
31  // ========================================================================
38  template <class TYPE>
40  public:
42  bool operator()( const IAlgorithm* a ) const override {
43  using TYPE_ = std::decay_t<TYPE>;
44  using CTYPE = std::add_const_t<TYPE_>;
45  using cptr = std::add_pointer_t<CTYPE>;
46  return dynamic_cast<cptr>( a );
47  }
48  };
49  // ========================================================================
57  public:
58  AlgNameSelector() = delete;
60  AlgNameSelector( std::string name ) : m_name( std::move( name ) ) {}
62  bool operator()( const IAlgorithm* a ) const override { return a && a->name() == m_name; }
63 
64  private:
65  // algorithm name
67  };
68  // ========================================================================
69  } // namespace Utils
70 } // end of namespace Gaudi
71 // ============================================================================
72 namespace Gaudi {
73  namespace Utils {
74  // ========================================================================
98  // ========================================================================
122  // ========================================================================
123  } // namespace Utils
124 } // end of namespace Gaudi
125 // ============================================================================
126 // The END
127 // ============================================================================
128 #endif // GAUDIALG_GETALG_H
The trivial selector of algorithm by type.
Definition: GetAlg.h:56
sel
Definition: IOTest.py:93
STL namespace.
bool operator()(const IAlgorithm *a) const override
the only one essential method:
Definition: GetAlg.h:42
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:62
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:39
AlgNameSelector(std::string name)
constructor form the name
Definition: GetAlg.h:60
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:24
#define GAUDI_API
Definition: Kernel.h:71
Helper functions to set/get the application return code.
Definition: __init__.py:1
std::string m_name
algorithm name
Definition: GetAlg.h:66