| The Gaudi Framework v29r1 (5cd95fa2)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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 // ========================================================================
26 class GAUDI_API AlgSelector
27 {
28 public:
30 virtual bool operator()( const IAlgorithm* ) const = 0;
31 // virtual destructor
32 virtual ~AlgSelector() = default;
33 };
34 // ========================================================================
41 template <class TYPE>
42 class GAUDI_API AlgTypeSelector : public AlgSelector
43 {
44 public:
46 bool operator()( const IAlgorithm* a ) const override
47 {
48 using TYPE_ = typename std::decay<TYPE>::type;
49 using CTYPE = typename std::add_const<TYPE_>::type;
50 using cptr = typename std::add_pointer<CTYPE>::type;
51 return dynamic_cast<cptr>( a );
52 }
53 };
54 // ========================================================================
61 class GAUDI_API AlgNameSelector : public AlgSelector
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
72 std::string m_name;
73 };
74 // ========================================================================
75 } // end of namespace Gaudi::Utils
76 } // end of namespace Gaudi
77 // ============================================================================
78 namespace Gaudi
79 {
80 namespace Utils
81 {
82 // ========================================================================
105 GAUDI_API IAlgorithm* getAlgorithm( const IAlgContextSvc* svc, const AlgSelector& sel );
106 // ========================================================================
129 GAUDI_API IAlgorithm* getAlgorithm( const std::vector<IAlgorithm*>& lst, const AlgSelector& sel );
130 // ========================================================================
131 } // end of namespace Gaudi::Utils
132 } // end of namespace Gaudi
133 // ============================================================================
134 // The END
135 // ============================================================================
136 #endif // GAUDIALG_GETALG_H
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:32
Gaudi::Utils::AlgNameSelector
The trivial selector of algorithm by type.
Definition: GetAlg.h:61
IAlgorithm.h
std::add_pointer
IOTest.sel
sel
Definition: IOTest.py:95
std
STL namespace.
Gaudi::Utils::AlgTypeSelector::operator()
bool operator()(const IAlgorithm *a) const override
the only one essential method:
Definition: GetAlg.h:46
std::type_info
std::string
STL class.
Gaudi::Utils::getAlgorithm
GAUDI_API IAlgorithm * getAlgorithm(const IAlgContextSvc *svc, const AlgSelector &sel)
simple function to get the algorithm from Context Service
Definition: GetAlg.cpp:24
Gaudi::Utils::AlgNameSelector::operator()
bool operator()(const IAlgorithm *a) const override
the only one essential method:
Definition: GetAlg.h:68
IAlgorithm
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:28
Gaudi::Utils::AlgTypeSelector
The trivial selector of algorithm by type.
Definition: GetAlg.h:42
std::add_const
Gaudi::Utils::AlgNameSelector::AlgNameSelector
AlgNameSelector(std::string name)
constructor form the name
Definition: GetAlg.h:66
std::vector< IAlgorithm * >
Gaudi::Functional::operator()
virtual Out operator()(const vector_of_const_< In > &inputs) const =0
IAlgContextSvc
An abstract interface for Algorithm Context Service.
Definition: IAlgContextSvc.h:23
Gaudi::Utils::AlgSelector
Simple interface class for selection of algorithms.
Definition: GetAlg.h:26
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:110
std::decay
Gaudi
Helper functions to set/get the application return code.
Definition: __init__.py:1
Gaudi::Utils::AlgNameSelector::m_name
std::string m_name
algorithm name
Definition: GetAlg.h:72