Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
fhiclcpp
fhiclcpp
types
OptionalDelegatedParameter.h
Go to the documentation of this file.
1
#ifndef fhiclcpp_types_OptionalDelegatedParameter_h
2
#define fhiclcpp_types_OptionalDelegatedParameter_h
3
4
#include "
fhiclcpp/ParameterSet.h
"
5
#include "
fhiclcpp/types/Comment.h
"
6
#include "
fhiclcpp/types/Name.h
"
7
#include "
fhiclcpp/types/detail/DelegateBase.h
"
8
#include "
fhiclcpp/types/detail/ParameterArgumentTypes.h
"
9
#include "
fhiclcpp/types/detail/TableMemberRegistry.h
"
10
#include "
fhiclcpp/types/detail/strip_containing_names.h
"
11
12
#include <functional>
13
#include <optional>
14
15
namespace
fhicl
{
16
17
//========================================================
18
class
OptionalDelegatedParameter
final
19
:
public
detail::DelegateBase
,
20
private
detail::RegisterIfTableMember
{
21
public
:
22
explicit
OptionalDelegatedParameter
(
Name
&&
name
);
23
explicit
OptionalDelegatedParameter
(
Name
&&
name
,
Comment
&&
comment
);
24
explicit
OptionalDelegatedParameter
(
Name
&&
name
,
25
Comment
&&
comment
,
26
std::function
<
bool
()> maybeUse);
27
bool
28
hasValue
()
const
29
{
30
return
pset_
&&
31
pset_
->has_key(
detail::strip_first_containing_name
(
key
()));
32
}
33
34
template
<
typename
T>
35
std::optional<T>
36
get_if_present
()
const
37
{
38
if
(not
pset_
) {
39
return
std::nullopt;
40
}
41
42
auto
const
trimmed_key =
detail::strip_first_containing_name
(
key
());
43
return
pset_->get_if_present<
T
>(trimmed_key);
44
}
45
46
// Obsolete interface
47
template
<
typename
T>
48
bool
49
get_if_present
(
T
&
t
)
const
50
{
51
if
(
auto
result
= get_if_present<T>()) {
52
t = *
result
;
53
return
true
;
54
}
55
return
false
;
56
}
57
58
private
:
59
void
60
do_set_value
(
fhicl::ParameterSet
const
& pset)
override
61
{
62
pset_
= std::make_optional(pset);
63
};
64
65
std::optional<ParameterSet>
pset_
{std::nullopt};
66
};
67
}
68
69
#endif
/* fhiclcpp_types_OptionalDelegatedParameter_h */
70
71
// Local variables:
72
// mode: c++
73
// End:
fhicl::OptionalDelegatedParameter::get_if_present
std::optional< T > get_if_present() const
Definition:
OptionalDelegatedParameter.h:36
fhicl::detail::ParameterBase::name
std::string const & name() const
Definition:
ParameterBase.h:43
fhicl::detail::DelegateBase
Definition:
DelegateBase.h:8
TableMemberRegistry.h
result
static QCString result
Definition:
fortranscanner.cpp:56614
strip_containing_names.h
ValidateOpDetSimulation.T
T
Definition:
ValidateOpDetSimulation.py:52
Comment.h
ParameterSet.h
fhicl::detail::strip_first_containing_name
std::string strip_first_containing_name(std::string const &key)
Definition:
strip_containing_names.cc:7
fhicl::OptionalDelegatedParameter
Definition:
OptionalDelegatedParameter.h:18
fhicl::OptionalDelegatedParameter::do_set_value
void do_set_value(fhicl::ParameterSet const &pset) override
Definition:
OptionalDelegatedParameter.h:60
DelegateBase.h
fhicl::detail::RegisterIfTableMember
Definition:
TableMemberRegistry.h:103
fhicl
Definition:
InputSourceFactory.h:7
reco_momentum_tuples.t
t
Definition:
reco_momentum_tuples.py:25
fhicl::OptionalDelegatedParameter::pset_
std::optional< ParameterSet > pset_
Definition:
OptionalDelegatedParameter.h:65
fhicl::detail::ParameterBase::key
std::string const & key() const
Definition:
ParameterBase.h:38
fhicl::OptionalDelegatedParameter::OptionalDelegatedParameter
OptionalDelegatedParameter(Name &&name)
Definition:
OptionalDelegatedParameter.cc:7
fhicl::OptionalDelegatedParameter::get_if_present
bool get_if_present(T &t) const
Definition:
OptionalDelegatedParameter.h:49
ParameterArgumentTypes.h
fhicl::OptionalDelegatedParameter::hasValue
bool hasValue() const
Definition:
OptionalDelegatedParameter.h:28
fhicl::detail::ParameterBase::comment
std::string const & comment() const
Definition:
ParameterBase.h:48
function
void function(int client, int *resource, int parblock, int *test, int p)
fhicl::Comment
Definition:
Comment.h:33
fhicl::Name
Definition:
Name.h:10
Name.h
fhicl::ParameterSet
Definition:
ParameterSet.h:36
Generated by
1.8.11