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

#include "SearchAllowedConfiguration.h"

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

Public Member Functions

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)
 

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}
 

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.

References form_absolute().

19  : key_{form_absolute(pb, searched_for_key)}
20 {}
static std::string form_absolute(ParameterBase const &pb, std::string const &searched_for_key)

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.

References fhicl::detail::ParameterBase::key(), key_, and supportsKey_.

Referenced by result().

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 }
void fhicl::detail::SearchAllowedConfiguration::delegated_parameter ( DelegateBase const &  )
inlineoverrideprivate

Definition at line 81 of file SearchAllowedConfiguration.h.

References form_absolute().

82  {}
void fhicl::detail::ParameterWalker< C >::do_after_action ( tt::maybe_const_t< ParameterBase, C > &  p)
inlineinherited

Definition at line 96 of file ParameterWalker.h.

References fhicl::detail::ParameterWalker< C >::after_action().

97  {
98  after_action(p);
99  }
virtual void after_action(tt::maybe_const_t< ParameterBase, C > &)
void fhicl::detail::ParameterWalker< C >::do_atom ( tt::maybe_const_t< AtomBase, C > &  a)
inlineinherited

Definition at line 124 of file ParameterWalker.h.

References fhicl::detail::ParameterWalker< C >::atom().

125  {
126  atom(a);
127  }
virtual void atom(tt::maybe_const_t< AtomBase, C > &)=0
bool fhicl::detail::ParameterWalker< C >::do_before_action ( tt::maybe_const_t< ParameterBase, C > &  p)
inlineinherited

Definition at line 91 of file ParameterWalker.h.

References fhicl::detail::ParameterWalker< C >::before_action().

92  {
93  return before_action(p);
94  }
virtual bool before_action(tt::maybe_const_t< ParameterBase, C > &)
void fhicl::detail::ParameterWalker< C >::do_enter_sequence ( tt::maybe_const_t< SequenceBase, C > &  s)
inlineinherited

Definition at line 113 of file ParameterWalker.h.

References fhicl::detail::ParameterWalker< C >::enter_sequence().

114  {
115  enter_sequence(s);
116  }
virtual void enter_sequence(tt::maybe_const_t< SequenceBase, C > &)=0
void fhicl::detail::ParameterWalker< C >::do_enter_table ( tt::maybe_const_t< TableBase, C > &  t)
inlineinherited

Definition at line 102 of file ParameterWalker.h.

References fhicl::detail::ParameterWalker< C >::enter_table().

103  {
104  enter_table(t);
105  }
virtual void enter_table(tt::maybe_const_t< TableBase, C > &)=0
void fhicl::detail::ParameterWalker< C >::do_exit_sequence ( tt::maybe_const_t< SequenceBase, C > &  s)
inlineinherited

Definition at line 118 of file ParameterWalker.h.

References fhicl::detail::ParameterWalker< C >::exit_sequence().

119  {
120  exit_sequence(s);
121  }
virtual void exit_sequence(tt::maybe_const_t< SequenceBase, C > &)
void fhicl::detail::ParameterWalker< C >::do_exit_table ( tt::maybe_const_t< TableBase, C > &  t)
inlineinherited

Definition at line 107 of file ParameterWalker.h.

References fhicl::detail::ParameterWalker< C >::exit_table().

108  {
109  exit_table(t);
110  }
virtual void exit_table(tt::maybe_const_t< TableBase, C > &)
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.

References fhicl::detail::is_sequence(), fhicl::detail::is_table(), fhicl::detail::ParameterBase::key(), fhicl::other, fhicl::detail::ParameterBase::parameter_type(), and pt.

Referenced by delegated_parameter(), and SearchAllowedConfiguration().

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 }
TMarker * pt
Definition: egs.C:25
bool is_table(std::any const &val)
Definition: coding.h:55
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.

References before_action(), and supportsKey_.

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

Definition at line 8 of file SearchAllowedConfiguration.cc.

Referenced by art::detail::supports_key().

10 {
11  SearchAllowedConfiguration sac{pb, searched_for_key};
12  sac.walk_over(pb);
13  return sac.result();
14 }
void walk_over(tt::maybe_const_t< ParameterBase, C > &)
void fhicl::detail::ParameterWalker< C >::walk_over ( tt::maybe_const_t< ParameterBase, C > &  )
inherited

Member Data Documentation

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

Definition at line 58 of file SearchAllowedConfiguration.h.

Referenced by before_action().

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

Definition at line 59 of file SearchAllowedConfiguration.h.

Referenced by before_action(), and result().


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