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

#include "ParameterSetID.h"

Public Member Functions

 ParameterSetID () noexcept
 
 ParameterSetID (ParameterSet const &)
 
 ParameterSetID (std::string const &id)
 
bool is_valid () const noexcept
 
std::string to_string () const
 
void invalidate () noexcept
 
void reset (ParameterSet const &)
 
void swap (ParameterSetID &)
 
bool operator== (ParameterSetID const &) const noexcept
 
bool operator!= (ParameterSetID const &) const noexcept
 
bool operator< (ParameterSetID const &) const noexcept
 
bool operator> (ParameterSetID const &) const noexcept
 
bool operator<= (ParameterSetID const &) const noexcept
 
bool operator>= (ParameterSetID const &) const noexcept
 

Static Public Member Functions

static constexpr std::size_t max_str_size () noexcept
 

Private Attributes

bool valid_
 
cet::sha1::digest_t id_
 

Detailed Description

Definition at line 23 of file ParameterSetID.h.

Constructor & Destructor Documentation

ParameterSetID::ParameterSetID ( )
noexcept

Definition at line 23 of file ParameterSetID.cc.

References invalid_id.

23 : valid_{false}, id_{invalid_id} {}
cet::sha1::digest_t id_
constexpr sha1::digest_t invalid_id
ParameterSetID::ParameterSetID ( ParameterSet const &  ps)
explicit

Definition at line 25 of file ParameterSetID.cc.

References id_, and reset().

25  : valid_{false}, id_{}
26 {
27  reset(ps);
28 }
cet::sha1::digest_t id_
void reset(ParameterSet const &)
ParameterSetID::ParameterSetID ( std::string const &  id)
explicit

Definition at line 30 of file ParameterSetID.cc.

References fhicl::cant_happen, e, util::empty(), id_, invalid_id, max_str_size(), fhicl::parse_error, to_string(), and valid_.

31  : valid_{id.size() == max_str_size()}, id_{}
32 {
33  if (valid_) {
34  for (size_t i = 0, e = id_.size(); i != e; ++i) {
35  id_[i] = std::stoi(id.substr(i * 2, 2), nullptr, 16);
36  }
37  if (id != to_string()) {
39  << "ParameterSetID construction failure: " << id
40  << " != " << to_string() << ".\n";
41  }
42  } else if (id.empty()) {
43  id_ = invalid_id;
44  } else {
46  << "Attempt to construct ParameterSetID from inappropriate input: " << id
47  << ".\n";
48  }
49 }
std::string to_string() const
cet::sha1::digest_t id_
static constexpr std::size_t max_str_size() noexcept
constexpr sha1::digest_t invalid_id
Float_t e
Definition: plot.C:35
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
Definition: StdUtils.h:109

Member Function Documentation

void ParameterSetID::invalidate ( )
noexcept

Definition at line 75 of file ParameterSetID.cc.

References id_, invalid_id, and valid_.

76 {
77  valid_ = false;
78  id_ = invalid_id;
79 }
cet::sha1::digest_t id_
constexpr sha1::digest_t invalid_id
bool ParameterSetID::is_valid ( ) const
noexcept

Definition at line 54 of file ParameterSetID.cc.

References valid_.

55 {
56  return valid_;
57 }
constexpr std::size_t fhicl::ParameterSetID::max_str_size ( )
inlinestaticnoexcept

Definition at line 55 of file ParameterSetID.h.

Referenced by ParameterSetID(), fhicl::dbid_parser::parse(), and fhicl::ParameterSet::stringify_().

56 {
57  // Two hex digits per byte.
58  return 2 * cet::sha1::digest_sz;
59 }
bool ParameterSetID::operator!= ( ParameterSetID const &  other) const
noexcept

Definition at line 107 of file ParameterSetID.cc.

References id_, and fhicl::other.

108 {
109  return id_ != other.id_;
110 }
cet::sha1::digest_t id_
bool ParameterSetID::operator< ( ParameterSetID const &  other) const
noexcept

Definition at line 113 of file ParameterSetID.cc.

References id_, and fhicl::other.

114 {
115  return id_ < other.id_;
116 }
cet::sha1::digest_t id_
bool ParameterSetID::operator<= ( ParameterSetID const &  other) const
noexcept

Definition at line 125 of file ParameterSetID.cc.

References id_, and fhicl::other.

126 {
127  return id_ <= other.id_;
128 }
cet::sha1::digest_t id_
bool ParameterSetID::operator== ( ParameterSetID const &  other) const
noexcept

Definition at line 101 of file ParameterSetID.cc.

References id_, and fhicl::other.

102 {
103  return id_ == other.id_;
104 }
cet::sha1::digest_t id_
bool ParameterSetID::operator> ( ParameterSetID const &  other) const
noexcept

Definition at line 119 of file ParameterSetID.cc.

References id_, and fhicl::other.

120 {
121  return id_ > other.id_;
122 }
cet::sha1::digest_t id_
bool ParameterSetID::operator>= ( ParameterSetID const &  other) const
noexcept

Definition at line 131 of file ParameterSetID.cc.

References id_, and fhicl::other.

132 {
133  return id_ >= other.id_;
134 }
cet::sha1::digest_t id_
void ParameterSetID::reset ( ParameterSet const &  ps)

Definition at line 82 of file ParameterSetID.cc.

References id_, fhicl::ParameterSet::to_string(), and valid_.

Referenced by fhicl::ParameterSet::id(), and ParameterSetID().

83 {
84  auto const hash = ps.to_string();
85  sha1 sha{hash.c_str()};
86 
87  id_ = sha.digest();
88  valid_ = true;
89 }
cet::sha1::digest_t id_
void ParameterSetID::swap ( ParameterSetID other)

Definition at line 92 of file ParameterSetID.cc.

References id_, std::swap(), and valid_.

93 {
94  id_.swap(other.id_);
95  std::swap(valid_, other.valid_);
96 }
cet::sha1::digest_t id_
void swap(lar::deep_const_fwd_iterator_nested< CITER, INNERCONTEXTRACT > &a, lar::deep_const_fwd_iterator_nested< CITER, INNERCONTEXTRACT > &b)
string ParameterSetID::to_string ( ) const

Definition at line 60 of file ParameterSetID.cc.

References id_.

Referenced by fhicl::decompose_parameterset(), fhicl::operator<<(), and ParameterSetID().

61 {
62  std::ostringstream oss;
63  oss << std::hex << std::setfill('0');
64  // The range-for loop performs an implicit cast from 'unsigned char'
65  // to 'unsigned int'.
66  for (unsigned int const num : id_) {
67  oss << std::setw(2) << num;
68  }
69  return oss.str();
70 }
cet::sha1::digest_t id_

Member Data Documentation

cet::sha1::digest_t fhicl::ParameterSetID::id_
private
bool fhicl::ParameterSetID::valid_
private

Definition at line 49 of file ParameterSetID.h.

Referenced by invalidate(), is_valid(), ParameterSetID(), reset(), and swap().


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