Public Member Functions | Private Member Functions | Private Attributes | List of all members
art::SummedValue< T > Class Template Reference

#include <SummedValue.h>

Public Member Functions

template<typename H >
std::enable_if_t< detail::is_handle< H >::valueupdate (H const &h)
 
template<typename H >
std::enable_if_t< detail::is_handle< H >::valueupdate (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 158 of file SummedValue.h.

159  {
160  SummedValue<T> tmp{};
161  std::swap(*this, tmp);
162  }
void swap(Handle< T > &a, Handle< T > &b)
string tmp
Definition: languages.py:63
template<typename T >
bool art::SummedValue< T >::isValid ( ) const
inline

Definition at line 166 of file SummedValue.h.

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

Definition at line 180 of file SummedValue.h.

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

Definition at line 135 of file SummedValue.h.

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

Definition at line 147 of file SummedValue.h.

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

Definition at line 85 of file SummedValue.h.

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

174  {
175  return value_;
176  }

Member Data Documentation

template<typename T>
RangeSet art::SummedValue< T >::rangeOfValidity_ {RangeSet::invalid()}
private

Definition at line 126 of file SummedValue.h.

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

Definition at line 125 of file SummedValue.h.


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