LArSoft  v07_13_02
Liquid Argon Software toolkit - http://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
 
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 52 of file SearchAllowedConfiguration.h.

Constructor & Destructor Documentation

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

Definition at line 15 of file SearchAllowedConfiguration.cc.

References form_absolute().

18  : key_{form_absolute(pb, searched_for_key)}
19 {}
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 79 of file SearchAllowedConfiguration.h.

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

Definition at line 22 of file SearchAllowedConfiguration.cc.

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

Referenced by result().

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

Definition at line 82 of file SearchAllowedConfiguration.h.

References form_absolute().

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

Definition at line 98 of file ParameterWalker.h.

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

99  {
100  after_action(p);
101  }
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 126 of file ParameterWalker.h.

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

127  {
128  atom(a);
129  }
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 93 of file ParameterWalker.h.

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

94  {
95  return before_action(p);
96  }
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 115 of file ParameterWalker.h.

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

116  {
117  enter_sequence(s);
118  }
Float_t s
Definition: plot.C:23
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 104 of file ParameterWalker.h.

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

105  {
106  enter_table(t);
107  }
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 120 of file ParameterWalker.h.

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

121  {
122  exit_sequence(s);
123  }
Float_t s
Definition: plot.C:23
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 109 of file ParameterWalker.h.

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

110  {
111  exit_table(t);
112  }
virtual void exit_table(tt::maybe_const_t< TableBase, C > &)
void fhicl::detail::SearchAllowedConfiguration::enter_sequence ( SequenceBase const &  )
inlineoverrideprivate

Definition at line 76 of file SearchAllowedConfiguration.h.

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

Definition at line 73 of file SearchAllowedConfiguration.h.

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

Definition at line 34 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().

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

Definition at line 66 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 7 of file SearchAllowedConfiguration.cc.

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

9 {
10  SearchAllowedConfiguration sac{pb, searched_for_key};
11  sac.walk_over(pb);
12  return sac.result();
13 }
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 59 of file SearchAllowedConfiguration.h.

Referenced by before_action().

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

Definition at line 60 of file SearchAllowedConfiguration.h.

Referenced by before_action(), and result().


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