1 #ifndef fhiclcpp_types_OptionalSequence_h 2 #define fhiclcpp_types_OptionalSequence_h 18 #include <type_traits> 28 template <
typename T, std::size_t
N = -1ull>
29 class OptionalSequence final :
public detail::SequenceBase,
30 private detail::RegisterIfTableMember {
36 using ftype = std::array<std::shared_ptr<tt::fhicl_type<T>>, N>;
45 std::optional<value_type>
51 if (
auto value = std::get_if<value_type>(&
value_)) {
52 return std::make_optional(*
value);
58 [](
auto const& elem) {
return (*elem)(); });
59 return std::make_optional(
std::move(result));
80 std::variant<ftype, value_type>
value_;
86 if (
auto value = std::get_if<value_type>(&value_)) {
123 template <
typename T>
132 using ftype = std::vector<std::shared_ptr<tt::fhicl_type<T>>>;
141 std::optional<value_type>
147 if (
auto value = std::get_if<value_type>(&
value_)) {
153 std::back_inserter(result),
154 [](
auto const& elem) {
return (*elem)(); });
155 return std::make_optional(
std::move(result));
162 if (
auto result =
operator()()) {
185 if (n <
value.size()) {
187 }
else if (n >
value.size()) {
195 std::size_t
const pos =
196 key_fragment.find(current_stem) != std::string::npos ?
197 current_stem.size() + 1ul :
199 key_fragment.replace(0ul, pos,
"");
202 for (
auto i =
value.size(); i !=
n; ++i) {
212 if (
auto value = std::get_if<value_type>(&value_)) {
213 return value->size();
248 template <
typename T, std::
size_t N>
253 template <
typename T, std::
size_t N>
264 for (std::size_t i{}; i !=
N; ++i) {
271 template <
typename T, std::
size_t N>
284 for (std::size_t i{}; i !=
N; ++i) {
291 template <
typename T, std::
size_t N>
304 template <
typename T, std::
size_t N>
320 template <
typename T>
325 template <
typename T>
339 template <
typename T>
355 template <
typename T>
368 template <
typename T>
std::variant< ftype, value_type > value_
void do_prepare_elements_for_validation(std::size_t const n) override
std::string const & name() const
std::size_t size() const noexcept
std::array< tt::return_type< fhicl::TupleAs< art::test::TypeAndInstance(std::string, std::string)> >,-1ull > value_type
#define NO_DELEGATED_PARAMETERS
void check_nargs_for_bounded_sequences(std::string const &key, std::size_t expected, std::size_t provided)
void do_walk_elements(detail::ParameterWalker< tt::const_flavor::require_non_const > &pw) override
bool hasValue() const noexcept
std::size_t get_size() const noexcept override
#define NO_OPTIONAL_TYPES
static void end_of_ctor()
std::function< bool()> AlwaysUse()
SequenceBase(Name &&name, Comment &&comment, par_style const vt, par_type const type, std::function< bool()> maybeUse)
void do_set_value(fhicl::ParameterSet const &) override
std::array< std::shared_ptr< tt::fhicl_type< fhicl::TupleAs< art::test::TypeAndInstance(std::string, std::string)> >>,-1ull > ftype
std::variant< ftype, value_type > value_
std::string strip_first_containing_name(std::string const &key)
void walk_over(tt::maybe_const_t< ParameterBase, C > &)
RegisterIfTableMember(ParameterBase *pb)
typename fhicl_type_impl< T >::type fhicl_type
T get(std::string const &key) const
bool operator()(value_type &t) const
void do_prepare_elements_for_validation(std::size_t const n) override
bool hasValue() const noexcept
static std::string current()
static constexpr double ps
std::optional< value_type > operator()() const
auto transform_all(Container &, OutputIt, UnaryOp)
void do_walk_elements(detail::ParameterWalker< tt::const_flavor::require_const > &pw) const override
#define NO_NESTED_TABLE_FRAGMENTS
void do_walk_elements(detail::ParameterWalker< tt::const_flavor::require_non_const > &pw) override
bool operator()(value_type &t) const
std::string const & key() const
static Name sequence_element(std::size_t const i)
bool do_preset_value(fhicl::ParameterSet const &) override
void do_walk_elements(detail::ParameterWalker< tt::const_flavor::require_const > &pw) const override
auto for_all(FwdCont &, Func)
std::string const & comment() const
std::vector< tt::return_type< T >> value_type
std::optional< value_type > operator()() const
typename return_type_impl< ARGS... >::value_type return_type
std::vector< std::shared_ptr< tt::fhicl_type< T >>> ftype
void function(int client, int *resource, int parblock, int *test, int p)
std::size_t get_size() const noexcept override
OptionalSequence(Name &&name)