LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
fhicl::ParameterSetID Class Reference

#include "ParameterSetID.h"

Public Member Functions

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

Static Public Member Functions

static std::size_t max_str_size ()
 

Private Attributes

bool valid_
 
cet::sha1::digest_t id_
 

Detailed Description

Definition at line 23 of file ParameterSetID.h.

Constructor & Destructor Documentation

ParameterSetID::ParameterSetID ( )

Definition at line 31 of file ParameterSetID.cc.

31 : valid_(false), id_(invalid_id_()) {}
cet::sha1::digest_t id_
static digest_t const & invalid_id_()
ParameterSetID::ParameterSetID ( ParameterSet const &  ps)
explicit

Definition at line 33 of file ParameterSetID.cc.

References reset().

33  : valid_(false), id_()
34 {
35  reset(ps);
36 }
cet::sha1::digest_t id_
void reset(ParameterSet const &)
ParameterSetID::ParameterSetID ( std::string const &  id)
explicit

Definition at line 38 of file ParameterSetID.cc.

References fhicl::cant_happen, e, id_, invalid_id_(), fhicl::parse_error, to_string(), and valid_.

39  : valid_(id.size() == max_str_size()), id_()
40 {
41  if (valid_) {
42  for (size_t i = 0, e = id_.size(); i != e; ++i) {
43  id_[i] = std::stoi(id.substr(i * 2, 2), nullptr, 16);
44  }
45  if (id != to_string()) {
47  << "ParameterSetID construction failure: " << id
48  << " != " << to_string() << ".\n";
49  }
50  } else if (id.empty()) {
51  id_ = invalid_id_();
52  } else {
54  << "Attempt to construct ParameterSetID from inappropriate input: " << id
55  << ".\n";
56  }
57 }
std::string to_string() const
cet::sha1::digest_t id_
static std::size_t max_str_size()
static digest_t const & invalid_id_()
Float_t e
Definition: plot.C:34
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33

Member Function Documentation

void ParameterSetID::invalidate ( )

Definition at line 79 of file ParameterSetID.cc.

References id_, invalid_id_(), and valid_.

80 {
81  valid_ = false;
82  id_ = invalid_id_();
83 }
cet::sha1::digest_t id_
static digest_t const & invalid_id_()
bool ParameterSetID::is_valid ( ) const

Definition at line 62 of file ParameterSetID.cc.

References valid_.

63 {
64  return valid_;
65 }
std::size_t fhicl::ParameterSetID::max_str_size ( )
inlinestatic

Definition at line 57 of file ParameterSetID.h.

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

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

Definition at line 110 of file ParameterSetID.cc.

References id_.

111 {
112  return id_ != other.id_;
113 }
cet::sha1::digest_t id_
bool ParameterSetID::operator< ( ParameterSetID const &  other) const

Definition at line 116 of file ParameterSetID.cc.

References id_.

117 {
118  return id_ < other.id_;
119 }
cet::sha1::digest_t id_
bool ParameterSetID::operator<= ( ParameterSetID const &  other) const

Definition at line 128 of file ParameterSetID.cc.

References id_.

129 {
130  return id_ <= other.id_;
131 }
cet::sha1::digest_t id_
bool ParameterSetID::operator== ( ParameterSetID const &  other) const

Definition at line 104 of file ParameterSetID.cc.

References id_.

105 {
106  return id_ == other.id_;
107 }
cet::sha1::digest_t id_
bool ParameterSetID::operator> ( ParameterSetID const &  other) const

Definition at line 122 of file ParameterSetID.cc.

References id_.

123 {
124  return id_ > other.id_;
125 }
cet::sha1::digest_t id_
bool ParameterSetID::operator>= ( ParameterSetID const &  other) const

Definition at line 134 of file ParameterSetID.cc.

References id_.

135 {
136  return id_ >= other.id_;
137 }
cet::sha1::digest_t id_
void ParameterSetID::reset ( ParameterSet const &  ps)

Definition at line 86 of file ParameterSetID.cc.

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

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

87 {
88  string const& hash(ps.to_string());
89  sha1 sha(hash.c_str());
90 
91  id_ = sha.digest(), valid_ = true;
92 }
cet::sha1::digest_t id_
void ParameterSetID::swap ( ParameterSetID other)

Definition at line 95 of file ParameterSetID.cc.

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

Referenced by art::TriggerResults::swap().

96 {
97  id_.swap(other.id_);
98  std::swap(valid_, other.valid_);
99 }
cet::sha1::digest_t id_
void swap(art::HLTGlobalStatus &lhs, art::HLTGlobalStatus &rhs)
string ParameterSetID::to_string ( ) const

Definition at line 68 of file ParameterSetID.cc.

References id_, and s.

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

69 {
70  string s;
71  for (std::size_t i = 0; i != id_.size(); ++i)
72  s += str(format("%02x") % (unsigned int)id_[i]);
73  return s;
74 }
Float_t s
Definition: plot.C:23
cet::sha1::digest_t id_

Member Data Documentation

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

Definition at line 51 of file ParameterSetID.h.

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


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