LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
art::SummedValue< T > Class Template Reference

#include "SummedValue.h"

Public Member Functions

template<typename H >
std::enable_if_t< detail::is_handle_v< H > > update (H const &h)
 
template<typename H >
std::enable_if_t< detail::is_handle_v< H > > update (H const &h, T const &t)
 
void clear ()
 
bool isValid () const
 
T const & value () const
 
RangeSet const & rangeOfValidity () const
 

Private Member Functions

template<typename H >
void update_impl (H const &h, T const &t)
 

Private Attributes

value_ {}
 
RangeSet rangeOfValidity_ {RangeSet::invalid()}
 

Detailed Description

template<typename T>
class art::SummedValue< T >

Definition at line 58 of file SummedValue.h.

Member Function Documentation

template<typename T >
void art::SummedValue< T >::clear ( )
inline

Definition at line 157 of file SummedValue.h.

References tmp.

158  {
159  SummedValue<T> tmp{};
160  std::swap(*this, tmp);
161  }
Float_t tmp
Definition: plot.C:35
void swap(lar::deep_const_fwd_iterator_nested< CITER, INNERCONTEXTRACT > &a, lar::deep_const_fwd_iterator_nested< CITER, INNERCONTEXTRACT > &b)
template<typename T >
bool art::SummedValue< T >::isValid ( ) const
inline

Definition at line 165 of file SummedValue.h.

References art::RangeSet::is_valid(), and art::SummedValue< T >::rangeOfValidity_.

166  {
167  return rangeOfValidity_.is_valid();
168  }
RangeSet rangeOfValidity_
Definition: SummedValue.h:125
bool is_valid() const
Definition: RangeSet.cc:117
template<typename T >
RangeSet const & art::SummedValue< T >::rangeOfValidity ( ) const

Definition at line 179 of file SummedValue.h.

References art::SummedValue< T >::rangeOfValidity_.

Referenced by art::disjoint_ranges(), art::overlapping_ranges(), and art::same_ranges().

180  {
181  return rangeOfValidity_;
182  }
RangeSet rangeOfValidity_
Definition: SummedValue.h:125
template<typename T >
template<typename H >
std::enable_if_t< detail::is_handle_v< H > > art::SummedValue< T >::update ( H const &  h)

Definition at line 134 of file SummedValue.h.

References art::detail::throw_if_invalid(), and art::SummedValue< T >::update_impl().

135  {
136  std::string const& errMsg{"Attempt to update " +
137  cet::demangle_symbol(typeid(*this).name()) +
138  " from an invalid handle."};
139  detail::throw_if_invalid(errMsg, h);
140  update_impl(h, *h);
141  }
void throw_if_invalid(std::string const &msg, T const &...t)
Definition: Handle.h:71
void update_impl(H const &h, T const &t)
Definition: SummedValue.h:84
template<typename T>
template<typename H >
std::enable_if_t< detail::is_handle_v< H > > art::SummedValue< T >::update ( H const &  h,
T const &  t 
)

Definition at line 146 of file SummedValue.h.

References art::detail::throw_if_invalid(), and art::SummedValue< T >::update_impl().

147  {
148  std::string const& errMsg{"Attempt to update " +
149  cet::demangle_symbol(typeid(*this).name()) +
150  " from an invalid handle.\n"};
151  detail::throw_if_invalid(errMsg, h);
152  update_impl(h, t);
153  }
void throw_if_invalid(std::string const &msg, T const &...t)
Definition: Handle.h:71
void update_impl(H const &h, T const &t)
Definition: SummedValue.h:84
template<typename T>
template<typename H >
void art::SummedValue< T >::update_impl ( H const &  h,
T const &  t 
)
inlineprivate

Definition at line 84 of file SummedValue.h.

Referenced by art::SummedValue< T >::update().

85  {
86  // Precondition: handle must be valid
87  assert(h.isValid());
88 
89  auto const& newRS = h.provenance()->rangeOfValidity();
90  if (!rangeOfValidity_.is_valid() && newRS.is_valid()) {
91  rangeOfValidity_ = newRS;
92  value_ = t;
93  } else if (art::disjoint_ranges(rangeOfValidity_, newRS)) {
94  if (rangeOfValidity_.run() != newRS.run()) {
96  "SummedValue<T>::update"}
97  << "\nThe following ranges corresponding to the type:\n"
98  << " '" << cet::demangle_symbol(typeid(T).name()) << "'"
99  << "\nhave different run numbers (" << rangeOfValidity_.run()
100  << " vs. " << newRS.run() << ") and cannot be aggregated.\n"
101  << "Please contact artists@fnal.gov.\n";
102  }
104  rangeOfValidity_.merge(h.provenance()->rangeOfValidity());
105  } else if (art::same_ranges(rangeOfValidity_, newRS)) {
106  // The ranges are the same, so the behavior is a NOP.
107  // However, we will probably never get here because of the
108  // seenIDs set, which prevents duplicate aggregation. If the
109  // stakeholders decide that products with the same ranges
110  // should be checked for equality, then the seenIDs set needs
111  // to go away, and an extra condition will be added here.
112  } else if (art::overlapping_ranges(rangeOfValidity_, newRS)) {
114  "SummedValue<T>::update"}
115  << "\nThe following ranges corresponding to the type:\n"
116  << " '" << cet::demangle_symbol(typeid(T).name()) << "'"
117  << "\ncannot be aggregated\n"
118  << rangeOfValidity_ << " and\n"
119  << newRS << "\nPlease contact artists@fnal.gov.\n";
120  }
121  // NOP when both RangeSets are invalid
122  }
RangeSet rangeOfValidity_
Definition: SummedValue.h:125
std::enable_if_t< detail::are_handles_v< T, U >, bool > overlapping_ranges(T const &a, U const &b)
bool is_valid() const
Definition: RangeSet.cc:117
RunNumber_t run() const
Definition: RangeSet.cc:89
std::enable_if_t< detail::are_handles_v< T, U >, bool > disjoint_ranges(T const &a, U const &b)
static void aggregate(T &, T const &)
Definition: aggregate.h:53
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::enable_if_t< detail::are_handles_v< T, U >, bool > same_ranges(T const &a, U const &b)
RangeSet & merge(RangeSet const &other)
Definition: RangeSet.cc:295
template<typename T >
T const & art::SummedValue< T >::value ( ) const
inline

Definition at line 172 of file SummedValue.h.

References art::SummedValue< T >::value_.

173  {
174  return value_;
175  }

Member Data Documentation

template<typename T>
T art::SummedValue< T >::value_ {}
private

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