1 #ifndef canvas_Persistency_Common_FindOne_h 2 #define canvas_Persistency_Common_FindOne_h 123 #include "cetlib/maybe_ref.h" 125 #include <initializer_list> 132 template <
typename ProdB,
typename DATA =
void>
136 template <
typename ProdB>
142 template <
typename ProdB>
148 #ifdef ART_IPR_BY_PTR 149 using bColl_t = std::vector<Ptr<assoc_t> >;
159 template <
typename Handle,
typename DataContainer,
typename Tag>
161 DataContainer
const& dc,
165 template <
typename ProdAColl,
typename DataContainer,
typename Tag>
167 DataContainer
const& dc,
171 template <
typename PtrProdAColl,
typename DataContainer,
typename Tag>
172 FindOne(PtrProdAColl
const& aPtrColl,
173 DataContainer
const& dc,
175 std::enable_if_t<std::is_same<
typename PtrProdAColl::value_type,
178 template <
typename ProdA,
typename DataContainer,
typename Tag>
180 DataContainer
const& dc,
184 bool isValid()
const;
190 #ifdef ART_IPR_BY_PTR 194 cet::maybe_ref<assoc_t const> at(
size_type i)
const;
195 void get(
size_type i, cet::maybe_ref<assoc_t const>& item)
const;
203 void setStoredException(std::shared_ptr<art::Exception const>&&
e);
204 void throwIfInvalid()
const;
208 std::shared_ptr<art::Exception const> storedException_{};
211 template <
typename ProdB,
typename Data>
229 template <
typename Handle,
typename DataContainer,
typename Tag>
231 DataContainer
const& dc,
235 template <
typename ProdAColl,
typename DataContainer,
typename Tag>
237 DataContainer
const& dc,
241 template <
typename PtrProdAColl,
typename DataContainer,
typename Tag>
242 FindOne(PtrProdAColl
const& aPtrColl,
243 DataContainer
const& dc,
245 std::enable_if_t<std::is_same<
typename PtrProdAColl::value_type,
248 template <
typename ProdA,
typename DataContainer,
typename Tag>
250 DataContainer
const& dc,
263 #ifdef ART_IPR_BY_PTR 266 cet::maybe_ref<assoc_t const>& item,
268 cet::maybe_ref<Data const>&
data)
const;
278 template <
typename ProdB>
279 template <
typename Handle,
typename DataContainer,
typename Tag>
282 DataContainer
const& dc,
286 using ProdA =
typename Handle::element_type::value_type;
288 storedException_ = finder(*aCollection, bCollection_);
291 template <
typename ProdB>
292 template <
typename ProdAColl,
typename DataContainer,
typename Tag>
295 DataContainer
const& dc,
299 using ProdA = std::remove_const_t<std::remove_pointer_t<typename ProdAColl::value_type>>;
301 storedException_ = finder(view, bCollection_);
304 template <
typename ProdB>
305 template <
typename PtrProdAColl,
typename DataContainer,
typename Tag>
308 DataContainer
const& dc,
310 std::enable_if_t<std::is_same<
typename PtrProdAColl::value_type,
313 using ProdA =
typename PtrProdAColl::value_type::value_type;
315 storedException_ = finder(aPtrColl, bCollection_);
318 template <
typename ProdB>
319 template <
typename ProdA,
typename DataContainer,
typename Tag>
322 DataContainer
const& dc,
326 storedException_ = finder(ptrs, bCollection_);
329 template <
typename ProdB>
337 return bCollection_.size();
340 template <
typename ProdB>
346 return storedException_.
get() ==
nullptr;
349 template <
typename ProdB>
358 cet::maybe_ref<assoc_t const>
362 #ifdef ART_IPR_BY_PTR 363 return bCollection_.at(i);
365 return cet::maybe_ref<assoc_t const>{*bCollection_.at(i)};
369 template <
typename ProdB>
377 cet::maybe_ref<assoc_t const>& item
382 #ifdef ART_IPR_BY_PTR 383 item = bCollection_.at(i);
385 item.reseat(*bCollection_.at(i));
389 template <
typename ProdB>
399 template <
typename ProdB>
405 storedException_ = std::move(
e);
408 template <
typename ProdB>
416 <<
"Attempt to use a FindOne where the underlying art::Assns product was not found.";
422 template <
typename ProdB,
typename Data>
423 template <
typename Handle,
typename DataContainer,
typename Tag>
426 DataContainer
const& dc,
430 using ProdA =
typename Handle::element_type::value_type;
435 template <
typename ProdB,
typename Data>
436 template <
typename ProdAColl,
typename DataContainer,
typename Tag>
439 DataContainer
const& dc,
443 using ProdA = std::remove_const_t<std::remove_pointer_t<typename ProdAColl::value_type>>;
448 template <
typename ProdB,
typename Data>
449 template <
typename PtrProdAColl,
typename DataContainer,
typename Tag>
452 DataContainer
const& dc,
454 std::enable_if_t<std::is_same<
typename PtrProdAColl::value_type,
457 using ProdA =
typename PtrProdAColl::value_type::value_type;
462 template <
typename ProdB,
typename Data>
463 template <
typename ProdA,
typename DataContainer,
typename Tag>
466 DataContainer
const& dc,
473 template <
typename ProdB,
typename Data>
475 cet::maybe_ref<Data const>
483 template <
typename ProdB,
typename Data>
491 cet::maybe_ref<assoc_t const>& item,
493 cet::maybe_ref<Data const>&
data)
const 499 template <
typename ProdB,
typename Data>
509 #undef ART_IPR_BY_PTR
void get(size_type i, cet::maybe_ref< assoc_t const > &item) const
typename base::size_type size_type
InputTag input_tag(InputTag const &tag)
void get(size_type i, cet::maybe_ref< assoc_t const > &item, cet::maybe_ref< Data const > &data) const
bool operator==(FindOne< ProdB, Data > const &other) const
bool operator==(FindOne< ProdB, void > const &other) const
std::vector< ProdB const * > bColl_t
typename bColl_t::size_type size_type
typename base::const_reference const_reference
typename base::reference reference
typename bColl_t::value_type value_type
std::vector< Data const * > dataColl_t
typename base::assoc_t assoc_t
dataColl_t dataCollection_
cet::maybe_ref< assoc_t const > at(size_type i) const
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
cet::maybe_ref< Data const > data(size_type i) const
typename base::value_type value_type
std::string value(boost::any const &)
FindOne(Handle const &aCollection, DataContainer const &dc, Tag const &tag, std::enable_if_t< detail::is_handle< Handle >::value > *=nullptr)
typename bColl_t::reference reference
Data const & data_const_reference
void throwIfInvalid() const
typename bColl_t::const_reference const_reference
void setStoredException(std::shared_ptr< art::Exception const > &&e)
typename base::difference_type difference_type
Data const * data_const_pointer
typename bColl_t::difference_type difference_type