LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
fhicl::detail::TableBase Class Reference

#include "TableBase.h"

Inheritance diagram for fhicl::detail::TableBase:
fhicl::detail::ParameterBase fhicl::OptionalTable< T > fhicl::Table< T, KeysToIgnore > fhicl::OptionalTable< art::Scheduler::Config::DebugConfig > fhicl::OptionalTable< Config > fhicl::Table< art::detail::Analyzer::Table::FullConfig< UserConfig >, KeysToIgnore_t > fhicl::Table< art::ProducerTable::FullConfig< UserConfig, ImplicitConfig >, KeysToIgnore_t > fhicl::Table< art::TimeTracker::Config::DBoutput > fhicl::Table< art::ToolConfigTable::FullConfig< Config >, KeysToIgnore_t > fhicl::Table< art::ToolConfigTable::FullConfig< UserConfig >, KeysToIgnore_t > fhicl::Table< calo::calo::CalorimetryAlg::calo::GnocchiCalorimetry::Config > fhicl::Table< calo::CalorimetryAlg::img::DataProviderAlg::Config > fhicl::Table< calo::CalorimetryAlg::nnet::PointIdEffTest::Config > fhicl::Table< cheat::BackTracker::cheat::BackTrackerService::fhiclConfig > fhicl::Table< cheat::ParticleInventory::ParticleInventoryConfig > fhicl::Table< cheat::PhotonBackTracker::cheat::PhotonBackTrackerService::fhiclConfig > fhicl::Table< evgen::evgen::ActiveVolumeVertexSampler::evgen::MarleyGen::Config > fhicl::Table< evgen::evgen::ActiveVolumeVertexSampler::evgen::MarleyTimeGen::Config > fhicl::Table< img::DataProviderAlg::pma::PMAlgTracker::Config > fhicl::Table< mf::service::ELdestination::MsgFormatSettings::mf::service::ELdestination::Config > fhicl::Table< nnet::nnet::PointIdAlg::nnet::EmTrackClusterId2out::Config > fhicl::Table< nnet::nnet::PointIdAlg::nnet::EmTrackClusterId::Config > fhicl::Table< nnet::nnet::PointIdAlg::nnet::EmTrackMichelId::Config > fhicl::Table< nnet::nnet::PointIdAlg::nnet::ParticleDecayId::Config > fhicl::Table< nnet::nnet::TrainingDataAlg::nnet::PointIdTrainingData::Config > fhicl::Table< pma::PMAlgCosmicTagger::trkf::PMAlgTrackMaker::Config > fhicl::Table< pma::PMAlgFitter::trkf::PMAlgTrajFitter::Config > fhicl::Table< pma::PMAlgStitching::trkf::PMAlgTrackMaker::Config > fhicl::Table< pma::PMAlgTracker::trkf::PMAlgTrackMaker::Config > fhicl::Table< pma::PMAlgVertexing::trkf::PMAlgTrackMaker::Config > fhicl::Table< pma::PMAlgVertexing::trkf::PMAlgTrajFitter::Config > fhicl::Table< pma::ProjectionMatchingAlg::trkf::PMAlgTrackMaker::Config > fhicl::Table< pma::ProjectionMatchingAlg::trkf::PMAlgTrajFitter::Config > fhicl::Table< PointIdAlgTools::IPointIdAlg::nnet::EmTrack::Config > fhicl::Table< T > fhicl::Table< T, fhicl::KeysToIgnore > fhicl::Table< trkf::Geometric3DVertexFitter::trkf::VertexFitter::Config > fhicl::Table< trkf::KalmanFilterFinalTrackFitter::trkf::KalmanFilterFinalTrackFitter::Inputs > fhicl::Table< trkf::KalmanFilterFinalTrackFitter::trkf::KalmanFilterFinalTrackFitter::Options > fhicl::Table< trkf::KalmanFilterTrajectoryFitter::trkf::KalmanFilterTrajectoryFitter::Inputs > fhicl::Table< trkf::KalmanFilterTrajectoryFitter::trkf::KalmanFilterTrajectoryFitter::Options > fhicl::Table< trkf::MCSFitProducer::trkf::MCSFitProducer::Inputs > fhicl::Table< trkf::TrackKalmanFitter::trkf::KalmanFilterFinalTrackFitter::Config > fhicl::Table< trkf::TrackKalmanFitter::trkf::KalmanFilterTrajectoryFitter::Config > fhicl::Table< trkf::TrackKalmanFitter::trkmkr::KalmanFilterFitTrackMaker::Config > fhicl::Table< trkf::TrackStatePropagator::trkf::KalmanFilterFinalTrackFitter::Config > fhicl::Table< trkf::TrackStatePropagator::trkf::KalmanFilterTrajectoryFitter::Config > fhicl::Table< trkf::TrackStatePropagator::trkf::VertexFitter::Config > fhicl::Table< trkf::TrackStatePropagator::trkmkr::KalmanFilterFitTrackMaker::Config > fhicl::Table< trkf::TrajectoryMCSFitter::trkf::MCSFitProducer::Config > fhicl::Table< trkf::TrajectoryMCSFitter::trkmkr::KalmanFilterFitTrackMaker::Config > fhicl::Table< trkf::VertexFitter::trkf::VertexFitter::Inputs > fhicl::Table< trkmkr::KalmanFilterFitTrackMaker::trkmkr::KalmanFilterFitTrackMaker::Options >

Public Member Functions

 TableBase (Name const &name, Comment const &comment, par_style vt, std::function< bool()> maybeUse)
 
 ~TableBase ()
 
void print_allowed_configuration (std::ostream &os, std::string const &tab=std::string(3, ' ')) const
 
std::vector< cet::exempt_ptr< ParameterBase > > const & members () const
 
void validate (ParameterSet const &pset, std::set< std::string > const &ignorable_keys={})
 
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
 
void set_value (fhicl::ParameterSet const &ps)
 
bool preset_value (fhicl::ParameterSet const &ps)
 
void set_par_style (par_style const vt)
 

Protected Member Functions

void finalize_members ()
 
void maybe_implicitly_default ()
 
bool has_value () const
 
ParameterSet const & get_pset () const
 
ParameterSet const & guarantee_pset () const
 

Private Member Functions

void do_set_value (ParameterSet const &pset) final
 
std::optional< ParameterSetselect_pset (ParameterSet const &pset) const
 
std::optional< ParameterSetmaybe_select_pset (ParameterSet const &pset) const
 

Private Attributes

std::optional< ParameterSetpset_
 
std::vector< cet::exempt_ptr< ParameterBase > > members_
 

Detailed Description

Definition at line 16 of file TableBase.h.

Constructor & Destructor Documentation

fhicl::detail::TableBase::TableBase ( Name const &  name,
Comment const &  comment,
par_style  vt,
std::function< bool()>  maybeUse 
)

Definition at line 12 of file TableBase.cc.

References fhicl::detail::ParameterBase::comment(), fhicl::detail::ParameterBase::name(), fhicl::TABLE, and ~TableBase().

16  : ParameterBase{name, comment, vt, par_type::TABLE, std::move(maybeUse)}
17  {}
ParameterBase(Name const &name, Comment const &comment, par_style const vt, par_type const type, std::function< bool()> maybeUse=AlwaysUse())
std::string const & name() const
std::string const & comment() const
fhicl::detail::TableBase::~TableBase ( )
default

Referenced by TableBase().

Member Function Documentation

void fhicl::detail::TableBase::do_set_value ( fhicl::ParameterSet const &  pset)
finalprivatevirtual

Implements fhicl::detail::ParameterBase.

Definition at line 129 of file TableBase.cc.

References fhicl::detail::ParameterBase::is_optional(), maybe_select_pset(), pset_, and select_pset().

130  {
131  if (is_optional()) {
132  pset_ = maybe_select_pset(pset);
133  } else {
134  pset_ = select_pset(pset);
135  }
136  }
std::optional< ParameterSet > select_pset(ParameterSet const &pset) const
Definition: TableBase.cc:92
std::optional< ParameterSet > maybe_select_pset(ParameterSet const &pset) const
Definition: TableBase.cc:110
std::optional< ParameterSet > pset_
Definition: TableBase.h:44
void fhicl::detail::TableBase::finalize_members ( )
protected

Definition at line 37 of file TableBase.cc.

References members_, and fhicl::detail::TableMemberRegistry::release_members().

Referenced by fhicl::OptionalTable< T >::OptionalTable(), and fhicl::Table< T, KeysToIgnore >::Table().

38  {
39  // This must be called in a derived class **after** the table's
40  // values has been set.
42  }
std::vector< cet::exempt_ptr< ParameterBase > > members_
Definition: TableBase.h:45
static std::vector< base_ptr > release_members()
ParameterSet const & fhicl::detail::TableBase::get_pset ( ) const
protected

Definition at line 79 of file TableBase.cc.

References pset_.

80  {
81  return pset_.value();
82  }
std::optional< ParameterSet > pset_
Definition: TableBase.h:44
ParameterSet const & fhicl::detail::TableBase::guarantee_pset ( ) const
protected

Definition at line 85 of file TableBase.cc.

References pset_.

86  {
87  static ParameterSet const empty_pset;
88  return pset_.has_value() ? *pset_ : empty_pset;
89  }
std::optional< ParameterSet > pset_
Definition: TableBase.h:44
bool fhicl::detail::TableBase::has_value ( ) const
protected

Definition at line 73 of file TableBase.cc.

References pset_.

74  {
75  return pset_.has_value();
76  }
std::optional< ParameterSet > pset_
Definition: TableBase.h:44
bool fhicl::detail::ParameterBase::is_conditional ( ) const
inherited
std::string const & fhicl::detail::ParameterBase::key ( ) const
inherited

Definition at line 6 of file ParameterBase.cc.

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::OptionalTuple< ARGS... >::do_prepare_elements_for_validation(), fhicl::OptionalSequence< art::InputTag >::do_prepare_elements_for_validation(), fhicl::OptionalSequence< T,-1ull >::do_prepare_elements_for_validation(), fhicl::OptionalSequence< T, N >::do_preset_value(), fhicl::OptionalSequence< T,-1ull >::do_preset_value(), fhicl::Atom< T >::do_set_value(), fhicl::OptionalAtom< T >::do_set_value(), fhicl::detail::ValidateThenSet::enter_sequence(), fhicl::detail::PrintAllowedConfiguration::enter_sequence(), fhicl::detail::SearchAllowedConfiguration::form_absolute(), fhicl::DelegatedParameter::get(), fhicl::OptionalDelegatedParameter::get_if_present(), fhicl::OptionalDelegatedParameter::hasValue(), fhicl::detail::MaybeDisplayParent::is_sequence_element(), maybe_select_pset(), fhicl::detail::PrintAllowedConfiguration::maybeReleaseTopLevelParameter(), fhicl::detail::RegisterIfTableMember::RegisterIfTableMember(), select_pset(), and fhicl::detail::PrintAllowedConfiguration::suppressFormat().

7  {
8  return mdata_.key();
9  }
ParameterMetadata mdata_
Definition: ParameterBase.h:63
std::string const & key() const
void fhicl::detail::TableBase::maybe_implicitly_default ( )
protected

Definition at line 45 of file TableBase.cc.

References fhicl::DEFAULT, members_, and fhicl::detail::ParameterBase::set_par_style().

Referenced by fhicl::Table< T, KeysToIgnore >::Table().

46  {
47  bool const implicitly_default =
48  std::all_of(members_.begin(), members_.end(), [](auto p) {
49  return p->has_default() || p->is_optional();
50  });
51  if (implicitly_default)
53  }
std::vector< cet::exempt_ptr< ParameterBase > > members_
Definition: TableBase.h:45
void set_par_style(par_style const vt)
std::optional< ParameterSet > fhicl::detail::TableBase::maybe_select_pset ( fhicl::ParameterSet const &  pset) const
private

Definition at line 110 of file TableBase.cc.

References fhicl::ParameterSet::get_if_present(), fhicl::detail::ParameterBase::key(), and fhicl::detail::strip_first_containing_name().

Referenced by do_set_value().

111  {
112  // Kind of tricky: we do not have the name of the current
113  // parameter set. A placeholder is often used
114  // (e.g. "<top_level>"). Fortunately, since the pset is passed
115  // in, we can just assign to it for a top-level ParameterSet.
116  // However, for nested parameter sets, we need to trim off the
117  // placeholder, and then the key we send
118  // pset.get<fhicl::ParameterSet>(key) is the key relative to the
119  // top-level pset.
120  std::string const& rkey = key();
121  std::string const& nkey = strip_first_containing_name(rkey);
122  if (nkey == rkey) {
123  return std::make_optional(pset);
124  }
125  return pset.get_if_present<ParameterSet>(nkey);
126  }
std::string strip_first_containing_name(std::string const &key)
std::string const & key() const
Definition: ParameterBase.cc:6
std::vector< cet::exempt_ptr< ParameterBase > > const & fhicl::detail::TableBase::members ( ) const

Definition at line 31 of file TableBase.cc.

References members_.

32  {
33  return members_;
34  }
std::vector< cet::exempt_ptr< ParameterBase > > members_
Definition: TableBase.h:45
bool fhicl::detail::ParameterBase::preset_value ( fhicl::ParameterSet const &  ps)
inherited

Definition at line 63 of file ParameterBase.cc.

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

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

64  {
65  return do_preset_value(ps);
66  }
virtual bool do_preset_value(fhicl::ParameterSet const &)
void fhicl::detail::TableBase::print_allowed_configuration ( std::ostream &  os,
std::string const &  tab = std::string(3, ' ') 
) const

Definition at line 22 of file TableBase.cc.

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

Referenced by art::operator<<(), and fhicl::detail::operator<<().

24  {
25  os << '\n' << tab << optional_parameter_message() << '\n';
26  PrintAllowedConfiguration pc{os, false, tab};
27  pc.walk_over(*this);
28  }
std::string optional_parameter_message(bool const with_comment=true)
std::optional< ParameterSet > fhicl::detail::TableBase::select_pset ( ParameterSet const &  pset) const
private

Definition at line 92 of file TableBase.cc.

References fhicl::ParameterSet::get(), fhicl::detail::ParameterBase::key(), and fhicl::detail::strip_first_containing_name().

Referenced by do_set_value().

93  {
94  // Kind of tricky: we do not have the name of the current
95  // parameter set. A placeholder is often used (e.g. "<top_level>").
96  // Fortunately, since the pset is passed in, we can just assign to
97  // it for a top-level ParameterSet. However, for nested parameter
98  // sets, we need to trim off the placeholder, and then the key we
99  // send pset.get<fhicl::ParameterSet>(key) is the key relative to
100  // the top-level pset.
101  std::string const& rkey = key();
102  std::string const& nkey = strip_first_containing_name(rkey);
103  if (nkey == rkey) {
104  return std::make_optional(pset);
105  }
106  return pset.get<ParameterSet>(nkey);
107  }
std::string strip_first_containing_name(std::string const &key)
std::string const & key() const
Definition: ParameterBase.cc:6
void fhicl::detail::ParameterBase::set_par_style ( par_style const  vt)
inherited
void fhicl::detail::ParameterBase::set_value ( fhicl::ParameterSet const &  ps)
inherited

Definition at line 58 of file ParameterBase.cc.

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

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

59  {
60  do_set_value(ps);
61  }
virtual void do_set_value(fhicl::ParameterSet const &)=0
bool fhicl::detail::ParameterBase::should_use ( ) const
inherited

Definition at line 41 of file ParameterBase.cc.

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

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

42  {
43  return maybeUse_();
44  }
std::function< bool()> maybeUse_
Definition: ParameterBase.h:64
void fhicl::detail::TableBase::validate ( ParameterSet const &  pset,
std::set< std::string > const &  ignorable_keys = {} 
)

Definition at line 56 of file TableBase.cc.

References fhicl::NameStackRegistry::clear(), members_, and pset_.

Referenced by fhicl::OptionalTable< T >::OptionalTable(), and fhicl::Table< T, KeysToIgnore >::Table().

58  {
59  pset_ = std::make_optional(pset);
60  ValidateThenSet vs{pset, ignorable_keys};
61  cet::for_all(members_, [&vs](auto m) { vs.walk_over(*m); });
62 
63  try {
64  vs.check_keys();
65  }
66  catch (detail::validationException const&) {
68  throw;
69  }
70  }
std::vector< cet::exempt_ptr< ParameterBase > > members_
Definition: TableBase.h:45
std::optional< ParameterSet > pset_
Definition: TableBase.h:44

Member Data Documentation

std::vector<cet::exempt_ptr<ParameterBase> > fhicl::detail::TableBase::members_
private

Definition at line 45 of file TableBase.h.

Referenced by finalize_members(), maybe_implicitly_default(), members(), and validate().

std::optional<ParameterSet> fhicl::detail::TableBase::pset_
private

Definition at line 44 of file TableBase.h.

Referenced by do_set_value(), get_pset(), guarantee_pset(), has_value(), and validate().


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