Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
fhiclcpp
fhiclcpp
types
OptionalTableAs.h
Go to the documentation of this file.
1
#ifndef fhiclcpp_types_OptionalTableAs_h
2
#define fhiclcpp_types_OptionalTableAs_h
3
4
#include "
fhiclcpp/type_traits.h
"
5
#include "
fhiclcpp/types/ConfigPredicate.h
"
6
#include "
fhiclcpp/types/OptionalTable.h
"
7
#include "
fhiclcpp/types/detail/ParameterBase.h
"
8
#include "
fhiclcpp/types/detail/type_traits_error_msgs.h
"
9
10
#include <memory>
11
#include <string>
12
#include <utility>
13
14
namespace
fhicl
{
15
16
//==================================================================
17
// e.g. OptionalTableAs<T, Config> ====> T as created by convert(Config)
18
//
19
template
<
typename
T,
typename
Config>
20
class
OptionalTableAs {
21
public
:
22
explicit
OptionalTableAs
(
Name
&&
name
);
23
explicit
OptionalTableAs
(
Name
&&
name
,
Comment
&&
comment
);
24
explicit
OptionalTableAs
(
Name
&&
name
,
25
Comment
&&
comment
,
26
std::function
<
bool
()> maybeUse);
27
28
std::optional<T>
29
operator()
()
const
30
{
31
if
(
auto
via =
tableObj_
()) {
32
return
std::make_optional(
convert
(*via));
33
}
34
return
std::nullopt;
35
}
36
37
// Obsolete
38
bool
39
operator()
(
T
&
result
)
const
40
{
41
auto
t
=
operator()
();
42
if
(
t
) {
43
result = *
t
;
44
}
45
return
t
.has_value();
46
}
47
48
bool
49
hasValue
()
const
50
{
51
return
tableObj_
.
hasValue
();
52
}
53
54
private
:
55
OptionalTable<Config>
tableObj_
;
56
57
Comment
58
conversion_comment
(
Comment
&&
comment
)
const
59
{
60
std::string
const
preface =
61
"N.B. The following table is converted to type:"
;
62
std::string
const
name
=
63
" '"
+ cet::demangle_symbol(
typeid
(
T
).
name
()) +
"'"
;
64
std::string
const
user_comment =
65
comment
.value.empty() ?
""
:
"\n\n"
+
comment
.value;
66
67
std::ostringstream oss;
68
oss << preface <<
'\n'
<< name << user_comment;
69
70
return
Comment
{oss.str().c_str()};
71
}
72
};
73
74
//==================================================================
75
// IMPLEMENTATION
76
77
template
<
typename
T,
typename
Config>
78
OptionalTableAs<T, Config>::OptionalTableAs
(
Name
&&
name
)
79
:
OptionalTableAs
{
std::move
(
name
),
Comment
(
""
)}
80
{}
81
82
template
<
typename
T,
typename
Config>
83
OptionalTableAs<T, Config>::OptionalTableAs
(
Name
&&
name
,
Comment
&&
comment
)
84
:
tableObj_
{
std::move
(
name
),
conversion_comment
(
std::move
(
comment
))}
85
{}
86
87
template
<
typename
T,
typename
Config>
88
OptionalTableAs<T, Config>::OptionalTableAs
(
Name
&&
name
,
89
Comment
&&
comment
,
90
std::function
<
bool
()> maybeUse)
91
:
tableObj_
{
std::move
(
name
),
92
conversion_comment
(
std::move
(
comment
)),
93
maybeUse}
94
{}
95
}
96
97
#endif
/* fhiclcpp_types_OptionalTableAs_h */
98
99
// Local variables:
100
// mode: c++
101
// End:
name
static QCString name
Definition:
declinfo.cpp:673
type_traits_error_msgs.h
result
static QCString result
Definition:
fortranscanner.cpp:56614
string
std::string string
Definition:
nybbler.cc:12
ParameterBase.h
Name
ChannelGroupService::Name Name
Definition:
FixedChannelGroupService_service.cc:19
fhicl::OptionalTableAs::conversion_comment
Comment conversion_comment(Comment &&comment) const
Definition:
OptionalTableAs.h:58
ValidateOpDetSimulation.T
T
Definition:
ValidateOpDetSimulation.py:52
fhicl::OptionalTable< Config >
comment
int comment
Definition:
tclscanner.cpp:1125
OptionalTable.h
fhicl::OptionalTableAs::tableObj_
OptionalTable< Config > tableObj_
Definition:
OptionalTableAs.h:55
fhicl::OptionalTableAs::OptionalTableAs
OptionalTableAs(Name &&name)
Definition:
OptionalTableAs.h:78
fhicl::OptionalTableAs::hasValue
bool hasValue() const
Definition:
OptionalTableAs.h:49
fhicl
Definition:
InputSourceFactory.h:7
reco_momentum_tuples.t
t
Definition:
reco_momentum_tuples.py:25
wirecell.gen.depos.move
def move(depos, offset)
Definition:
depos.py:107
wirecell.sigproc.garfield.convert
def convert(inputfile, outputfile="wire-cell-garfield-fine-response.json.bz2", average=False, shaped=False)
Definition:
garfield.py:262
fhicl::OptionalTableAs::operator()
bool operator()(T &result) const
Definition:
OptionalTableAs.h:39
ConfigPredicate.h
Comment
#define Comment
Definition:
commentscan.cpp:4062
fhicl::OptionalTableAs
Definition:
type_traits.h:55
fhicl::OptionalTableAs::operator()
std::optional< T > operator()() const
Definition:
OptionalTableAs.h:29
fhicl::OptionalTable::hasValue
bool hasValue() const
Definition:
OptionalTable.h:62
function
void function(int client, int *resource, int parblock, int *test, int p)
fhicl::Comment
Definition:
Comment.h:33
type_traits.h
fhicl::Name
Definition:
Name.h:10
Generated by
1.8.11