LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
evgen::MarleyParameterSetWalker Class Reference

#include "MarleyParameterSetWalker.h"

Inheritance diagram for evgen::MarleyParameterSetWalker:
fhicl::ParameterSetWalker

Public Types

using key_t = std::string
 
using any_t = std::any
 

Public Member Functions

const marley::JSON & get_json () const
 
marley::JSON & get_json ()
 
void do_enter_table (key_t const &k, any_t const &a)
 
void do_enter_sequence (key_t const &k, any_t const &a)
 
void do_atom (key_t const &k, any_t const &a)
 
void do_before_action (key_t const &k, any_t const &a, ParameterSet const *ps)
 
void do_after_action (key_t const &k)
 
void do_exit_table (key_t const &k, any_t const &a)
 
void do_exit_sequence (key_t const &k, any_t const &a)
 

Private Member Functions

void enter_table (const key_t &key, const any_t &) override
 
void enter_sequence (const key_t &key, const any_t &) override
 
void atom (const key_t &key, const any_t &any) override
 
void exit_table (const key_t &, const any_t &) override
 
void exit_sequence (const key_t &, const any_t &) override
 

Private Attributes

marley::JSON full_json_
 Owned JSON object used to store the converted FHiCL parameters. More...
 
std::vector< std::reference_wrapper< marley::JSON > > json_refs_ = {full_json_}
 References to the owned JSON object or a sub-object thereof. More...
 
unsigned seq_index_ = 0u
 
bool in_seq_ = false
 

Detailed Description

Definition at line 26 of file MarleyParameterSetWalker.h.

Member Typedef Documentation

using fhicl::ParameterSetWalker::any_t = std::any
inherited

Definition at line 79 of file ParameterSetWalker.h.

using fhicl::ParameterSetWalker::key_t = std::string
inherited

Definition at line 78 of file ParameterSetWalker.h.

Member Function Documentation

void evgen::MarleyParameterSetWalker::atom ( const key_t key,
const any_t any 
)
inlineoverrideprivate

Definition at line 47 of file MarleyParameterSetWalker.h.

References in_seq_, json_refs_, seq_index_, and fhicl::detail::atom::value().

48  {
49  auto& json = json_refs_.back().get();
50  // Convert the atom to a string. Add an extra space to keep some
51  // of MARLEY's JSON parsing routines (which rely on looking ahead
52  // in some cases) happy
53  std::string atom_val = fhicl::detail::atom::value(any) + ' ';
54  marley::JSON json_atom;
55  // Hard-coded value taken from fhiclcpp/detail/printing_helpers.cc
56  if (atom_val != "@nil") {
57  std::istringstream iss(atom_val);
58  // Utility function defined in marley/JSON.hh
59  json_atom = marley::parse_next(iss);
60  }
61  if (in_seq_) { json[seq_index_++] = json_atom; }
62  else {
63  json[key] = json_atom;
64  }
65  }
std::string value(std::any const &)
std::vector< std::reference_wrapper< marley::JSON > > json_refs_
References to the owned JSON object or a sub-object thereof.
void fhicl::ParameterSetWalker::do_after_action ( key_t const &  k)
inlineinherited

Definition at line 103 of file ParameterSetWalker.h.

References fhicl::ParameterSetWalker::after_action().

Referenced by fhicl::ParameterSet::walk().

104  {
105  after_action(k);
106  }
virtual void after_action(key_t const &)
void fhicl::ParameterSetWalker::do_atom ( key_t const &  k,
any_t const &  a 
)
inlineinherited

Definition at line 92 of file ParameterSetWalker.h.

References fhicl::ParameterSetWalker::atom().

Referenced by fhicl::ParameterSet::walk().

93  {
94  atom(k, a);
95  }
virtual void atom(key_t const &, any_t const &)=0
void fhicl::ParameterSetWalker::do_before_action ( key_t const &  k,
any_t const &  a,
ParameterSet const *  ps 
)
inlineinherited

Definition at line 98 of file ParameterSetWalker.h.

References fhicl::ParameterSetWalker::before_action().

Referenced by fhicl::ParameterSet::walk().

99  {
100  before_action(k, a, ps);
101  }
virtual void before_action(key_t const &, any_t const &, ParameterSet const *)
void fhicl::ParameterSetWalker::do_enter_sequence ( key_t const &  k,
any_t const &  a 
)
inlineinherited

Definition at line 87 of file ParameterSetWalker.h.

References fhicl::ParameterSetWalker::enter_sequence().

Referenced by fhicl::ParameterSet::walk().

88  {
89  enter_sequence(k, a);
90  }
virtual void enter_sequence(key_t const &, any_t const &)=0
void fhicl::ParameterSetWalker::do_enter_table ( key_t const &  k,
any_t const &  a 
)
inlineinherited

Definition at line 82 of file ParameterSetWalker.h.

References fhicl::ParameterSetWalker::enter_table().

Referenced by fhicl::ParameterSet::walk().

83  {
84  enter_table(k, a);
85  }
virtual void enter_table(key_t const &, any_t const &)=0
void fhicl::ParameterSetWalker::do_exit_sequence ( key_t const &  k,
any_t const &  a 
)
inlineinherited
void fhicl::ParameterSetWalker::do_exit_table ( key_t const &  k,
any_t const &  a 
)
inlineinherited

Definition at line 109 of file ParameterSetWalker.h.

References fhicl::ParameterSetWalker::exit_table().

Referenced by fhicl::ParameterSet::walk().

110  {
111  exit_table(k, a);
112  }
virtual void exit_table(key_t const &, any_t const &)
void evgen::MarleyParameterSetWalker::enter_sequence ( const key_t key,
const any_t  
)
inlineoverrideprivate

Definition at line 39 of file MarleyParameterSetWalker.h.

References in_seq_, json_refs_, art::InputSourceFactory::make(), and seq_index_.

40  {
41  auto& json = json_refs_.back().get();
42  in_seq_ = true;
43  seq_index_ = 0u;
44  json_refs_.emplace_back(json[key] = marley::JSON::make(marley::JSON::DataType::Array));
45  }
std::unique_ptr< InputSource > make(fhicl::ParameterSet const &conf, InputSourceDescription &desc)
std::vector< std::reference_wrapper< marley::JSON > > json_refs_
References to the owned JSON object or a sub-object thereof.
void evgen::MarleyParameterSetWalker::enter_table ( const key_t key,
const any_t  
)
inlineoverrideprivate

Definition at line 33 of file MarleyParameterSetWalker.h.

References json_refs_, and art::InputSourceFactory::make().

34  {
35  auto& json = json_refs_.back().get();
36  json_refs_.emplace_back(json[key] = marley::JSON::make(marley::JSON::DataType::Object));
37  }
std::unique_ptr< InputSource > make(fhicl::ParameterSet const &conf, InputSourceDescription &desc)
std::vector< std::reference_wrapper< marley::JSON > > json_refs_
References to the owned JSON object or a sub-object thereof.
void evgen::MarleyParameterSetWalker::exit_sequence ( const key_t ,
const any_t  
)
inlineoverrideprivate

Definition at line 69 of file MarleyParameterSetWalker.h.

References in_seq_, and json_refs_.

70  {
71  json_refs_.pop_back();
72  in_seq_ = false;
73  }
std::vector< std::reference_wrapper< marley::JSON > > json_refs_
References to the owned JSON object or a sub-object thereof.
void evgen::MarleyParameterSetWalker::exit_table ( const key_t ,
const any_t  
)
inlineoverrideprivate

Definition at line 67 of file MarleyParameterSetWalker.h.

References json_refs_.

67 { json_refs_.pop_back(); }
std::vector< std::reference_wrapper< marley::JSON > > json_refs_
References to the owned JSON object or a sub-object thereof.
const marley::JSON& evgen::MarleyParameterSetWalker::get_json ( ) const
inline

Definition at line 29 of file MarleyParameterSetWalker.h.

References full_json_.

Referenced by evgen::MARLEYHelper::reconfigure().

29 { return full_json_; }
marley::JSON full_json_
Owned JSON object used to store the converted FHiCL parameters.
marley::JSON& evgen::MarleyParameterSetWalker::get_json ( )
inline

Definition at line 30 of file MarleyParameterSetWalker.h.

References full_json_.

30 { return full_json_; }
marley::JSON full_json_
Owned JSON object used to store the converted FHiCL parameters.

Member Data Documentation

marley::JSON evgen::MarleyParameterSetWalker::full_json_
private

Owned JSON object used to store the converted FHiCL parameters.

Definition at line 76 of file MarleyParameterSetWalker.h.

Referenced by get_json().

bool evgen::MarleyParameterSetWalker::in_seq_ = false
private

Definition at line 82 of file MarleyParameterSetWalker.h.

Referenced by atom(), enter_sequence(), and exit_sequence().

std::vector<std::reference_wrapper<marley::JSON> > evgen::MarleyParameterSetWalker::json_refs_ = {full_json_}
private

References to the owned JSON object or a sub-object thereof.

Definition at line 79 of file MarleyParameterSetWalker.h.

Referenced by atom(), enter_sequence(), enter_table(), exit_sequence(), and exit_table().

unsigned evgen::MarleyParameterSetWalker::seq_index_ = 0u
private

Definition at line 81 of file MarleyParameterSetWalker.h.

Referenced by atom(), and enter_sequence().


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