1 #ifndef fhiclcpp_types_Sequence_h 2 #define fhiclcpp_types_Sequence_h 4 #include "cetlib/container_algorithms.h" 16 #include <initializer_list> 19 #include <type_traits> 24 namespace sequence_detail {
38 template <std::
size_t N>
74 template <
typename T, std::size_t N = -1ull>
84 using ftype = std::array<std::shared_ptr<tt::fhicl_type<T>>, N>;
91 std::function<
bool()> maybeUse);
100 std::function<
bool()> maybeUse,
106 if (
auto value = std::get_if<value_type>(&value_)) {
110 cet::transform_all(std::get<ftype>(value_),
112 [](
auto const& elem) {
return (*elem)(); });
119 if (
auto value = std::get_if<value_type>(&value_)) {
122 return (*std::get<ftype>(value_).at(i))();
131 if (
auto value = std::get_if<value_type>(&value_)) {
132 return value->size();
134 return std::get<ftype>(value_).
size();
148 cet::for_all(std::get<ftype>(value_),
157 cet::for_all(std::get<ftype>(value_),
180 template <
typename T>
188 using default_type = std::vector<typename tt::fhicl_type<T>::default_type>;
189 using ftype = std::vector<std::shared_ptr<tt::fhicl_type<T>>>;
196 std::function<
bool()> maybeUse);
205 std::function<
bool()> maybeUse,
211 if (
auto value = std::get_if<value_type>(&value_)) {
215 cet::transform_all(std::get<ftype>(value_),
216 std::back_inserter(result),
217 [](
auto const&
e) {
return (*
e)(); });
224 if (
auto value = std::get_if<value_type>(&value_)) {
227 return (*std::get<ftype>(value_).at(i))();
237 auto&
value = std::get<ftype>(value_);
241 if (n <
value.size()) {
243 }
else if (n >
value.size()) {
244 std::string key_fragment{key()};
250 std::size_t
const pos =
251 key_fragment.find(current_stem) != std::string::npos ?
252 current_stem.size() + 1ul :
254 key_fragment.replace(0ul, pos,
"");
257 for (
auto i =
value.size(); i !=
n; ++i) {
267 if (
auto value = std::get_if<value_type>(&value_)) {
268 return value->size();
270 return std::get<ftype>(value_).
size();
278 cet::for_all(std::get<ftype>(value_),
287 cet::for_all(std::get<ftype>(value_),
308 #include "cetlib/container_algorithms.h" 309 #include "cetlib_except/demangle.h" 325 template <
typename T, std::
size_t N>
329 template <
typename T, std::
size_t N>
340 for (std::size_t i{}; i != N; ++i) {
347 template <
typename T, std::
size_t N>
350 std::function<
bool()> maybeUse)
360 for (std::size_t i{}; i != N; ++i) {
368 template <
typename T, std::
size_t N>
373 template <
typename T, std::
size_t N>
387 for (
auto const& arg : defaults) {
395 template <
typename T, std::
size_t N>
398 std::function<
bool()> maybeUse,
410 for (
auto const& arg : defaults) {
421 template <
typename T>
426 template <
typename T>
440 template <
typename T>
443 std::function<
bool()> maybeUse)
457 template <
typename T>
462 template <
typename T>
476 for (
auto const& t : defaults) {
484 template <
typename T>
487 std::function<
bool()> maybeUse,
499 for (
auto const& t : defaults) {
std::array< tt::return_type< float >, N > value_type
std::vector< T > const holder_
void do_walk_elements(detail::ParameterWalker< tt::const_flavor::require_const > &pw) const override
void do_prepare_elements_for_validation(std::size_t const n) override
std::variant< ftype, value_type > value_
#define NO_DELEGATED_PARAMETERS
void check_nargs_for_bounded_sequences(std::string const &key, std::size_t expected, std::size_t provided)
auto operator()(std::size_t const i) const
bool do_preset_value(fhicl::ParameterSet const &ps) override
auto operator()(std::size_t const i) const
#define NO_OPTIONAL_TYPES
static void end_of_ctor()
ValueHolder(std::array< T, N > const &array)
std::function< bool()> AlwaysUse()
SequenceBase(Name &&name, Comment &&comment, par_style const vt, par_type const type, std::function< bool()> maybeUse)
void do_walk_elements(detail::ParameterWalker< tt::const_flavor::require_non_const > &pw) override
void do_prepare_elements_for_validation(std::size_t const n) override
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
std::string strip_first_containing_name(std::string const &key)
bool do_preset_value(fhicl::ParameterSet const &ps) override
void walk_over(tt::maybe_const_t< ParameterBase, C > &)
auto array(Array const &a)
Returns a manipulator which will print the specified array.
RegisterIfTableMember(ParameterBase *pb)
static std::string current()
auto end() const noexcept
typename fhicl_type_impl< T >::type fhicl_type
auto begin() const noexcept
std::vector< typename tt::fhicl_type< T >::default_type > default_type
std::vector< std::shared_ptr< tt::fhicl_type< T >>> ftype
void do_walk_elements(detail::ParameterWalker< tt::const_flavor::require_const > &pw) const override
T get(std::string const &key) const
void do_set_value(fhicl::ParameterSet const &) override
std::string const & name() const
auto cend() const noexcept
void do_walk_elements(detail::ParameterWalker< tt::const_flavor::require_non_const > &pw) override
void do_set_value(fhicl::ParameterSet const &) override
#define NO_NESTED_TABLE_FRAGMENTS
std::vector< tt::return_type< T >> value_type
std::array< std::shared_ptr< tt::fhicl_type< float >>, N > ftype
static Name sequence_element(std::size_t const i)
std::size_t get_size() const noexcept override
ValueHolder(std::initializer_list< T > list)
typename return_type_impl< ARGS... >::value_type return_type
auto cbegin() const noexcept
#define NO_DEFAULTS_FOR_TABLE
std::string const & comment() const
std::variant< ftype, value_type > value_
std::size_t get_size() const noexcept override