Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
fhiclcpp
fhiclcpp
types
OptionalTupleAs.h
Go to the documentation of this file.
1
#ifndef fhiclcpp_types_OptionalTupleAs_h
2
#define fhiclcpp_types_OptionalTupleAs_h
3
4
#include "
fhiclcpp/type_traits.h
"
5
#include "
fhiclcpp/types/ConfigPredicate.h
"
6
#include "
fhiclcpp/types/OptionalTuple.h
"
7
#include "
fhiclcpp/types/detail/NameStackRegistry.h
"
8
#include "
fhiclcpp/types/detail/ParameterBase.h
"
9
#include "
fhiclcpp/types/detail/type_traits_error_msgs.h
"
10
11
#include <memory>
12
#include <string>
13
#include <tuple>
14
#include <utility>
15
16
namespace
fhicl
{
17
18
//==================================================================
19
// e.g. OptionalTupleAs<T,int,double,bool> ====> T(int,double,bool)
20
//
21
template
<
typename
T
,
typename
... ARGS>
22
class
OptionalTupleAs;
23
24
template
<
typename
T
,
typename
... ARGS>
25
class
OptionalTupleAs
<T(ARGS...)> {
26
public
:
27
explicit
OptionalTupleAs
(
Name
&&
name
);
28
explicit
OptionalTupleAs
(
Name
&&
name
,
Comment
&&
comment
);
29
explicit
OptionalTupleAs
(
Name
&&
name
,
30
Comment
&&
comment
,
31
std::function
<
bool
()> maybeUse);
32
33
std::optional<T>
34
operator()
()
const
35
{
36
if
(
auto
via = tupleObj_()) {
37
return
make_optional(std::make_from_tuple(*via));
38
}
39
return
std::nullopt;
40
}
41
42
// Obsolete
43
bool
44
operator()
(T&
result
)
const
45
{
46
auto
t
= operator()();
47
if
(
t
) {
48
result = *
t
;
49
}
50
return
t
.has_value();
51
}
52
53
bool
54
hasValue
()
const
55
{
56
return
tupleObj_.hasValue();
57
}
58
59
private
:
60
OptionalTuple
<ARGS...>
tupleObj_
;
61
62
Comment
63
conversion_comment
(
Comment
&&
comment
)
const
64
{
65
std::string
const
preface =
66
"N.B. The following sequence is converted to type:"
;
67
std::string
const
name
=
68
" '"
+ cet::demangle_symbol(
typeid
(T).
name
()) +
"'"
;
69
std::string
const
user_comment =
70
comment
.value.empty() ?
""
:
"\n\n"
+
comment
.value;
71
72
std::ostringstream oss;
73
oss << preface <<
'\n'
<< name << user_comment;
74
75
return
Comment
{oss.str().c_str()};
76
}
77
};
78
79
//==================================================================
80
// IMPLEMENTATION
81
82
template
<
typename
T
,
typename
... ARGS>
83
OptionalTupleAs
<
T
(ARGS...)>
::OptionalTupleAs
(
Name
&&
name
)
84
:
OptionalTupleAs
{
std::move
(
name
),
Comment
(
""
)}
85
{}
86
87
template
<
typename
T
,
typename
... ARGS>
88
OptionalTupleAs
<
T
(ARGS...)>
::OptionalTupleAs
(
Name
&&
name
,
Comment
&&
comment
)
89
: tupleObj_{
std::move
(
name
), conversion_comment(
std::move
(
comment
))}
90
{}
91
92
template
<
typename
T
,
typename
... ARGS>
93
OptionalTupleAs
<
T
(ARGS...)>
::OptionalTupleAs
(
Name
&&
name
,
94
Comment
&&
comment
,
95
std::function
<
bool
()> maybeUse)
96
: tupleObj_{
std::move
(
name
),
97
conversion_comment(
std::move
(
comment
)),
98
maybeUse}
99
{}
100
}
101
102
#endif
/* fhiclcpp_types_OptionalTupleAs_h */
103
104
// Local variables:
105
// mode: c++
106
// End:
name
static QCString name
Definition:
declinfo.cpp:673
fhicl::OptionalTupleAs< T(ARGS...)>::hasValue
bool hasValue() const
Definition:
OptionalTupleAs.h:54
fhicl::OptionalTupleAs
Definition:
type_traits.h:50
type_traits_error_msgs.h
result
static QCString result
Definition:
fortranscanner.cpp:56614
string
std::string string
Definition:
nybbler.cc:12
ParameterBase.h
ValidateOpDetSimulation.T
T
Definition:
ValidateOpDetSimulation.py:52
fhicl::OptionalTupleAs< T(ARGS...)>::conversion_comment
Comment conversion_comment(Comment &&comment) const
Definition:
OptionalTupleAs.h:63
comment
int comment
Definition:
tclscanner.cpp:1125
fhicl::OptionalTupleAs< T(ARGS...)>::operator()
bool operator()(T &result) const
Definition:
OptionalTupleAs.h:44
fhicl::OptionalTuple
Definition:
type_traits.h:40
OptionalTuple.h
NameStackRegistry.h
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
fhicl::OptionalTupleAs< T(ARGS...)>::tupleObj_
OptionalTuple< ARGS... > tupleObj_
Definition:
OptionalTupleAs.h:60
ConfigPredicate.h
Comment
#define Comment
Definition:
commentscan.cpp:4062
fhicl::OptionalTupleAs< T(ARGS...)>::operator()
std::optional< T > operator()() const
Definition:
OptionalTupleAs.h:34
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