Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
fhicl::detail::SearchAllowedConfiguration Class Reference

#include <SearchAllowedConfiguration.h>

Inheritance diagram for fhicl::detail::SearchAllowedConfiguration:
fhicl::detail::ParameterWalker< tt::const_flavor::require_const >

Static Public Member Functions

static bool supports_key (ParameterBase const &pb, std::string const &searched_for_key)
 

Private Member Functions

 SearchAllowedConfiguration (ParameterBase const &pb, std::string const &searched_for_key)
 
bool result () const noexcept
 
bool before_action (ParameterBase const &pb) override
 
void enter_table (TableBase const &) override
 
void enter_sequence (SequenceBase const &) override
 
void atom (AtomBase const &) override
 
void delegated_parameter (DelegateBase const &) override
 

Static Private Member Functions

static std::string form_absolute (ParameterBase const &pb, std::string const &searched_for_key)
 

Private Attributes

std::string key_
 
bool supportsKey_ {false}
 

Additional Inherited Members

- Public Member Functions inherited from fhicl::detail::ParameterWalker< tt::const_flavor::require_const >
 ParameterWalker ()=default
 
virtual ~ParameterWalker ()=default
 
void walk_over (tt::maybe_const_t< ParameterBase, C > &)
 
bool do_before_action (tt::maybe_const_t< ParameterBase, C > &p)
 
void do_after_action (tt::maybe_const_t< ParameterBase, C > &p)
 
void do_enter_table (tt::maybe_const_t< TableBase, C > &t)
 
void do_exit_table (tt::maybe_const_t< TableBase, C > &t)
 
void do_enter_sequence (tt::maybe_const_t< SequenceBase, C > &s)
 
void do_exit_sequence (tt::maybe_const_t< SequenceBase, C > &s)
 
void do_atom (tt::maybe_const_t< AtomBase, C > &a)
 
void do_delegated_parameter (tt::maybe_const_t< DelegateBase, C > &dp)
 

Detailed Description

Definition at line 51 of file SearchAllowedConfiguration.h.

Constructor & Destructor Documentation

SearchAllowedConfiguration::SearchAllowedConfiguration ( ParameterBase const &  pb,
std::string const &  searched_for_key 
)
private

Definition at line 16 of file SearchAllowedConfiguration.cc.

19  : key_{form_absolute(pb, searched_for_key)}
20 {}
static std::string form_absolute(ParameterBase const &pb, std::string const &searched_for_key)
static constexpr double pb
Definition: Units.h:82

Member Function Documentation

void fhicl::detail::SearchAllowedConfiguration::atom ( AtomBase const &  )
inlineoverrideprivate

Definition at line 78 of file SearchAllowedConfiguration.h.

79  {}
bool SearchAllowedConfiguration::before_action ( ParameterBase const &  pb)
overrideprivate

Definition at line 23 of file SearchAllowedConfiguration.cc.

24 {
25  supportsKey_ = supportsKey_ || pb.key() == key_;
26  // If supportsKey_ is true, then a match has been found, and no
27  // extra tree-walking is required--so this function should
28  // return false. If supportsKey_ is false, then continue
29  // looking through the tree to see if another parameter
30  // matches--i.e. it should return true.
31  return !supportsKey_;
32 }
static constexpr double pb
Definition: Units.h:82
void fhicl::detail::SearchAllowedConfiguration::delegated_parameter ( DelegateBase const &  )
inlineoverrideprivate

Definition at line 81 of file SearchAllowedConfiguration.h.

82  {}
void fhicl::detail::SearchAllowedConfiguration::enter_sequence ( SequenceBase const &  )
inlineoverrideprivate

Definition at line 75 of file SearchAllowedConfiguration.h.

76  {}
void fhicl::detail::SearchAllowedConfiguration::enter_table ( TableBase const &  )
inlineoverrideprivate

Definition at line 72 of file SearchAllowedConfiguration.h.

73  {}
std::string SearchAllowedConfiguration::form_absolute ( ParameterBase const &  pb,
std::string const &  searched_for_key 
)
staticprivate

Definition at line 35 of file SearchAllowedConfiguration.cc.

37 {
38  if (searched_for_key.empty()) {
39  throw exception{error::other, "SearchAllowedConfiguration::form_absolute"}
40  << "The specified searched-for key is empty.\n";
41  }
42 
43  auto const pt = pb.parameter_type();
44  if (!is_table(pt) && !is_sequence(pt)) {
45  throw exception{error::other, "SearchAllowedConfiguration::form_absolute"}
46  << "Attempt to search for '" << searched_for_key
47  << "' as supported by a\n"
48  << "parameter that is not a table or sequence.\n";
49  }
50 
51  // assume searched-for key is meant to be relative to the
52  // top_level_key.
53  std::string const appending_character{is_table(pt) ? "." : ""};
54  std::string absolute_key{pb.key()};
55  absolute_key += appending_character;
56  absolute_key += searched_for_key;
57  return absolute_key;
58 }
std::string string
Definition: nybbler.cc:12
bool is_table(std::any const &val)
Definition: coding.h:55
static constexpr double pb
Definition: Units.h:82
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
bool is_sequence(std::any const &val)
Definition: coding.h:49
bool fhicl::detail::SearchAllowedConfiguration::result ( ) const
inlineprivatenoexcept

Definition at line 65 of file SearchAllowedConfiguration.h.

bool SearchAllowedConfiguration::supports_key ( ParameterBase const &  pb,
std::string const &  searched_for_key 
)
static

Definition at line 8 of file SearchAllowedConfiguration.cc.

10 {
11  SearchAllowedConfiguration sac{pb, searched_for_key};
12  sac.walk_over(pb);
13  return sac.result();
14 }
static constexpr double pb
Definition: Units.h:82

Member Data Documentation

std::string fhicl::detail::SearchAllowedConfiguration::key_
private

Definition at line 58 of file SearchAllowedConfiguration.h.

bool fhicl::detail::SearchAllowedConfiguration::supportsKey_ {false}
private

Definition at line 59 of file SearchAllowedConfiguration.h.


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