LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
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 54 of file SummedValue.h.

Member Function Documentation

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

Definition at line 146 of file SummedValue.h.

References tmp.

147  {
148  SummedValue<T> tmp{};
149  std::swap(*this, tmp);
150  }
Float_t tmp
Definition: plot.C:37
void swap(art::HLTGlobalStatus &lhs, art::HLTGlobalStatus &rhs)
template<typename T >
bool art::SummedValue< T >::isValid ( ) const
inline

Definition at line 154 of file SummedValue.h.

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

155  {
156  return rangeOfValidity_.is_valid();
157  }
RangeSet rangeOfValidity_
Definition: SummedValue.h:114
bool is_valid() const
Definition: RangeSet.cc:230
template<typename T >
RangeSet const & art::SummedValue< T >::rangeOfValidity ( ) const

Definition at line 168 of file SummedValue.h.

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

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

169  {
170  return rangeOfValidity_;
171  }
RangeSet rangeOfValidity_
Definition: SummedValue.h:114
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 123 of file SummedValue.h.

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

124  {
125  std::string const& errMsg{"Attempt to update " +
126  cet::demangle_symbol(typeid(*this).name()) +
127  " from an invalid handle."};
128  detail::throw_if_invalid(errMsg, h);
129  update_impl(h, *h);
130  }
void throw_if_invalid(std::string const &)
Definition: Handle.h:63
void update_impl(H const &h, T const &t)
Definition: SummedValue.h:81
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 135 of file SummedValue.h.

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

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

Definition at line 81 of file SummedValue.h.

References art::detail::CanBeAggregated< T, Enable >::aggregate(), art::disjoint_ranges(), art::RangeSet::is_valid(), art::RangeSet::merge(), art::overlapping_ranges(), art::errors::ProductCannotBeAggregated, art::SummedValue< T >::rangeOfValidity_, art::same_ranges(), and art::SummedValue< T >::value_.

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

82  {
83  // Precondition: handle must be valid
84  assert(h.isValid());
85 
86  auto const& newRS = h.provenance()->rangeOfValidity();
87  if (!rangeOfValidity_.is_valid() && newRS.is_valid()) {
88  rangeOfValidity_ = newRS;
89  value_ = t;
90  } else if (art::disjoint_ranges(rangeOfValidity_, newRS)) {
92  rangeOfValidity_.merge(h.provenance()->rangeOfValidity());
93  } else if (art::same_ranges(rangeOfValidity_, newRS)) {
94  // The ranges are the same, so the behavior is a NOP.
95  // However, we will probably never get here because of the
96  // seenIDs set, which prevents from duplicate aggregation.
97  // If the stakeholders decide that products with the same
98  // ranges should be checked for equality, then the seenIDs
99  // set needs to go away, and an extra condition will be
100  // added here.
101  } else if (art::overlapping_ranges(rangeOfValidity_, newRS)) {
103  "SummedValue<T>::update"}
104  << "\nThe following ranges corresponding to the type:\n"
105  << " '" << cet::demangle_symbol(typeid(T).name()) << "'"
106  << "\ncannot be aggregated\n"
107  << rangeOfValidity_ << " and\n"
108  << newRS << "\nPlease contact artists@fnal.gov.\n";
109  }
110  // NOP when both RangeSets are invalid
111  }
RangeSet rangeOfValidity_
Definition: SummedValue.h:114
RangeSet & merge(RangeSet const &other)
Definition: RangeSet.cc:134
std::enable_if_t< detail::are_handles< T, U >::value, bool > disjoint_ranges(T const &a, U const &b)
bool is_valid() const
Definition: RangeSet.cc:230
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)
static void aggregate(T &, T const &)
Definition: aggregate.h:57
template<typename T >
T const & art::SummedValue< T >::value ( ) const
inline

Definition at line 161 of file SummedValue.h.

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

162  {
163  return value_;
164  }

Member Data Documentation

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

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