Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v38r0 (2143aa4c)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
GetAlg.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #ifndef GAUDIALG_GETALG_H
12 #define GAUDIALG_GETALG_H 1
13 // ============================================================================
14 // Include files
15 // ============================================================================
16 #include <type_traits>
17 // ============================================================================
18 // GaudiKernel
19 // ============================================================================
20 #include "GaudiKernel/IAlgorithm.h"
21 // ============================================================================
22 // forward declarations
23 // ============================================================================
24 class IAlgContextSvc;
25 // ============================================================================
26 namespace Gaudi {
27  namespace Utils {
28  // ========================================================================
35  public:
37  virtual bool operator()( const IAlgorithm* ) const = 0;
38  // virtual destructor
39  virtual ~AlgSelector() = default;
40  };
41  // ========================================================================
48  template <class TYPE>
50  public:
52  bool operator()( const IAlgorithm* a ) const override {
53  using TYPE_ = std::decay_t<TYPE>;
54  using CTYPE = std::add_const_t<TYPE_>;
55  using cptr = std::add_pointer_t<CTYPE>;
56  return dynamic_cast<cptr>( a );
57  }
58  };
59  // ========================================================================
67  public:
68  AlgNameSelector() = delete;
70  AlgNameSelector( std::string name ) : m_name( std::move( name ) ) {}
72  bool operator()( const IAlgorithm* a ) const override { return a && a->name() == m_name; }
73 
74  private:
75  // algorithm name
77  };
78  // ========================================================================
79  } // namespace Utils
80 } // end of namespace Gaudi
81 // ============================================================================
82 namespace Gaudi {
83  namespace Utils {
84  // ========================================================================
107  GAUDI_API IAlgorithm* getAlgorithm( const IAlgContextSvc* svc, const AlgSelector& sel );
108  // ========================================================================
131  GAUDI_API IAlgorithm* getAlgorithm( const std::vector<IAlgorithm*>& lst, const AlgSelector& sel );
132  // ========================================================================
133  } // namespace Utils
134 } // end of namespace Gaudi
135 // ============================================================================
136 // The END
137 // ============================================================================
138 #endif // GAUDIALG_GETALG_H
std::string
STL class.
Gaudi::Utils::AlgSelector::operator()
virtual bool operator()(const IAlgorithm *) const =0
the only one essential method:
Gaudi::Utils::AlgSelector::~AlgSelector
virtual ~AlgSelector()=default
bug_34121.name
name
Definition: bug_34121.py:20
Gaudi::Utils::AlgTypeSelector
Definition: GetAlg.h:49
Gaudi::Utils::AlgNameSelector::AlgNameSelector
AlgNameSelector(std::string name)
constructor form the name
Definition: GetAlg.h:70
std::vector< IAlgorithm * >
std::type_info
Gaudi::Utils::AlgNameSelector::AlgNameSelector
AlgNameSelector()=delete
Gaudi::Utils::AlgTypeSelector::operator()
bool operator()(const IAlgorithm *a) const override
the only one essential method:
Definition: GetAlg.h:52
IAlgorithm
Definition: IAlgorithm.h:38
Gaudi::Utils::AlgSelector
Definition: GetAlg.h:34
Gaudi::Utils::AlgNameSelector
Definition: GetAlg.h:66
Gaudi
Header file for std:chrono::duration-based Counters.
Definition: __init__.py:1
IOTest.sel
sel
Definition: IOTest.py:104
Gaudi::Utils::AlgNameSelector::operator()
bool operator()(const IAlgorithm *a) const override
the only one essential method:
Definition: GetAlg.h:72
Gaudi::Utils::AlgNameSelector::m_name
std::string m_name
algorithm name
Definition: GetAlg.h:76
std
STL namespace.
GaudiPartProp.tests.lst
lst
Definition: tests.py:37
IAlgContextSvc
Definition: IAlgContextSvc.h:33
IAlgorithm.h
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:34
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:81