Static Public Member Functions | Static Private Member Functions | Private Attributes | List of all members
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::stringnames_ {}
 

Detailed Description

Definition at line 45 of file NameStackRegistry.h.

Member Function Documentation

static void fhicl::NameStackRegistry::clear ( )
inlinestatic

Definition at line 56 of file NameStackRegistry.h.

57  {
58  instance_().names_.clear();
59  }
static NameStackRegistry & instance_()
std::vector< std::string > names_
static std::string fhicl::NameStackRegistry::current ( )
inlinestatic

Definition at line 68 of file NameStackRegistry.h.

69  {
70  return instance_().names_.back();
71  }
static NameStackRegistry & instance_()
std::vector< std::string > names_
static bool fhicl::NameStackRegistry::empty ( )
inlinestatic

Definition at line 62 of file NameStackRegistry.h.

63  {
64  return instance_().names_.empty();
65  }
static NameStackRegistry & instance_()
std::vector< std::string > names_
static void fhicl::NameStackRegistry::end_of_ctor ( )
inlinestatic

Definition at line 50 of file NameStackRegistry.h.

51  {
52  instance_().names_.pop_back();
53  }
static NameStackRegistry & instance_()
std::vector< std::string > names_
std::string fhicl::NameStackRegistry::full_key ( std::string const &  key)
static

Definition at line 13 of file NameStackRegistry.cc.

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

Definition at line 77 of file NameStackRegistry.h.

78  {
79  // The use of the registry is restricted to the construction of
80  // fhiclcpp types. As construction happens on only one thread,
81  // it is sufficient for each thread to have its own copy.
82  // Although a thread-local static would be appropriate here, not
83  // all implementations adequately support thread-local variables
84  // for the use case here. We thus use a custom-built per-thread
85  // cache.
86  static detail::per_thread_holder<NameStackRegistry> registry;
87  return registry.slot_for_current_thread();
88  }

Member Data Documentation

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

Definition at line 74 of file NameStackRegistry.h.


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