The Gaudi Framework
v36r9p1 (5c15b2bb)
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
// ========================================================================
34
class
GAUDI_API
AlgSelector
{
35
public
:
37
virtual
bool
operator()
(
const
IAlgorithm
* )
const
= 0;
38
// virtual destructor
39
virtual
~AlgSelector
() =
default
;
40
};
41
// ========================================================================
48
template
<
class
TYPE>
49
class
GAUDI_API
AlgTypeSelector
:
public
AlgSelector
{
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
// ========================================================================
66
class
GAUDI_API
AlgNameSelector
:
public
AlgSelector
{
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
76
std::string
m_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
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
TimingHistograms.name
name
Definition:
TimingHistograms.py:25
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:109
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.
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
GaudiAlg
include
GaudiAlg
GetAlg.h
Generated on Fri Feb 3 2023 18:02:51 for The Gaudi Framework by
1.8.18