Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
fhicl::OptionalSequence< T,-1ull > Class Template Referencefinal

#include "/cvmfs/nova.opensciencegrid.org/externals/fhiclcpp/v4_06_10/source/fhiclcpp/types/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

std::string fhicl::detail::ParameterBase::comment ( ) const
inlineinherited
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 MECModelEnuComparisons::i, fhicl::NameStackRegistry::instance(), fhicl::detail::ParameterBase::key(), getGoodRuns4SAM::n, elec2geo::pos, fhicl::Name::sequence_element(), and string.

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:273
static Name sequence_element(std::size_t const i)
Definition: Name.h:17
std::string key() const
Definition: ParameterBase.h:44
enum BeamMode string
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, cet::for_all(), and fhicl::detail::ParameterWalker< C >::walk_over().

177  {
178  cet::for_all(value_, [&pw](auto& e) { pw.walk_over(*e); });
179  }
auto for_all(FwdCont &, Func)
Float_t e
Definition: plot.C:35
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, cet::for_all(), and fhicl::detail::ParameterWalker< C >::walk_over().

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

Definition at line 29 of file SequenceBase.h.

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

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::has_default ( ) const
inlineinherited
bool fhicl::detail::ParameterBase::is_conditional ( ) const
inlineinherited
bool fhicl::detail::ParameterBase::is_optional ( ) const
inlineinherited
std::string fhicl::detail::ParameterBase::key ( ) const
inlineinherited
std::string fhicl::detail::ParameterBase::name ( ) const
inlineinherited
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_, fillBadChanDBTables::result, std::swap(), cet::transform_all(), and fhicl::OptionalSequence< T, N >::value_.

122  {
123 
124  if (!has_value_)
125  return false;
126 
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)
auto transform_all(Container &, OutputIt, UnaryOp)
std::vector< tt::return_type< T >> value_type
Float_t e
Definition: plot.C:35
par_type fhicl::detail::ParameterBase::parameter_type ( ) const
inlineinherited
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().

41  {
43  }
virtual void do_prepare_elements_for_validation(std::size_t)=0
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().

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

Definition at line 79 of file ParameterBase.h.

References fhicl::detail::ParameterBase::maybeUse_.

80  {
81  return maybeUse_();
82  }
std::function< bool()> maybeUse_
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().

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: