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 {
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  { using TYPE_ = typename std::decay<TYPE>::type;
48  using CTYPE = typename std::add_const<TYPE_>::type;
49  using cptr = typename std::add_pointer<CTYPE>::type;
50  return dynamic_cast<cptr>( a ); }
51  } ;
52  // ========================================================================
60  {
61  public:
62  AlgNameSelector() = delete ;
64  AlgNameSelector ( std::string name ) : m_name ( std::move(name) ) {}
66  bool operator() ( const IAlgorithm* a ) const override
67  { return a && a->name() == m_name; }
68  private:
69  // algorithm name
71  } ;
72  // ========================================================================
73  } // end of namespace Gaudi::Utils
74 } // end of namespace Gaudi
75 // ============================================================================
76 namespace Gaudi
77 {
78  namespace Utils
79  {
80  // ========================================================================
104  ( const IAlgContextSvc* svc ,
105  const AlgSelector& sel ) ;
106  // ========================================================================
130  ( const std::vector<IAlgorithm*>& lst ,
131  const AlgSelector& sel ) ;
132  // ========================================================================
133  } // end of namespace Gaudi::Utils
134 } // end of namespace Gaudi
135 // ============================================================================
136 // The END
137 // ============================================================================
138 #endif // GAUDIALG_GETALG_H
The trivial selector of algorithm by type.
Definition: GetAlg.h:59
sel
Definition: IOTest.py:84
STL namespace.
STL class.
GAUDI_API IAlgorithm * getAlgorithm(const IAlgContextSvc *svc, const AlgSelector &sel)
simple function to get the algorithm from Context Service
Definition: GetAlg.cpp:26
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:27
The trivial selector of algorithm by type.
Definition: GetAlg.h:42
AlgNameSelector(std::string name)
constructor form the name
Definition: GetAlg.h:64
An abstract interface for Algorithm Context Service.
Simple interface class for selection of algorithms.
Definition: GetAlg.h:26
#define GAUDI_API
Definition: Kernel.h:107
Helper functions to set/get the application return code.
Definition: __init__.py:1
std::string m_name
algorithm name
Definition: GetAlg.h:70