LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
fhicl::OptionalSequence< T,-1ull > Class Template Referencefinal

#include "OptionalSequence.h"

Inheritance diagram for fhicl::OptionalSequence< T,-1ull >:
fhicl::detail::SequenceBase fhicl::detail::RegisterIfTableMember fhicl::detail::ParameterBase

Public Types

using ftype = std::vector< std::shared_ptr< tt::fhicl_type< T >>>
 
using value_type = std::vector< tt::return_type< T >>
 

Public Member Functions

 OptionalSequence (Name &&name)
 
 OptionalSequence (Name &&name, Comment &&comment)
 
 OptionalSequence (Name &&name, Comment &&comment, std::function< bool()> maybeUse)
 
bool operator() (value_type &t) const
 
bool empty () const
 
std::size_t size () const
 
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
 
std::string key () const
 
std::string name () const
 
std::string comment () const
 
bool has_default () const
 
bool is_optional () const
 
bool is_conditional () const
 
par_type parameter_type () const
 
bool should_use () const
 
void set_value (fhicl::ParameterSet const &ps, bool trimParents)
 
void set_par_style (par_style const vt)
 
void set_key (std::string const &key)
 

Private Member Functions

void do_prepare_elements_for_validation (std::size_t const n) override
 
std::size_t get_size () const 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
 
void do_set_value (fhicl::ParameterSet const &, bool const trimParents) override
 

Private Attributes

ftype value_
 
bool has_value_ {false}
 

Detailed Description

template<typename T>
class fhicl::OptionalSequence< T,-1ull >

Definition at line 102 of file OptionalSequence.h.

Member Typedef Documentation

template<typename T >
using fhicl::OptionalSequence< T,-1ull >::ftype = std::vector<std::shared_ptr<tt::fhicl_type<T>>>

Definition at line 111 of file OptionalSequence.h.

template<typename T >
using fhicl::OptionalSequence< T,-1ull >::value_type = std::vector<tt::return_type<T>>

Definition at line 112 of file OptionalSequence.h.

Constructor & Destructor Documentation

template<typename T >
fhicl::OptionalSequence< T,-1ull >::OptionalSequence ( Name &&  name)
explicit
template<typename T >
fhicl::OptionalSequence< T,-1ull >::OptionalSequence ( Name &&  name,
Comment &&  comment 
)
explicit
template<typename T >
fhicl::OptionalSequence< T,-1ull >::OptionalSequence ( Name &&  name,
Comment &&  comment,
std::function< bool()>  maybeUse 
)
explicit

Member Function Documentation

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

Implements fhicl::detail::SequenceBase.

Definition at line 141 of file OptionalSequence.h.

References fhicl::NameStackRegistry::instance(), fhicl::detail::ParameterBase::key(), n, and fhicl::Name::sequence_element().

142  {
143  if (n < value_.size()) {
144  value_.resize(n);
145  } else if (n > value_.size()) {
146 
147  std::string key_fragment{key()};
148  // When emplacing a new element, do not include in the key
149  // argument the current name-stack stem--it will
150  // automatically be prepended.
151  auto const& nsr = NameStackRegistry::instance();
152  if (!nsr.empty()) {
153  std::string const& current_stem = nsr.current();
154  std::size_t const pos =
155  key_fragment.find(current_stem) != std::string::npos ?
156  current_stem.size() + 1ul : // + 1ul to account for the '.'
157  0ul;
158  key_fragment.replace(0ul, pos, "");
159  }
160 
161  for (auto i = value_.size(); i != n; ++i) {
162  value_.emplace_back(
163  new tt::fhicl_type<T>{Name::sequence_element(key_fragment, i)});
164  }
165  }
166  }
static NameStackRegistry & instance()
typename fhicl_type_impl< T >::type fhicl_type
Definition: type_traits.h:305
static Name sequence_element(std::size_t const i)
Definition: Name.h:17
Char_t n[5]
std::string key() const
Definition: ParameterBase.h:44
template<typename T >
void fhicl::OptionalSequence< T,-1ull >::do_set_value ( fhicl::ParameterSet const &  ,
bool const  trimParents 
)
overrideprivatevirtual
template<typename T >
void fhicl::OptionalSequence< T,-1ull >::do_walk_elements ( detail::ParameterWalker< tt::const_flavor::require_non_const > &  pw)
inlineoverrideprivatevirtual

Implements fhicl::detail::SequenceBase.

Definition at line 175 of file OptionalSequence.h.

References e, and fhicl::detail::ParameterWalker< C >::walk_over().

177  {
178  cet::for_all(value_, [&pw](auto& e) { pw.walk_over(*e); });
179  }
Float_t e
Definition: plot.C:34
template<typename T >
void fhicl::OptionalSequence< T,-1ull >::do_walk_elements ( detail::ParameterWalker< tt::const_flavor::require_const > &  pw) const
inlineoverrideprivatevirtual

Implements fhicl::detail::SequenceBase.

Definition at line 182 of file OptionalSequence.h.

References fhicl::OptionalSequence< T, N >::do_set_value(), e, and fhicl::detail::ParameterWalker< C >::walk_over().

184  {
185  cet::for_all(value_, [&pw](auto const& e) { pw.walk_over(*e); });
186  }
Float_t e
Definition: plot.C:34
bool fhicl::detail::SequenceBase::empty ( void  ) const
inlineinherited

Definition at line 29 of file SequenceBase.h.

References fhicl::detail::SequenceBase::size().

Referenced by fhicl::detail::PrintAllowedConfiguration::enter_sequence().

30  {
31  return size() == 0;
32  }
std::size_t size() const
Definition: SequenceBase.h:34
template<typename T >
std::size_t fhicl::OptionalSequence< T,-1ull >::get_size ( ) const
inlineoverrideprivatevirtual

Implements fhicl::detail::SequenceBase.

Definition at line 169 of file OptionalSequence.h.

170  {
171  return value_.size();
172  }
bool fhicl::detail::ParameterBase::is_conditional ( ) const
inlineinherited
std::string fhicl::detail::ParameterBase::key ( ) const
inlineinherited

Definition at line 44 of file ParameterBase.h.

References fhicl::detail::ParameterMetadata::key(), and fhicl::detail::ParameterBase::mdata_.

Referenced by fhicl::detail::PrintAllowedConfiguration::after_action(), fhicl::detail::ValidateThenSet::before_action(), fhicl::detail::PrintAllowedConfiguration::before_action(), fhicl::detail::SearchAllowedConfiguration::before_action(), fhicl::detail::PrintAllowedConfiguration::cacheTopLevelParameter(), detinfo::LArPropertiesStandard::Configure(), fhicl::OptionalSequence< Table< T >< art::RootInputFileSequence::Config::SecondaryFile > >::do_prepare_elements_for_validation(), fhicl::OptionalTuple< ARGS... >::do_prepare_elements_for_validation(), do_prepare_elements_for_validation(), fhicl::detail::ValidateThenSet::enter_sequence(), fhicl::detail::PrintAllowedConfiguration::enter_sequence(), evgen::MARLEYHelper::fhicl_parameter_to_json(), fhicl::detail::SearchAllowedConfiguration::form_absolute(), fhicl::DelegatedParameter::get(), fhicl::OptionalDelegatedParameter::get_if_present(), fhicl::OptionalDelegatedParameter::hasValue(), fhicl::detail::MaybeDisplayParent::is_sequence_element(), fhicl::detail::PrintAllowedConfiguration::maybeReleaseTopLevelParameter(), fhicl::detail::RegisterIfTableMember::RegisterIfTableMember(), and fhicl::detail::PrintAllowedConfiguration::suppressFormat().

45  {
46  return mdata_.key();
47  }
template<typename T >
bool fhicl::OptionalSequence< T,-1ull >::operator() ( value_type t) const
inline

Definition at line 121 of file OptionalSequence.h.

References e, fhicl::OptionalSequence< T, N >::has_value_, and fhicl::OptionalSequence< T, N >::value_.

122  {
123 
124  if (!has_value_)
125  return false;
126 
127  value_type result;
128  cet::transform_all(value_, std::back_inserter(result), [](auto const& e) {
129  return (*e)();
130  });
131 
132  std::swap(result, t);
133  return true;
134  }
void swap(art::HLTGlobalStatus &lhs, art::HLTGlobalStatus &rhs)
std::vector< tt::return_type< T >> value_type
Float_t e
Definition: plot.C:34
void fhicl::detail::SequenceBase::prepare_elements_for_validation ( std::size_t const  n)
inlineinherited

Definition at line 40 of file SequenceBase.h.

References fhicl::detail::SequenceBase::do_prepare_elements_for_validation().

Referenced by fhicl::detail::ValidateThenSet::enter_sequence().

41  {
43  }
virtual void do_prepare_elements_for_validation(std::size_t)=0
Char_t n[5]
void fhicl::detail::ParameterBase::set_key ( std::string const &  key)
inlineinherited
void fhicl::detail::ParameterBase::set_par_style ( par_style const  vt)
inlineinherited
void fhicl::detail::ParameterBase::set_value ( fhicl::ParameterSet const &  ps,
bool  trimParents 
)
inlineinherited

Definition at line 96 of file ParameterBase.h.

References fhicl::detail::ParameterBase::do_set_value().

Referenced by fhicl::detail::ValidateThenSet::after_action().

97  {
98  do_set_value(ps, trimParents);
99  }
virtual void do_set_value(fhicl::ParameterSet const &, bool trimParents)=0
bool fhicl::detail::ParameterBase::should_use ( ) const
inlineinherited
std::size_t fhicl::detail::SequenceBase::size ( void  ) const
inlineinherited

Definition at line 34 of file SequenceBase.h.

References fhicl::detail::SequenceBase::get_size().

Referenced by fhicl::detail::SequenceBase::empty(), and fhicl::detail::PrintAllowedConfiguration::enter_sequence().

35  {
36  return get_size();
37  }
virtual std::size_t get_size() const =0
void fhicl::detail::SequenceBase::walk_elements ( ParameterWalker< tt::const_flavor::require_non_const > &  pw)
inlineinherited

Definition at line 45 of file SequenceBase.h.

References fhicl::detail::SequenceBase::do_walk_elements().

46  {
47  do_walk_elements(pw);
48  }
virtual void do_walk_elements(ParameterWalker< tt::const_flavor::require_non_const > &)=0
void fhicl::detail::SequenceBase::walk_elements ( ParameterWalker< tt::const_flavor::require_const > &  pw) const
inlineinherited

Definition at line 50 of file SequenceBase.h.

References fhicl::detail::SequenceBase::do_prepare_elements_for_validation(), fhicl::detail::SequenceBase::do_walk_elements(), and fhicl::detail::SequenceBase::get_size().

51  {
52  do_walk_elements(pw);
53  }
virtual void do_walk_elements(ParameterWalker< tt::const_flavor::require_non_const > &)=0

Member Data Documentation

template<typename T >
bool fhicl::OptionalSequence< T,-1ull >::has_value_ {false}
private

Definition at line 138 of file OptionalSequence.h.

template<typename T >
ftype fhicl::OptionalSequence< T,-1ull >::value_
private

Definition at line 137 of file OptionalSequence.h.


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