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

#include "NameStackRegistry.h"

Static Public Member Functions

static std::string full_key (std::string const &key)
 
static void end_of_ctor ()
 
static void clear ()
 
static bool empty ()
 
static std::string current ()
 

Static Private Member Functions

static NameStackRegistryinstance_ ()
 

Private Attributes

std::vector< std::string > names_ {}
 

Detailed Description

Definition at line 43 of file NameStackRegistry.h.

Member Function Documentation

void fhicl::NameStackRegistry::clear ( )
static

Definition at line 37 of file NameStackRegistry.cc.

References instance_(), and names_.

Referenced by fhicl::detail::TableBase::validate().

38  {
39  instance_().names_.clear();
40  }
static NameStackRegistry & instance_()
std::vector< std::string > names_
std::string fhicl::NameStackRegistry::current ( )
static

Definition at line 49 of file NameStackRegistry.cc.

References instance_(), and names_.

Referenced by fhicl::OptionalSequence< T,-1ull >::do_prepare_elements_for_validation(), and fhicl::Sequence< T,-1ull >::do_prepare_elements_for_validation().

50  {
51  return instance_().names_.back();
52  }
static NameStackRegistry & instance_()
std::vector< std::string > names_
bool fhicl::NameStackRegistry::empty ( )
static

Definition at line 43 of file NameStackRegistry.cc.

References instance_(), and names_.

Referenced by fhicl::OptionalSequence< T,-1ull >::do_prepare_elements_for_validation(), and fhicl::Sequence< T,-1ull >::do_prepare_elements_for_validation().

44  {
45  return instance_().names_.empty();
46  }
static NameStackRegistry & instance_()
std::vector< std::string > names_
std::string fhicl::NameStackRegistry::full_key ( std::string const &  key)
static

Definition at line 14 of file NameStackRegistry.cc.

References instance_(), names_, and fhicl::other.

Referenced by fhicl::detail::ParameterMetadata::ParameterMetadata().

15  {
16  if (name.empty()) {
17  throw exception{error::other, "NameStackRegistry::full_key"}
18  << "Cannot insert empty name into 'NameStackRegistry'.\n";
19  }
20 
21  auto& names = instance_().names_;
22  if (names.empty() || std::regex_match(name, re_sequence_element)) {
23  names.emplace_back(name);
24  } else {
25  names.emplace_back("." + name);
26  }
27  return std::accumulate(names.begin(), names.end(), std::string{});
28  }
static NameStackRegistry & instance_()
std::vector< std::string > names_
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
NameStackRegistry & fhicl::NameStackRegistry::instance_ ( )
staticprivate

Definition at line 55 of file NameStackRegistry.cc.

References fhicl::detail::per_thread_holder< T >::slot_for_current_thread().

Referenced by clear(), current(), empty(), end_of_ctor(), and full_key().

56  {
57  // The use of the registry is restricted to the construction of
58  // fhiclcpp types. As construction happens on only one thread,
59  // it is sufficient for each thread to have its own copy.
60  // Although a thread-local static would be appropriate here, not
61  // all implementations adequately support thread-local variables
62  // for the use case here. We thus use a custom-built per-thread
63  // cache.
64  static detail::per_thread_holder<NameStackRegistry> registry;
65  return registry.slot_for_current_thread();
66  }

Member Data Documentation

std::vector<std::string> fhicl::NameStackRegistry::names_ {}
private

Definition at line 53 of file NameStackRegistry.h.

Referenced by clear(), current(), empty(), end_of_ctor(), and full_key().


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