Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
fhicl::Sequence< T, N > Class Template Reference

#include <type_traits.h>

Inheritance diagram for fhicl::Sequence< T, N >:
fhicl::detail::SequenceBase fhicl::detail::RegisterIfTableMember fhicl::detail::ParameterBase

Public Types

using default_type = sequence_detail::ValueHolder< typename tt::fhicl_type< T >::default_type >
 
using ftype = std::array< std::shared_ptr< tt::fhicl_type< T >>, N >
 
using value_type = std::array< tt::return_type< T >, N >
 

Public Member Functions

 Sequence (Name &&name)
 
 Sequence (Name &&name, Comment &&comment)
 
 Sequence (Name &&name, Comment &&comment, std::function< bool()> maybeUse)
 
 Sequence (Name &&name, default_type const &defaults)
 
 Sequence (Name &&name, Comment &&comment, default_type const &defaults)
 
 Sequence (Name &&name, Comment &&comment, std::function< bool()> maybeUse, default_type const &defaults)
 
auto operator() () const
 
auto operator() (std::size_t const i) const
 
- Public Member Functions inherited from fhicl::detail::SequenceBase
 SequenceBase (Name &&name, Comment &&comment, par_style const vt, par_type const type, std::function< bool()> maybeUse)
 
bool empty () const noexcept
 
std::size_t size () const noexcept
 
void prepare_elements_for_validation (std::size_t const n)
 
void walk_elements (ParameterWalker< tt::const_flavor::require_non_const > &pw)
 
void walk_elements (ParameterWalker< tt::const_flavor::require_const > &pw) const
 
- Public Member Functions inherited from fhicl::detail::ParameterBase
std::string const & key () const
 
std::string const & name () const
 
std::string const & comment () const
 
bool has_default () const
 
bool is_optional () const
 
bool is_conditional () const
 
par_type parameter_type () const
 
bool should_use () const
 
 ParameterBase (Name const &name, Comment const &comment, par_style const vt, par_type const type, std::function< bool()> maybeUse=AlwaysUse())
 
virtual ~ParameterBase ()=default
 
void set_value (fhicl::ParameterSet const &ps)
 
bool preset_value (fhicl::ParameterSet const &ps)
 
void set_par_style (par_style const vt)
 

Private Member Functions

std::size_t get_size () const noexcept override
 
void do_prepare_elements_for_validation (std::size_t const n) override
 
void do_walk_elements (detail::ParameterWalker< tt::const_flavor::require_non_const > &pw) override
 
void do_walk_elements (detail::ParameterWalker< tt::const_flavor::require_const > &pw) const override
 
bool do_preset_value (fhicl::ParameterSet const &ps) override
 
void do_set_value (fhicl::ParameterSet const &) override
 
- Private Member Functions inherited from fhicl::detail::RegisterIfTableMember
 RegisterIfTableMember (ParameterBase *pb)
 

Private Attributes

std::variant< ftype, value_typevalue_
 

Detailed Description

template<typename T, std::size_t N = -1ull>
class fhicl::Sequence< T, N >

Definition at line 43 of file type_traits.h.

Member Typedef Documentation

template<typename T, std::size_t N = -1ull>
using fhicl::Sequence< T, N >::default_type = sequence_detail::ValueHolder<typename tt::fhicl_type<T>::default_type>

Definition at line 83 of file Sequence.h.

template<typename T, std::size_t N = -1ull>
using fhicl::Sequence< T, N >::ftype = std::array<std::shared_ptr<tt::fhicl_type<T>>, N>

Definition at line 84 of file Sequence.h.

template<typename T, std::size_t N = -1ull>
using fhicl::Sequence< T, N >::value_type = std::array<tt::return_type<T>, N>

Definition at line 85 of file Sequence.h.

Constructor & Destructor Documentation

template<typename T , std::size_t N>
fhicl::Sequence< T, N >::Sequence ( Name &&  name)
explicit

Definition at line 326 of file Sequence.h.

326  : Sequence{std::move(name), Comment("")}
327  {}
std::string const & name() const
Definition: ParameterBase.h:43
def move(depos, offset)
Definition: depos.py:107
Sequence(Name &&name)
Definition: Sequence.h:326
#define Comment
template<typename T , std::size_t N>
fhicl::Sequence< T, N >::Sequence ( Name &&  name,
Comment &&  comment 
)
explicit

Definition at line 330 of file Sequence.h.

336  , RegisterIfTableMember{this}
337  , value_{ftype{nullptr}}
338  {
339  auto& value = std::get<ftype>(value_);
340  for (std::size_t i{}; i != N; ++i) {
341  value.at(i) =
342  std::make_shared<tt::fhicl_type<T>>(Name::sequence_element(i));
343  }
345  }
std::string const & name() const
Definition: ParameterBase.h:43
std::function< bool()> AlwaysUse()
SequenceBase(Name &&name, Comment &&comment, par_style const vt, par_type const type, std::function< bool()> maybeUse)
Definition: SequenceBase.h:19
def move(depos, offset)
Definition: depos.py:107
std::array< std::shared_ptr< tt::fhicl_type< T >>, N > ftype
Definition: Sequence.h:84
static Name sequence_element(std::size_t const i)
Definition: Name.h:16
std::string const & comment() const
Definition: ParameterBase.h:48
std::variant< ftype, value_type > value_
Definition: Sequence.h:126
template<typename T , std::size_t N>
fhicl::Sequence< T, N >::Sequence ( Name &&  name,
Comment &&  comment,
std::function< bool()>  maybeUse 
)
explicit

Definition at line 348 of file Sequence.h.

355  maybeUse}
356  , RegisterIfTableMember{this}
357  , value_{ftype{nullptr}}
358  {
359  auto& value = std::get<ftype>(value_);
360  for (std::size_t i{}; i != N; ++i) {
361  value.at(i) =
362  std::make_shared<tt::fhicl_type<T>>(Name::sequence_element(i));
363  }
365  }
std::string const & name() const
Definition: ParameterBase.h:43
SequenceBase(Name &&name, Comment &&comment, par_style const vt, par_type const type, std::function< bool()> maybeUse)
Definition: SequenceBase.h:19
def move(depos, offset)
Definition: depos.py:107
std::array< std::shared_ptr< tt::fhicl_type< T >>, N > ftype
Definition: Sequence.h:84
static Name sequence_element(std::size_t const i)
Definition: Name.h:16
std::string const & comment() const
Definition: ParameterBase.h:48
std::variant< ftype, value_type > value_
Definition: Sequence.h:126
template<typename T , std::size_t N>
fhicl::Sequence< T, N >::Sequence ( Name &&  name,
default_type const &  defaults 
)
explicit

Definition at line 369 of file Sequence.h.

370  : Sequence{std::move(name), Comment{""}, defaults}
371  {}
std::string const & name() const
Definition: ParameterBase.h:43
def move(depos, offset)
Definition: depos.py:107
Sequence(Name &&name)
Definition: Sequence.h:326
#define Comment
template<typename T , std::size_t N>
fhicl::Sequence< T, N >::Sequence ( Name &&  name,
Comment &&  comment,
default_type const &  defaults 
)
explicit

Definition at line 374 of file Sequence.h.

382  , RegisterIfTableMember{this}
383  , value_{ftype{nullptr}}
384  {
385  std::size_t i{};
386  auto& value = std::get<ftype>(value_);
387  for (auto const& arg : defaults) {
388  value.at(i) =
389  std::make_shared<tt::fhicl_type<T>>(Name::sequence_element(i), arg);
390  ++i;
391  }
393  }
std::string const & name() const
Definition: ParameterBase.h:43
std::function< bool()> AlwaysUse()
SequenceBase(Name &&name, Comment &&comment, par_style const vt, par_type const type, std::function< bool()> maybeUse)
Definition: SequenceBase.h:19
def move(depos, offset)
Definition: depos.py:107
std::array< std::shared_ptr< tt::fhicl_type< T >>, N > ftype
Definition: Sequence.h:84
static Name sequence_element(std::size_t const i)
Definition: Name.h:16
std::string const & comment() const
Definition: ParameterBase.h:48
std::variant< ftype, value_type > value_
Definition: Sequence.h:126
template<typename T , std::size_t N>
fhicl::Sequence< T, N >::Sequence ( Name &&  name,
Comment &&  comment,
std::function< bool()>  maybeUse,
default_type const &  defaults 
)
explicit

Definition at line 396 of file Sequence.h.

404  maybeUse}
405  , RegisterIfTableMember{this}
406  , value_{ftype{nullptr}}
407  {
408  std::size_t i{};
409  auto& value = std::get<ftype>(value_);
410  for (auto const& arg : defaults) {
411  value.at(i) =
412  std::make_shared<tt::fhicl_type<T>>(Name::sequence_element(i), arg);
413  ++i;
414  }
416  }
std::string const & name() const
Definition: ParameterBase.h:43
SequenceBase(Name &&name, Comment &&comment, par_style const vt, par_type const type, std::function< bool()> maybeUse)
Definition: SequenceBase.h:19
def move(depos, offset)
Definition: depos.py:107
std::array< std::shared_ptr< tt::fhicl_type< T >>, N > ftype
Definition: Sequence.h:84
static Name sequence_element(std::size_t const i)
Definition: Name.h:16
std::string const & comment() const
Definition: ParameterBase.h:48
std::variant< ftype, value_type > value_
Definition: Sequence.h:126

Member Function Documentation

template<typename T, std::size_t N = -1ull>
void fhicl::Sequence< T, N >::do_prepare_elements_for_validation ( std::size_t const  n)
inlineoverrideprivatevirtual

Implements fhicl::detail::SequenceBase.

Definition at line 138 of file Sequence.h.

139  {
141  }
void check_nargs_for_bounded_sequences(std::string const &key, std::size_t expected, std::size_t provided)
std::void_t< T > n
std::string const & key() const
Definition: ParameterBase.h:38
std::size_t get_size() const noexcept override
Definition: Sequence.h:129
template<typename T, std::size_t N = -1ull>
bool fhicl::Sequence< T, N >::do_preset_value ( fhicl::ParameterSet const &  ps)
inlineoverrideprivatevirtual

Reimplemented from fhicl::detail::ParameterBase.

Definition at line 162 of file Sequence.h.

163  {
164  if constexpr (std::is_same_v<tt::fhicl_type<T>, Atom<T>>) {
165  auto const trimmed_key = detail::strip_first_containing_name(key());
166  value_ = ps.get<value_type>(trimmed_key);
167  return true;
168  }
169  return false;
170  }
std::array< tt::return_type< T >, N > value_type
Definition: Sequence.h:85
std::string strip_first_containing_name(std::string const &key)
typename fhicl_type_impl< T >::type fhicl_type
Definition: type_traits.h:315
static constexpr double ps
Definition: Units.h:99
std::string const & key() const
Definition: ParameterBase.h:38
std::variant< ftype, value_type > value_
Definition: Sequence.h:126
template<typename T, std::size_t N = -1ull>
void fhicl::Sequence< T, N >::do_set_value ( fhicl::ParameterSet const &  )
inlineoverrideprivatevirtual

Implements fhicl::detail::ParameterBase.

Definition at line 173 of file Sequence.h.

174  {}
template<typename T, std::size_t N = -1ull>
void fhicl::Sequence< T, N >::do_walk_elements ( detail::ParameterWalker< tt::const_flavor::require_non_const > &  pw)
inlineoverrideprivatevirtual

Implements fhicl::detail::SequenceBase.

Definition at line 144 of file Sequence.h.

146  {
147  // We only enter here if we do not have a preset value.
148  cet::for_all(std::get<ftype>(value_),
149  [&pw](auto& e) { pw.walk_over(*e); });
150  }
const double e
auto for_all(FwdCont &, Func)
std::variant< ftype, value_type > value_
Definition: Sequence.h:126
template<typename T, std::size_t N = -1ull>
void fhicl::Sequence< T, N >::do_walk_elements ( detail::ParameterWalker< tt::const_flavor::require_const > &  pw) const
inlineoverrideprivatevirtual

Implements fhicl::detail::SequenceBase.

Definition at line 153 of file Sequence.h.

155  {
156  // We only enter here if we do not have a preset value.
157  cet::for_all(std::get<ftype>(value_),
158  [&pw](auto const& e) { pw.walk_over(*e); });
159  }
const double e
auto for_all(FwdCont &, Func)
std::variant< ftype, value_type > value_
Definition: Sequence.h:126
template<typename T, std::size_t N = -1ull>
std::size_t fhicl::Sequence< T, N >::get_size ( ) const
inlineoverrideprivatevirtualnoexcept

Implements fhicl::detail::SequenceBase.

Definition at line 129 of file Sequence.h.

130  {
131  if (auto value = std::get_if<value_type>(&value_)) {
132  return value->size();
133  }
134  return std::get<ftype>(value_).size();
135  }
std::size_t size() const noexcept
Definition: SequenceBase.h:33
std::variant< ftype, value_type > value_
Definition: Sequence.h:126
template<typename T, std::size_t N = -1ull>
auto fhicl::Sequence< T, N >::operator() ( ) const
inline

Definition at line 104 of file Sequence.h.

105  {
106  if (auto value = std::get_if<value_type>(&value_)) {
107  return *value;
108  }
110  cet::transform_all(std::get<ftype>(value_),
111  result.begin(),
112  [](auto const& elem) { return (*elem)(); });
113  return result;
114  }
std::array< tt::return_type< T >, N > value_type
Definition: Sequence.h:85
static QCString result
auto transform_all(Container &, OutputIt, UnaryOp)
typename return_type_impl< ARGS... >::value_type return_type
Definition: type_traits.h:357
std::variant< ftype, value_type > value_
Definition: Sequence.h:126
template<typename T, std::size_t N = -1ull>
auto fhicl::Sequence< T, N >::operator() ( std::size_t const  i) const
inline

Definition at line 117 of file Sequence.h.

118  {
119  if (auto value = std::get_if<value_type>(&value_)) {
120  return value->at(i);
121  }
122  return (*std::get<ftype>(value_).at(i))();
123  }
std::variant< ftype, value_type > value_
Definition: Sequence.h:126

Member Data Documentation

template<typename T, std::size_t N = -1ull>
std::variant<ftype, value_type> fhicl::Sequence< T, N >::value_
private

Definition at line 126 of file Sequence.h.


The documentation for this class was generated from the following files: