LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
fhicl::ParameterSet Class Reference

#include "ParameterSet.h"

Public Types

using ps_atom_t = fhicl::detail::ps_atom_t
 
using ps_sequence_t = fhicl::detail::ps_sequence_t
 
using annot_t = std::unordered_map< std::string, std::string >
 

Public Member Functions

bool is_empty () const
 
ParameterSetID id () const
 
std::string to_string () const
 
std::string to_compact_string () const
 
std::string to_indented_string () const
 
std::string to_indented_string (unsigned initial_indent_level) const
 
std::string to_indented_string (unsigned initial_indent_level, bool annotate) const
 
std::string to_indented_string (unsigned initial_indent_level, detail::print_mode pm) const
 
std::vector< std::string > get_names () const
 
std::vector< std::string > get_pset_names () const
 
std::vector< std::string > get_all_keys () const
 
bool has_key (std::string const &key) const
 
bool is_key_to_table (std::string const &key) const
 
bool is_key_to_sequence (std::string const &key) const
 
bool is_key_to_atom (std::string const &key) const
 
template<class T >
bool get_if_present (std::string const &key, T &value) const
 
template<class T , class Via >
bool get_if_present (std::string const &key, T &value, T convert(Via const &)) const
 
template<class T >
get (std::string const &key) const
 
template<class T , class Via >
get (std::string const &key, T convert(Via const &)) const
 
template<class T >
get (std::string const &key, T const &default_value) const
 
template<class T , class Via >
get (std::string const &key, T const &default_value, T convert(Via const &)) const
 
std::string get_src_info (std::string const &key) const
 
void walk (ParameterSetWalker &psw) const
 
void put (std::string const &key)
 
template<class T >
void put (std::string const &key, T const &value)
 
void put_or_replace (std::string const &key)
 
template<class T >
void put_or_replace (std::string const &key, T const &value)
 
template<class T >
void put_or_replace_compatible (std::string const &key, T const &value)
 
bool erase (std::string const &key)
 
bool operator== (ParameterSet const &other) const
 
bool operator!= (ParameterSet const &other) const
 
template<>
void put (std::string const &key, fhicl::extended_value const &value)
 

Private Types

using map_t = std::map< std::string, boost::any >
 
using map_iter_t = map_t::const_iterator
 

Private Member Functions

void insert_ (std::string const &key, boost::any const &value)
 
void insert_or_replace_ (std::string const &key, boost::any const &value)
 
void insert_or_replace_compatible_ (std::string const &key, boost::any const &value)
 
std::string to_string_ (bool compact=false) const
 
std::string stringify_ (boost::any const &a, bool compact=false) const
 
bool key_is_type_ (std::string const &key, std::function< bool(boost::any const &)> func) const
 
template<class T >
bool get_one_ (std::string const &key, T &value) const
 
bool find_one_ (std::string const &key) const
 
bool descend_ (std::vector< std::string > const &names, ParameterSet &ps) const
 

Private Attributes

map_t mapping_
 
annot_t srcMapping_
 
ParameterSetID id_
 

Detailed Description

Definition at line 34 of file ParameterSet.h.

Member Typedef Documentation

using fhicl::ParameterSet::annot_t = std::unordered_map<std::string, std::string>

Definition at line 38 of file ParameterSet.h.

Definition at line 108 of file ParameterSet.h.

using fhicl::ParameterSet::map_t = std::map<std::string, boost::any>
private

Definition at line 107 of file ParameterSet.h.

Member Function Documentation

bool ParameterSet::descend_ ( std::vector< std::string > const &  names,
ParameterSet ps 
) const
private

Definition at line 173 of file ParameterSet.cc.

References tmp.

Referenced by get_if_present().

175 {
176  ParameterSet const* p{this};
178  for (auto const& table : names) {
179  if (!p->get_one_(table, tmp)) {
180  return false;
181  }
182  p = &tmp;
183  }
184  ps = *p; // Can't be 'tmp'. Sometimes 'names' is empty.
185  return true;
186 }
Float_t tmp
Definition: plot.C:37
bool ParameterSet::erase ( std::string const &  key)

Definition at line 282 of file ParameterSet.cc.

Referenced by art::EventProcessor::initServices_(), and strip_pset().

283 {
284  bool const did_erase{1u == mapping_.erase(key)};
285  id_.invalidate();
286  return did_erase;
287 }
ParameterSetID id_
Definition: ParameterSet.h:112
bool ParameterSet::find_one_ ( std::string const &  key) const
private

Definition at line 159 of file ParameterSet.cc.

References fhicl::detail::find_an_any(), and fhicl::detail::get_sequence_indices().

Referenced by has_key().

160 {
161  auto skey = detail::get_sequence_indices(simple_key);
162 
163  auto it = mapping_.find(skey.name());
164  if (it == mapping_.end()) {
165  return false;
166  }
167 
168  auto a = it->second;
169  return detail::find_an_any(skey.indices().cbegin(), skey.indices().cend(), a);
170 }
SequenceKey get_sequence_indices(std::string const &key)
bool find_an_any(cit_size_t it, cit_size_t const cend, boost::any &a)
template<class T >
T fhicl::ParameterSet::get ( std::string const &  key) const

Definition at line 231 of file ParameterSet.h.

References fhicl::cant_find, and get_if_present().

Referenced by art::ActionTable::ActionTable(), pmtana::AlgoCFD::AlgoCFD(), pmtana::AlgoFixedWindow::AlgoFixedWindow(), pmtana::AlgoSiPM::AlgoSiPM(), pmtana::AlgoSlidingWindow::AlgoSlidingWindow(), pmtana::AlgoThreshold::AlgoThreshold(), geo::AuxDetGeometry::AuxDetGeometry(), fhicl::detail::Prettifier::before_action(), opdet::BoDataFrameInput::BoDataFrameInput(), cluster::ClusterMatchAlg::ClusterMatchAlg(), altns::ExampleAction::Config(), mf::service::ELdestination::Category::Config::Config(), trigger::TriggerAlgoBase::Config(), reco_tool::PeakFitterGaussElimination::configure(), evwgh::GenieWeightCalc::Configure(), reco_tool::CandHitStandard::configure(), reco_tool::PeakFitterGaussian::configure(), reco_tool::CandHitDerivative::configure(), reco_tool::CandHitMorphological::configure(), spacecharge::SpaceChargeStandard::Configure(), evd_tool::ICARUSDrawer::configure(), evd_tool::MicroBooNEDrawer::configure(), lar_cluster3d::ClusterParamsBuilder::configure(), evd_tool::StandardDrawer::configure(), lar_cluster3d::kdTree::configure(), lar_cluster3d::DBScanAlg::configure(), lar_cluster3d::ClusterMergeAlg::configure(), lar_cluster3d::SpacePointHit3DBuilder::configure(), lar_cluster3d::MinSpanTreeAlg::configure(), lar_cluster3d::ClusterPathFinder::configure(), lar_cluster3d::VoronoiPathFinder::configure(), evwgh::WeightManager::Configure(), trk::TrackContainmentAlg::Configure(), lar_cluster3d::StandardHit3DBuilder::configure(), rndm::details::PerEventPolicy< SEED >::configure(), detinfo::LArPropertiesStandard::Configure(), detinfo::DetectorClocksStandard::Configure(), evgen::CosmicsGen::CosmicsGen(), rndm::details::AutoIncrementPolicy< SEED >::createSeed(), rndm::details::LinearMappingPolicy< SEED >::createSeed(), rndm::details::PredefinedOffsetPolicy< SEED >::createSeed(), evgb::CRYHelper::CRYHelper(), fhicl::decompose_parameterset(), opdet::MicrobooneOpDetResponse::doReconfigure(), shower::EMShowerAlg::EMShowerAlg(), art::EventProcessor::EventProcessor(), art::EventSelector::EventSelector(), evwgh::EventWeight::EventWeight(), art::TrivialFileDelivery::extractFileListFromPset(), opdet::FIFOHistogramAna::FIFOHistogramAna(), art::PathManager::fillAllModules_(), opdet::SimPhotonCounterAlg::FillRanges(), opdet::FlashPurityCheckAna::FlashPurityCheckAna(), cluster::FuzzyClusterMerger::FuzzyClusterMerger(), evgen::GENIEGen::GENIEGen(), geo::Geometry::Geometry(), evd::DrawingPad::GeometryDraw(), fhicl::DelegatedParameter::get(), art::detail::get_failureToPut_flag(), art::EngineCreator::get_seed_value(), rndm::details::PerInstancePolicy< SEED >::getInstanceParameter(), rndm::details::PerInstancePolicy< SEED >::getInstanceSeed(), art::TriggerNamesService::getTrigPaths(), art::EventProcessor::initSchedules_(), art::EventProcessor::initServices_(), art::ActionTable::install_(), detinfo::DetectorPropertiesServiceStandard::isDetectorPropertiesServiceStandard(), lar_pandora::LArPandora::LArPandora(), detinfo::LArPropertiesStandard::LArPropertiesStandard(), opdet::LEDCalibrationAna::LEDCalibrationAna(), evgen::LightSource::LightSource(), art::InputSourceFactory::make(), art::make_tool(), art::detail::ServiceCacheEntry::makeAndCacheService(), art::EmptyEvent::makePlugin_(), art::RPManager::makeRPs_(), art::detail::ModuleFactory::makeWorker(), art::PathsInfo::makeWorker_(), hit::MCHitAnaExample::MCHitAnaExample(), hit::MCHitFinder::MCHitFinder(), MCReco::MCReco(), sim::MCRecoEdep::MCRecoEdep(), sim::MCRecoPart::MCRecoPart(), sim::MCShowerRecoPart::MCShowerRecoPart(), sim::MCTrackRecoAlg::MCTrackRecoAlg(), mvapid::MVAAlg::MVAAlg(), evgen::NeutronOsc::NeutronOsc(), evgen::NucleonDecay::NucleonDecay(), evgen::NueAr40CCGenerator::NueAr40CCGenerator(), opdet::OpDigiAna::OpDigiAna(), opdet::OpFlashAna::OpFlashAna(), opdet::OpFlashMCTruthAna::OpFlashMCTruthAna(), opdet::OpHitAna::OpHitAna(), opdet::OpHitFinder::OpHitFinder(), opdet::OpMCDigi::OpMCDigi(), opdet::OptDetDigitizer::OptDetDigitizer(), opreco::OpticalRecoAna::OpticalRecoAna(), testing::BasicTesterEnvironment< ConfigurationClass >::ParseEnvironmentOptions(), cheat::ParticleInventoryService::ParticleInventoryService(), pmtana::PedAlgoEdges::PedAlgoEdges(), pmtana::PedAlgoRmsSlider::PedAlgoRmsSlider(), pmtana::PedAlgoRollingMean::PedAlgoRollingMean(), pmtana::PedAlgoUB::PedAlgoUB(), pmtana::PMTAna::PMTAna(), detinfo::DetectorPropertiesServiceStandard::postOpenFile(), detinfo::DetectorClocksServiceStandard::postOpenFile(), util::DetectorPropertiesServiceArgoNeuT::postOpenFile(), art::PathManager::processPathConfigs_(), art::ProvenanceDumper< DETAIL, Enable >::ProvenanceDumper(), evd::AnalysisDrawingOptions::reconfigure(), wcls::WireCellToolkit::reconfigure(), hit::HitFilterAlg::reconfigure(), evd::ColorDrawingOptions::reconfigure(), event::EventMaker::reconfigure(), evdb::Colors::reconfigure(), evd::EvdLayoutOptions::reconfigure(), evd::SimulationDrawingOptions::reconfigure(), evd::RecoDrawingOptions::reconfigure(), evdb::EventDisplay::reconfigure(), phot::PhotonVisibilityService::reconfigure(), tss::Segmentation2D::reconfigure(), filt::LArG4ParticleFilter::reconfigure(), nutools::dbi::DBIService::reconfigure(), cluster::ClusterMatchTQ::reconfigure(), trkf::CosmicTrackerAlg::reconfigure(), cluster::fuzzyClusterAlg::reconfigure(), sim::LArG4Parameters::reconfigure(), opdet::OpDigiProperties::reconfigure(), cluster::EndPointAlg::reconfigure(), pid::Chi2PIDAlg::reconfigure(), trkf::StitchAlg::reconfigure(), opdet::FlashClusterMatch::reconfigure(), hit::HitFinder::reconfigure(), corner::CornerFinderAlg::reconfigure(), trkf::SeedFinderAlgorithm::reconfigure(), trkf::SeedFinderModule::reconfigure(), lar_pandora::PFParticleTrackAna::reconfigure(), hit::DisambigCheater::reconfigure(), sppt::SpacePointAlg_TimeSort::reconfigure(), lar_pandora::PFParticleValidation::reconfigure(), calo::TrackCalorimetryAlg::reconfigure(), pid::PIDAAnalyzer::reconfigure(), cluster::DBScanAlg::reconfigure(), filter::EventFilter::reconfigure(), lar_pandora::PFParticleCosmicAna::reconfigure(), cheat::CheckBackTracking::reconfigure(), opdet::OpFlashSimpleAna::reconfigure(), vertex::CornerFinder::reconfigure(), lar_pandora::PFParticleAnalysis::reconfigure(), lar_pandora::PFParticleMonitoring::reconfigure(), lar_pandora::PFParticleHitDumper::reconfigure(), phot::PhotonLibraryAnalyzer::reconfigure(), sim::LArVoxelCalculator::reconfigure(), trkf::TCTrack::reconfigure(), calo::PrintCalorimetry::reconfigure(), hit::TTHitFinder::reconfigure(), vertex::VertexCheater::reconfigure(), lar_pandora::ConsolidatedPFParticleAnalysisTemplate::reconfigure(), filt::FinalStateParticleFilter::reconfigure(), trkf::SpacePointCheater::reconfigure(), trkf::SpacePointFinder::reconfigure(), trk::TrackContainmentTagger::reconfigure(), tss::TrackShowerHits::reconfigure(), cosmic::BeamFlashTrackMatchTaggerAlg::reconfigure(), evd::RawDrawingOptions::reconfigure(), lariov::DatabaseRetrievalAlg::Reconfigure(), lariov::SIOVPmtGainProvider::Reconfigure(), filter::ADCFilter::reconfigure(), cluster::SmallClusterFilter::reconfigure(), trk::TrackContainmentAnalyzer::reconfigure(), cluster::LineCluster::reconfigure(), util::DetectorPropertiesServiceArgoNeuT::reconfigure(), apa::DisambigAlg::reconfigure(), trkf::BezierTrackerModule::reconfigure(), opdet::OpticalRawDigitReformatter::reconfigure(), opdet::TrackTimeAssoc::reconfigure(), event::EventCheater::reconfigure(), shwf::ShowerCheater::reconfigure(), filt::FinalStateSelectFilter::reconfigure(), cheat::RecoCheckAna::reconfigure(), pid::PIDAAlg::reconfigure(), opdet::BeamFlashCompatabilityCheck::reconfigure(), evd::InfoTransfer::reconfigure(), pid::Chi2ParticleID::reconfigure(), apa::APAHitFinder::reconfigure(), lariov::SIOVElectronicsCalibProvider::Reconfigure(), calo::BezierCalorimetry::reconfigure(), cluster::TrajCluster::reconfigure(), opdet::OpFlashFinder::reconfigure(), lar_cluster3d::HoughSeedFinderAlg::reconfigure(), noisefilteralg::WireCellNoiseFilter::reconfigure(), lar_cluster3d::SkeletonAlg::reconfigure(), t0::IndirectHitParticleAssns::reconfigure(), cosmic::BeamFlashTrackMatchTagger::reconfigure(), mag::MagneticField::reconfigure(), sppt::TTSpacePointFinder::reconfigure(), trkf::FeatureTracker::reconfigure(), calo::GeneralCalorimetry::reconfigure(), filt::EmptyFilter::reconfigure(), hit::HitCheater::reconfigure(), t0::DirectHitParticleAssns::reconfigure(), larg4::ISCalculationAna::reconfigure(), trkf::TrackCheater::reconfigure(), CRHitRemoval::reconfigure(), lar_cluster3d::PCASeedFinderAlg::reconfigure(), cluster::ClusterCheater::reconfigure(), cluster::SmallClusterFinderAlg::reconfigure(), hit::HitAnaModule::reconfigure(), lar_cluster3d::ParallelHitsSeedFinderAlg::reconfigure(), hit::FFTHitFinder::reconfigure(), calo::TrackCalorimetry::reconfigure(), util::DatabaseUtil::reconfigure(), lar_cluster3d::PrincipalComponentsAlg::reconfigure(), simfilter::FilterPrimaryPDG::reconfigure(), caldata::CalWire::reconfigure(), cluster::DBcluster::reconfigure(), DUNE::NeutrinoShowerEff::reconfigure(), cluster::ClusterCrawler::reconfigure(), cosmic::TrackPFParticleMatch::reconfigure(), tca::TrajClusterAlg::reconfigure(), caldata::CalWireT962::reconfigure(), t0::MCParticleHitMatching::reconfigure(), trkf::SpacePts::reconfigure(), cluster::BlurredClustering::reconfigure(), rwgt::ReweightAna::reconfigure(), opdet::OpHitFinder::reconfigure(), cluster::fuzzyCluster::reconfigure(), phot::PhotonLibraryPropagation::reconfigure(), detsim::SimWireAna::reconfigure(), trkf::TrackKalmanCheater::reconfigure(), trkf::Track3Dreco::reconfigure(), filter::MuonFilter::reconfigure(), larg4::LArG4Ana::reconfigure(), util::LArPropertiesServiceArgoNeuT::reconfigure(), shower::EMShower::reconfigure(), shwf::ShowerFinder::reconfigure(), cosmic::CosmicPFParticleTagger::reconfigure(), evgen::NUANCEGen::reconfigure(), lariov::DetPedestalRetrievalAlg::Reconfigure(), larg::LArSimChannelAna::reconfigure(), trkf::KalmanFilterAlg::reconfigure(), cosmic::CosmicTrackTagger::reconfigure(), vertex::PrimaryVertexFinder::reconfigure(), cosmic::CosmicPCAxisTagger::reconfigure(), trkf::CCTrackMaker::reconfigure(), cosmic::CosmicClusterTagger::reconfigure(), trkf::Track3DKalmanHitAlg::reconfigure(), t0::MCParticleShowerMatching::reconfigure(), cluster::SmallClusterFinder::reconfigure(), hit::RawHitFinder::reconfigure(), cluster::MergeClusterAlg::reconfigure(), t0::MCParticleTrackMatching::reconfigure(), DUNE::NeutrinoTrackingEff::reconfigure(), hit::MagDriftAna::reconfigure(), evgen::NDKGen::reconfigure(), cluster::EndPointModule::reconfigure(), DUNE::MuonTrackingEff::reconfigure(), cluster::BlurredClusteringAlg::reconfigure(), hit::GausHitFinderAna::reconfigure(), trkf::Track3DKalmanHit::reconfigure(), hit::HitFinderAna::reconfigure(), hit::GausHitFinder::reconfigure(), cluster::HoughLineFinder::reconfigure(), CRHitRemovalByPCA::reconfigure(), trkf::TrackStitcher::reconfigure(), ems::EMShower3D::reconfigure(), trkf::BezierTrackerAlgorithm::reconfigure(), vertex::VertexFinder2D::reconfigure(), evgen::GaisserParam::reconfigure(), wc::CellTree::reconfigure(), evgen::TextFileGen::reconfigure(), hit::DPRawHitFinder::reconfigure(), detsim::SimWire::reconfigure(), shwf::ShowerReco::reconfigure(), detsim::SimWireT962::reconfigure(), vertex::FeatureVertexFinderAna::reconfigure(), hit::CCHitFinderAlg::reconfigure(), trkf::Track3DKalman::reconfigure(), trkf::SpacePointAlg::reconfigure(), lbne::PhotonCounterT0Matching::reconfigure(), util::FileCatalogMetadataExtras::reconfigure(), evgen::RadioGen::reconfigure(), detsim::SimDriftElectrons::reconfigure(), trkf::Track3DKalmanSPS::reconfigure(), cluster::ClusterCrawlerAlg::reconfigure(), t0::MCTruthT0Matching::reconfigure(), vertex::FeatureVertexFinder::reconfigure(), lar_cluster3d::Cluster3D::reconfigure(), shower::TrackShowerSeparationAlg::reconfigure(), trkf::CosmicTracker::reconfigure(), evgen::MUSUN::reconfigure(), ems::MultiEMShowers::reconfigure(), ems::MergeEMShower3D::reconfigure(), ClusteringValidation::ClusteringValidation::reconfigure(), cluster::HoughBaseAlg::reconfigure(), evdb::ServiceTable::RegisterService(), hit::RFFHitFinderAlg::RFFHitFinderAlg(), art::RPManager::RPManager(), art::run_art_common_(), evdb::ScanOptions::ScanOptions(), rndm::SeedMaster< SEED >::SeedMaster(), testing::BasicTesterEnvironment< ConfigurationClass >::ServiceParameters(), lar::standalone::SetupGeometry(), lar::standalone::SetupGeometryWithChannelMapping(), lar::standalone::SetupMessageFacility(), shower::ShowerEnergyAlg::ShowerEnergyAlg(), ShowerQuality::ShowerQuality(), ShowerReco3D::ShowerReco3D(), opdet::SimPhotonCounterAlg::SimPhotonCounterAlg(), lariov::SimpleChannelStatus::SimpleChannelStatus(), cluster::SimpleClusterMerger::SimpleClusterMerger(), detsim::SimWire::SimWire(), detsim::SimWireT962::SimWireT962(), lariov::SIOVChannelStatusProvider::SIOVChannelStatusProvider(), rndm::details::AutoIncrementPolicy< SEED >::static_configure(), rndm::details::LinearMappingPolicy< SEED >::static_configure(), rndm::details::PredefinedOffsetPolicy< SEED >::static_configure(), testing::BasicTesterEnvironment< ConfigurationClass >::TesterParameters(), ToyOneShowerGen::ToyOneShowerGen(), TrackProducerFromPFParticle::TrackProducerFromPFParticle(), TrackProducerFromTrack::TrackProducerFromTrack(), TrackProducerFromTrackTrajectory::TrackProducerFromTrackTrajectory(), opdet::TrackTimeAssocAna::TrackTimeAssocAna(), evdb::Colors::UnpackColorScale(), evdb::ParameterSetEditRow::UnpackParameter(), and cheat::PhotonBackTracker::~PhotonBackTracker().

232 {
233  T result;
234  return get_if_present(key, result) ? result :
235  throw fhicl::exception(cant_find, key);
236 }
bool get_if_present(std::string const &key, T &value) const
Definition: ParameterSet.h:208
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
template<class T , class Via >
T fhicl::ParameterSet::get ( std::string const &  key,
T   convertVia const & 
) const

Definition at line 240 of file ParameterSet.h.

References fhicl::cant_find, and get_if_present().

241 {
242  T result;
243  return get_if_present(key, result, convert) ?
244  result :
245  throw fhicl::exception(cant_find, key);
246 }
bool get_if_present(std::string const &key, T &value) const
Definition: ParameterSet.h:208
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
template<class T >
T fhicl::ParameterSet::get ( std::string const &  key,
T const &  default_value 
) const

Definition at line 250 of file ParameterSet.h.

References get_if_present().

251 {
252  T result;
253  return get_if_present(key, result) ? result : default_value;
254 }
bool get_if_present(std::string const &key, T &value) const
Definition: ParameterSet.h:208
template<class T , class Via >
T fhicl::ParameterSet::get ( std::string const &  key,
T const &  default_value,
T   convertVia const & 
) const

Definition at line 258 of file ParameterSet.h.

References get_if_present().

261 {
262  T result;
263  return get_if_present(key, result, convert) ? result : default_value;
264 }
bool get_if_present(std::string const &key, T &value) const
Definition: ParameterSet.h:208
vector< string > ParameterSet::get_all_keys ( ) const

Definition at line 151 of file ParameterSet.cc.

References fhicl::detail::KeyAssembler::result().

152 {
153  KeyAssembler ka;
154  walk(ka);
155  return ka.result();
156 }
void walk(ParameterSetWalker &psw) const
std::vector< key_t > const & result()
Definition: KeyAssembler.h:77
template<class T >
bool fhicl::ParameterSet::get_if_present ( std::string const &  key,
T &  value 
) const

Definition at line 208 of file ParameterSet.h.

References descend_(), fhicl::detail::get_names(), get_one_(), and fhicl::detail::atom::value().

Referenced by rndm::details::RangeCheckHelper< SEED >::configure(), rndm::details::RandomPolicy< SEED >::configure(), rndm::details::RandomPolicy< SEED >::createSeed(), rndm::details::LinearMappingPolicy< SEED >::createSeed(), mf::service::ELdestination::ELdestination(), evgen::GENIEGen::GENIEGen(), get(), fhicl::OptionalDelegatedParameter::get_if_present(), get_if_present(), rndm::details::PerInstancePolicy< SEED >::getInstanceParameter(), rndm::details::PerInstancePolicy< SEED >::getInstanceSeed(), util::DetectorPropertiesServiceArgoNeuT::isDetectorPropertiesServiceArgoNeuT(), detinfo::DetectorPropertiesServiceStandard::isDetectorPropertiesServiceStandard(), art::Consumer::prepareForJob(), rndm::NuRandomService::readSeedParameter(), util::DetectorPropertiesServiceArgoNeuT::reconfigure(), tca::TrajClusterAlg::reconfigure(), trkf::Track3DKalmanSPS::reconfigure(), testing::ProviderSetupClass< detinfo::DetectorClocksStandard >::setup(), testing::ProviderSetupClass< detinfo::LArPropertiesStandard >::setup(), testing::ProviderSetupClass< detinfo::DetectorPropertiesStandard >::setup(), testing::BasicTesterEnvironment< ConfigurationClass >::SetupMessageFacility(), rndm::details::LinearMappingPolicy< SEED >::static_configure(), and want_pset().

209 {
210  auto keys = detail::get_names(key);
211  ParameterSet ps;
212  return descend_(keys.tables(), ps) ? ps.get_one_(keys.last(), value) : false;
213 }
Keys get_names(std::string const &key)
std::string value(boost::any const &)
bool descend_(std::vector< std::string > const &names, ParameterSet &ps) const
template<class T , class Via >
bool fhicl::ParameterSet::get_if_present ( std::string const &  key,
T &  value,
T   convertVia const & 
) const

Definition at line 217 of file ParameterSet.h.

References get_if_present().

220 {
221  Via go_between;
222  if (!get_if_present(key, go_between)) {
223  return false;
224  }
225  result = convert(go_between);
226  return true;
227 } // get_if_present<>()
bool get_if_present(std::string const &key, T &value) const
Definition: ParameterSet.h:208
vector< string > ParameterSet::get_names ( ) const

Definition at line 129 of file ParameterSet.cc.

Referenced by fhicl::decompose_parameterset(), rndm::details::PerInstancePolicy< SEED >::getInstanceParameter(), evdb::ParameterSetEditFrame::ParameterSetEditFrame(), and art::PathManager::processPathConfigs_().

130 {
131  vector<string> keys;
132  cet::transform_all(mapping_, std::back_inserter(keys), [](auto const& pr) {
133  return pr.first;
134  });
135  return keys;
136 }
template<class T >
bool fhicl::ParameterSet::get_one_ ( std::string const &  key,
T &  value 
) const
private

Definition at line 284 of file ParameterSet.h.

References fhicl::cant_find, art::decode(), fhicl::detail::decode(), e, fhicl::detail::find_an_any(), fhicl::detail::get_sequence_indices(), put(), and fhicl::type_mismatch.

Referenced by get_if_present().

284  {
285  auto skey = detail::get_sequence_indices(key);
286 
287  map_iter_t it = mapping_.find(skey.name());
288  if (it == mapping_.end()) {
289  return false;
290  }
291 
292  auto a = it->second;
293  if (!detail::find_an_any(skey.indices().cbegin(), skey.indices().cend(), a)) {
295  }
296 
297  using detail::decode;
298  decode(a, value);
299  return true;
300 }
301 catch (fhicl::exception const& e) {
302  std::ostringstream errmsg;
303  errmsg << "\nUnsuccessful attempt to convert FHiCL parameter '" << key
304  << "' to type '" << cet::demangle_symbol(typeid(value).name())
305  << "'.\n\n"
306  << "[Specific error:]";
307  throw fhicl::exception(type_mismatch, errmsg.str(), e);
308 }
309 catch (std::exception const& e) {
310  std::ostringstream errmsg;
311  errmsg << "\nUnsuccessful attempt to convert FHiCL parameter '" << key
312  << "' to type '" << cet::demangle_symbol(typeid(value).name())
313  << "'.\n\n"
314  << "[Specific error:]\n"
315  << e.what() << "\n\n";
316  throw fhicl::exception(type_mismatch, errmsg.str());
317 }
void decode(boost::any const &, std::string &)
map_t::const_iterator map_iter_t
Definition: ParameterSet.h:108
void decode(boost::any const &a, InputTag &tag)
Definition: InputTag.cc:64
SequenceKey get_sequence_indices(std::string const &key)
std::string value(boost::any const &)
Float_t e
Definition: plot.C:34
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
bool find_an_any(cit_size_t it, cit_size_t const cend, boost::any &a)
vector< string > ParameterSet::get_pset_names ( ) const

Definition at line 139 of file ParameterSet.cc.

References fhicl::detail::is_table().

140 {
141  vector<string> keys;
142  for (auto const& pr : mapping_) {
143  if (is_table(pr.second)) {
144  keys.push_back(pr.first);
145  }
146  }
147  return keys;
148 }
bool is_table(par_type const pt)
std::string ParameterSet::get_src_info ( std::string const &  key) const

Definition at line 199 of file ParameterSet.cc.

Referenced by fhicl::detail::PrettifierAnnotated::before_action(), fhicl::detail::PrettifierPrefixAnnotated::before_action(), and fhicl::detail::ValidateThenSet::delegated_parameter().

200 {
201  auto result = srcMapping_.find(key);
202  return result != srcMapping_.cend() ? result->second : "";
203 }
bool ParameterSet::has_key ( std::string const &  key) const
ParameterSetID ParameterSet::id ( ) const
void ParameterSet::insert_ ( std::string const &  key,
boost::any const &  value 
)
private

Definition at line 234 of file ParameterSet.cc.

References fhicl::cant_insert.

Referenced by put().

235 {
236  check_put_local_key(key);
237  if (!mapping_.emplace(key, value).second) {
238  throw exception(cant_insert) << "key " << key << " already exists.";
239  }
240  id_.invalidate();
241 }
std::string value(boost::any const &)
ParameterSetID id_
Definition: ParameterSet.h:112
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void ParameterSet::insert_or_replace_ ( std::string const &  key,
boost::any const &  value 
)
private

Definition at line 244 of file ParameterSet.cc.

References fhicl::detail::atom::value().

Referenced by put_or_replace().

245 {
246  check_put_local_key(key);
247  mapping_[key] = value;
248  id_.invalidate();
249 }
std::string value(boost::any const &)
ParameterSetID id_
Definition: ParameterSet.h:112
void ParameterSet::insert_or_replace_compatible_ ( std::string const &  key,
boost::any const &  value 
)
private

Definition at line 252 of file ParameterSet.cc.

References fhicl::cant_insert, fhicl::detail::is_nil(), fhicl::detail::is_sequence(), fhicl::detail::is_table(), and fhicl::detail::atom::value().

Referenced by put_or_replace_compatible().

253 {
254  check_put_local_key(key);
255  auto item = mapping_.find(key);
256  if (item == mapping_.end()) {
257  insert_(key, value);
258  return;
259  } else {
260  if (!detail::is_nil(value)) {
261  auto is_non_nil_atom = [](any const& v) {
262  return !(detail::is_sequence(v) || detail::is_table(v) ||
263  detail::is_nil(v));
264  };
265  if (detail::is_sequence(item->second) && !detail::is_sequence(value)) {
266  throw exception(cant_insert)
267  << "can't use non-sequence to replace sequence.";
268  } else if (detail::is_table(item->second) && !detail::is_table(value)) {
269  throw exception(cant_insert) << "can't use non-table to replace table.";
270  } else if (is_non_nil_atom(item->second) &&
272  throw exception(cant_insert)
273  << "can't use non-atom to replace non-nil atom.";
274  }
275  }
276  item->second = value;
277  }
278  id_.invalidate();
279 }
bool is_nil(boost::any const &val)
Definition: coding.cc:75
bool is_sequence(boost::any const &val)
Definition: coding.h:50
bool is_table(boost::any const &val)
Definition: coding.h:56
void insert_(std::string const &key, boost::any const &value)
std::string value(boost::any const &)
ParameterSetID id_
Definition: ParameterSet.h:112
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
bool ParameterSet::is_empty ( ) const

Definition at line 97 of file ParameterSet.cc.

98 {
99  return mapping_.empty();
100 }
bool fhicl::ParameterSet::is_key_to_atom ( std::string const &  key) const
inline

Definition at line 161 of file ParameterSet.h.

References fhicl::detail::is_sequence(), fhicl::detail::is_table(), and key_is_type_().

Referenced by rndm::details::PerInstancePolicy< SEED >::getInstanceParameter(), and rndm::details::PerInstancePolicy< SEED >::getInstanceSeed().

162 {
163  return key_is_type_(key, [](boost::any const& a) {
164  return !(detail::is_sequence(a) || detail::is_table(a));
165  });
166 }
bool is_sequence(boost::any const &val)
Definition: coding.h:50
bool is_table(boost::any const &val)
Definition: coding.h:56
bool key_is_type_(std::string const &key, std::function< bool(boost::any const &)> func) const
bool fhicl::ParameterSet::is_key_to_sequence ( std::string const &  key) const
inline

Definition at line 155 of file ParameterSet.h.

References fhicl::detail::is_sequence(), and key_is_type_().

Referenced by fhicl::decompose_parameterset(), and fhicl::detail::ValidateThenSet::enter_sequence().

156 {
157  return key_is_type_(key, &detail::is_sequence);
158 }
bool is_sequence(boost::any const &val)
Definition: coding.h:50
bool key_is_type_(std::string const &key, std::function< bool(boost::any const &)> func) const
bool fhicl::ParameterSet::is_key_to_table ( std::string const &  key) const
inline

Definition at line 149 of file ParameterSet.h.

References fhicl::detail::is_table(), and key_is_type_().

Referenced by fhicl::decompose_parameterset(), rndm::details::PerInstancePolicy< SEED >::getInstanceParameter(), and rndm::details::PerInstancePolicy< SEED >::getInstanceSeed().

150 {
151  return key_is_type_(key, &detail::is_table);
152 }
bool is_table(boost::any const &val)
Definition: coding.h:56
bool key_is_type_(std::string const &key, std::function< bool(boost::any const &)> func) const
bool ParameterSet::key_is_type_ ( std::string const &  key,
std::function< bool(boost::any const &)>  func 
) const
private

Definition at line 290 of file ParameterSet.cc.

References fhicl::cant_find, fhicl::detail::find_an_any(), fhicl::detail::get_names(), fhicl::detail::get_sequence_indices(), and mapping_.

Referenced by is_key_to_atom(), is_key_to_sequence(), and is_key_to_table().

292 {
293  auto split_keys = detail::get_names(key);
294  ParameterSet ps;
295  if (!descend_(split_keys.tables(), ps)) {
296  throw exception(error::cant_find, key);
297  }
298 
299  auto skey = detail::get_sequence_indices(split_keys.last());
300 
301  auto it = ps.mapping_.find(skey.name());
302  if (it == ps.mapping_.end()) {
303  throw exception(error::cant_find, key);
304  }
305 
306  auto a = it->second;
307  return detail::find_an_any(
308  skey.indices().cbegin(), skey.indices().cend(), a) ?
309  func(a) :
310  throw exception(error::cant_find, key);
311 }
Keys get_names(std::string const &key)
SequenceKey get_sequence_indices(std::string const &key)
bool descend_(std::vector< std::string > const &names, ParameterSet &ps) const
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
bool find_an_any(cit_size_t it, cit_size_t const cend, boost::any &a)
bool fhicl::ParameterSet::operator!= ( ParameterSet const &  other) const
inline

Definition at line 275 of file ParameterSet.h.

References operator==().

276 {
277  return !operator==(other);
278 }
bool operator==(ParameterSet const &other) const
Definition: ParameterSet.h:269
bool fhicl::ParameterSet::operator== ( ParameterSet const &  other) const
inline

Definition at line 269 of file ParameterSet.h.

References id().

Referenced by operator!=().

270 {
271  return id() == other.id();
272 }
ParameterSetID id() const
void ParameterSet::put ( std::string const &  key)

Definition at line 208 of file ParameterSet.cc.

References fhicl::detail::atom::value().

Referenced by fhicl::detail::encode(), evgen::GENIEGen::GENIEGen(), get_one_(), fhicl::make_ParameterSet(), and art::TriggerNamesService::TriggerNamesService().

209 {
210  void* const value{nullptr};
211  put(key, value);
212 }
std::string value(boost::any const &)
void put(std::string const &key)
template<class T >
void fhicl::ParameterSet::put ( std::string const &  key,
T const &  value 
)

Definition at line 170 of file ParameterSet.h.

References fhicl::detail::encode(), insert_(), fhicl::detail::try_insert(), and fhicl::detail::atom::value().

171 {
172  auto insert = [this, &value](auto const& key) {
173  using detail::encode;
174  this->insert_(key, boost::any(encode(value)));
175  };
176  detail::try_insert(insert, key);
177 }
ps_atom_t encode(std::string const &)
Definition: coding.cc:87
void try_insert(L l, std::string const &key)
Definition: try_blocks.h:13
void insert_(std::string const &key, boost::any const &value)
std::string value(boost::any const &)
void fhicl::ParameterSet::put ( std::string const &  key,
fhicl::extended_value const &  value 
)

Definition at line 353 of file ParameterSet.cc.

References fhicl::detail::encode(), fhicl::detail::try_insert(), and fhicl::detail::atom::value().

354  {
355  auto insert = [this, &value](auto const& key) {
356  using detail::encode;
357  this->insert_(key, boost::any(encode(value)));
358  fill_src_info(value, key, srcMapping_);
359  };
360  detail::try_insert(insert, key);
361  }
ps_atom_t encode(std::string const &)
Definition: coding.cc:87
void try_insert(L l, std::string const &key)
Definition: try_blocks.h:13
void insert_(std::string const &key, boost::any const &value)
std::string value(boost::any const &)
void ParameterSet::put_or_replace ( std::string const &  key)

Definition at line 215 of file ParameterSet.cc.

References fhicl::unimplemented, and fhicl::detail::atom::value().

216 {
217  void* const value{nullptr};
218  put_or_replace(key, value); // Replace with nil is always OK.
219 }
std::string value(boost::any const &)
void put_or_replace(std::string const &key)
template<class T >
void fhicl::ParameterSet::put_or_replace ( std::string const &  key,
T const &  value 
)

Definition at line 181 of file ParameterSet.h.

References fhicl::detail::encode(), insert_or_replace_(), fhicl::detail::try_insert(), and fhicl::detail::atom::value().

182 {
183  auto insert_or_replace = [this, &value](auto const& key) {
184  using detail::encode;
185  this->insert_or_replace_(key, boost::any(encode(value)));
186  srcMapping_.erase(key);
187  };
188  detail::try_insert(insert_or_replace, key);
189 }
ps_atom_t encode(std::string const &)
Definition: coding.cc:87
void try_insert(L l, std::string const &key)
Definition: try_blocks.h:13
void insert_or_replace_(std::string const &key, boost::any const &value)
std::string value(boost::any const &)
template<class T >
void fhicl::ParameterSet::put_or_replace_compatible ( std::string const &  key,
T const &  value 
)

Definition at line 193 of file ParameterSet.h.

References fhicl::detail::encode(), insert_or_replace_compatible_(), fhicl::detail::try_insert(), and fhicl::detail::atom::value().

195 {
196  auto insert_or_replace_compatible = [this, &value](auto const& key) {
197  using detail::encode;
198  this->insert_or_replace_compatible_(key, boost::any(encode(value)));
199  srcMapping_.erase(key);
200  };
201  detail::try_insert(insert_or_replace_compatible, key);
202 }
ps_atom_t encode(std::string const &)
Definition: coding.cc:87
void insert_or_replace_compatible_(std::string const &key, boost::any const &value)
void try_insert(L l, std::string const &key)
Definition: try_blocks.h:13
std::string value(boost::any const &)
string ParameterSet::stringify_ ( boost::any const &  a,
bool  compact = false 
) const
private

Definition at line 67 of file ParameterSet.cc.

References e, fhicl::ParameterSetRegistry::get(), fhicl::detail::is_sequence(), fhicl::detail::is_table(), and fhicl::ParameterSetID::max_str_size().

68 {
69  string result;
70  if (is_table(a)) {
71  auto const& psid = any_cast<ParameterSetID>(a);
72  result = '{' + ParameterSetRegistry::get(psid).to_string() + '}';
73  if (compact && result.size() > (5 + ParameterSetID::max_str_size())) {
74  // Replace with a reference to the ParameterSetID;
75  result = std::string("@id::") + psid.to_string();
76  }
77  } else if (is_sequence(a)) {
78  auto const& seq = any_cast<ps_sequence_t>(a);
79  result = '[';
80  if (!seq.empty()) {
81  result.append(stringify_(*seq.begin(), compact));
82  for (auto it = seq.cbegin(), e = seq.cend(); ++it != e;) {
83  result.append(1, ',').append(stringify_(*it, compact));
84  }
85  }
86  result.append(1, ']');
87  } else { // is_atom(a)
88  ps_atom_t const str = any_cast<ps_atom_t>(a);
89  result = str == string(9, '\0') ? "@nil" : str;
90  }
91  return result;
92 } // stringify_()
std::string stringify_(boost::any const &a, bool compact=false) const
Definition: ParameterSet.cc:67
static collection_type const & get() noexcept
bool is_sequence(par_type const pt)
static std::size_t max_str_size()
bool is_table(par_type const pt)
Float_t e
Definition: plot.C:34
std::string ps_atom_t
Definition: coding.h:45
std::vector< boost::any > ps_sequence_t
Definition: coding.h:46
std::string fhicl::ParameterSet::to_compact_string ( ) const
inline

Definition at line 143 of file ParameterSet.h.

References to_string_().

Referenced by fhicl::decompose_parameterset().

144 {
145  return to_string_(true);
146 }
std::string to_string_(bool compact=false) const
string ParameterSet::to_indented_string ( ) const

Definition at line 410 of file ParameterSet.cc.

Referenced by main(), print_pset_from_file(), and testing::BasicTesterEnvironment< ConfigurationClass >::SetupMessageFacility().

411 {
412  return to_indented_string(0u);
413 }
std::string to_indented_string() const
string ParameterSet::to_indented_string ( unsigned  initial_indent_level) const

Definition at line 416 of file ParameterSet.cc.

417 {
418  return to_indented_string(initial_indent_level, false);
419 }
std::string to_indented_string() const
string ParameterSet::to_indented_string ( unsigned  initial_indent_level,
bool  annotate 
) const

Definition at line 422 of file ParameterSet.cc.

References fhicl::detail::annotated, and fhicl::detail::raw.

424 {
425  if (annotate) {
426  return to_indented_string(initial_indent_level, print_mode::annotated);
427  }
428  return to_indented_string(initial_indent_level, print_mode::raw);
429 }
std::string to_indented_string() const
string ParameterSet::to_indented_string ( unsigned  initial_indent_level,
detail::print_mode  pm 
) const

Definition at line 432 of file ParameterSet.cc.

References fhicl::detail::annotated, fhicl::detail::prefix_annotated, fhicl::detail::raw, and fhicl::detail::PrettifierPrefixAnnotated::result().

434 {
435  std::string result;
436  switch (pm) {
437  case print_mode::raw: {
438  Prettifier p{initial_indent_level};
439  walk(p);
440  result = p.result();
441  break;
442  }
443  case print_mode::annotated: {
444  PrettifierAnnotated p{initial_indent_level};
445  walk(p);
446  result = p.result();
447  break;
448  }
449  case print_mode::prefix_annotated: {
451  walk(p);
452  result = p.result();
453  break;
454  }
455  }
456  return result;
457 }
void walk(ParameterSetWalker &psw) const
std::string fhicl::ParameterSet::to_string ( ) const
inline

Definition at line 137 of file ParameterSet.h.

References to_string_().

Referenced by fhicl::ParameterSetID::reset(), and evdb::ParameterSetEditRow::UnpackParameter().

138 {
139  return to_string_();
140 }
std::string to_string_(bool compact=false) const
string ParameterSet::to_string_ ( bool  compact = false) const
private

Definition at line 112 of file ParameterSet.cc.

References e.

Referenced by to_compact_string(), and to_string().

113 {
114  string result;
115  if (mapping_.empty()) {
116  return result;
117  }
118  auto it = mapping_.begin();
119  result.append(it->first).append(1, ':').append(
120  stringify_(it->second, compact));
121  for (auto const e = mapping_.end(); ++it != e;) {
122  result.append(1, ' ').append(it->first).append(1, ':').append(
123  stringify_(it->second, compact));
124  }
125  return result;
126 }
std::string stringify_(boost::any const &a, bool compact=false) const
Definition: ParameterSet.cc:67
Float_t e
Definition: plot.C:34
void ParameterSet::walk ( ParameterSetWalker psw) const

Definition at line 367 of file ParameterSet.cc.

References fhicl::ParameterSetWalker::do_after_action(), fhicl::ParameterSetWalker::do_atom(), fhicl::ParameterSetWalker::do_before_action(), fhicl::ParameterSetWalker::do_enter_sequence(), fhicl::ParameterSetWalker::do_enter_table(), fhicl::ParameterSetWalker::do_exit_sequence(), fhicl::ParameterSetWalker::do_exit_table(), fhicl::detail::is_sequence(), fhicl::detail::is_table(), mapping_, s, and util::flags::to_string().

368 {
369  std::stack<ParameterSet const*> ps_stack;
370  ps_stack.push(this);
371 
372  std::function<void(std::string const&, boost::any const&)> act_on_element =
373  [&psw, &ps_stack, &act_on_element](std::string const& key,
374  boost::any const& a) {
375  auto const* ps = ps_stack.top();
376  psw.do_before_action(key, a, ps);
377 
378  if (is_table(a)) {
379  ParameterSet const* ps = &get_pset_via_any(a);
380  ps_stack.push(ps);
381  psw.do_enter_table(key, a);
382  for (auto const& elem : ps->mapping_) {
383  act_on_element(elem.first, elem.second);
384  }
385  psw.do_exit_table(key, a);
386  ps_stack.pop();
387  } else if (is_sequence(a)) {
388  psw.do_enter_sequence(key, a);
389  std::size_t i{};
390  for (auto const& elem : any_cast<ps_sequence_t>(a)) {
391  std::string const new_key = key + "["s + std::to_string(i++) + "]";
392  act_on_element(new_key, elem);
393  }
394  psw.do_exit_sequence(key, a);
395  } else {
396  psw.do_atom(key, a);
397  }
398 
399  psw.do_after_action();
400  };
401 
402  for (const auto& entry : mapping_) {
403  act_on_element(entry.first, entry.second);
404  }
405 }
Float_t s
Definition: plot.C:23
void do_before_action(key_t const &k, any_t const &a, ParameterSet const *ps)
bool is_sequence(par_type const pt)
void do_enter_sequence(key_t const &k, any_t const &a)
void do_exit_table(key_t const &k, any_t const &a)
void do_exit_sequence(key_t const &k, any_t const &a)
std::string to_string(Flag_t< Storage > const flag)
Convert a flag into a stream (shows its index).
Definition: BitMask.h:187
bool is_table(par_type const pt)
void do_atom(key_t const &k, any_t const &a)
void do_enter_table(key_t const &k, any_t const &a)

Member Data Documentation

ParameterSetID fhicl::ParameterSet::id_
mutableprivate

Definition at line 112 of file ParameterSet.h.

map_t fhicl::ParameterSet::mapping_
private

Definition at line 110 of file ParameterSet.h.

Referenced by key_is_type_(), and walk().

annot_t fhicl::ParameterSet::srcMapping_
private

Definition at line 111 of file ParameterSet.h.


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