1 #ifndef canvas_Persistency_Common_FindOneP_h 2 #define canvas_Persistency_Common_FindOneP_h 123 #include "cetlib/maybe_ref.h" 125 #include <initializer_list> 128 #define ART_IPR_BY_PTR 132 template <
typename ProdB,
typename DATA =
void>
136 template <
typename ProdB>
142 template <
typename ProdB>
148 #ifdef ART_IPR_BY_PTR 151 using bColl_t = std::vector<ProdB const*>;
159 template <
typename Handle,
typename DataContainer,
typename Tag>
161 Handle const& aCollection,
162 DataContainer
const& dc,
164 std::enable_if_t<detail::is_handle_v<Handle>>* =
nullptr);
166 template <
typename ProdAColl,
typename DataContainer,
typename Tag>
168 ProdAColl
const& view,
169 DataContainer
const& dc,
171 std::enable_if_t<std::is_pointer_v<typename ProdAColl::value_type>>* =
174 template <
typename PtrProdAColl,
typename DataContainer,
typename Tag>
176 PtrProdAColl
const& aPtrColl,
177 DataContainer
const& dc,
179 std::enable_if_t<std::is_same_v<
180 typename PtrProdAColl::value_type,
184 template <
typename ProdA,
typename DataContainer,
typename Tag>
186 DataContainer
const& dc,
190 bool isValid()
const;
196 #ifdef ART_IPR_BY_PTR 200 cet::maybe_ref<assoc_t const> at(
size_type i)
const;
201 void get(
size_type i, cet::maybe_ref<assoc_t const> & item)
const;
209 void setStoredException(std::shared_ptr<art::Exception const> &&
e);
210 void throwIfInvalid()
const;
214 std::shared_ptr<art::Exception const> storedException_{};
217 template <
typename ProdB,
typename Data>
237 template <
typename Handle,
typename DataContainer,
typename Tag>
239 Handle const& aCollection,
240 DataContainer
const& dc,
242 std::enable_if_t<detail::is_handle_v<Handle>>* =
nullptr);
244 template <
typename ProdAColl,
typename DataContainer,
typename Tag>
246 ProdAColl
const& view,
247 DataContainer
const& dc,
249 std::enable_if_t<std::is_pointer_v<typename ProdAColl::value_type>>* =
252 template <
typename PtrProdAColl,
typename DataContainer,
typename Tag>
254 PtrProdAColl
const& aPtrColl,
255 DataContainer
const& dc,
257 std::enable_if_t<std::is_same_v<
258 typename PtrProdAColl::value_type,
261 template <
typename ProdA,
typename DataContainer,
typename Tag>
263 DataContainer
const& dc,
276 #ifdef ART_IPR_BY_PTR 279 cet::maybe_ref<assoc_t const> & item,
281 cet::maybe_ref<Data const> &
data)
const;
291 template <
typename ProdB>
292 template <
typename Handle,
typename DataContainer,
typename Tag>
294 Handle const& aCollection,
295 DataContainer
const& dc,
297 std::enable_if_t<detail::is_handle_v<Handle>>*)
299 using ProdA =
typename Handle::element_type::value_type;
301 dc, detail::input_tag<ProdA, ProdB, void>(tag)};
302 storedException_ = finder(*aCollection, bCollection_);
305 template <
typename ProdB>
306 template <
typename ProdAColl,
typename DataContainer,
typename Tag>
308 ProdAColl
const& view,
309 DataContainer
const& dc,
311 std::enable_if_t<std::is_pointer_v<typename ProdAColl::value_type>>*)
314 std::remove_const_t<std::remove_pointer_t<typename ProdAColl::value_type>>;
316 dc, detail::input_tag<ProdA, ProdB, void>(tag)};
317 storedException_ = finder(view, bCollection_);
320 template <
typename ProdB>
321 template <
typename PtrProdAColl,
typename DataContainer,
typename Tag>
323 PtrProdAColl
const& aPtrColl,
324 DataContainer
const& dc,
326 std::enable_if_t<std::is_same_v<
327 typename PtrProdAColl::value_type,
330 using ProdA =
typename PtrProdAColl::value_type::value_type;
332 dc, detail::input_tag<ProdA, ProdB, void>(tag)};
333 storedException_ = finder(aPtrColl, bCollection_);
336 template <
typename ProdB>
337 template <
typename ProdA,
typename DataContainer,
typename Tag>
339 std::initializer_list<
Ptr<ProdA>>
const& ptrs,
340 DataContainer
const& dc,
344 dc, detail::input_tag<ProdA, ProdB, void>(tag)};
345 storedException_ = finder(ptrs, bCollection_);
348 template <
typename ProdB>
353 return bCollection_.size();
356 template <
typename ProdB>
360 return storedException_.
get() ==
nullptr;
363 template <
typename ProdB>
370 cet::maybe_ref<assoc_t const>
374 #ifdef ART_IPR_BY_PTR 375 return bCollection_.at(i);
377 return cet::maybe_ref<assoc_t const>{*bCollection_.at(i)};
381 template <
typename ProdB>
387 cet::maybe_ref<assoc_t const>& item
392 #ifdef ART_IPR_BY_PTR 393 item = bCollection_.at(i);
395 item.reseat(*bCollection_.at(i));
399 template <
typename ProdB>
408 template <
typename ProdB>
411 std::shared_ptr<art::Exception const>&&
e)
413 storedException_ = std::move(
e);
416 template <
typename ProdB>
423 <<
"Attempt to use a FindOneP where the underlying " 424 "art::Assns product was not found.";
430 template <
typename ProdB,
typename Data>
431 template <
typename Handle,
typename DataContainer,
typename Tag>
433 Handle const& aCollection,
434 DataContainer
const& dc,
436 std::enable_if_t<detail::is_handle_v<Handle>>*)
438 using ProdA =
typename Handle::element_type::value_type;
440 dc, detail::input_tag<ProdA, ProdB, Data>(tag)};
445 template <
typename ProdB,
typename Data>
446 template <
typename ProdAColl,
typename DataContainer,
typename Tag>
448 ProdAColl
const& view,
449 DataContainer
const& dc,
451 std::enable_if_t<std::is_pointer_v<typename ProdAColl::value_type>>*)
454 std::remove_const_t<std::remove_pointer_t<typename ProdAColl::value_type>>;
456 dc, detail::input_tag<ProdA, ProdB, Data>(tag)};
460 template <
typename ProdB,
typename Data>
461 template <
typename PtrProdAColl,
typename DataContainer,
typename Tag>
463 PtrProdAColl
const& aPtrColl,
464 DataContainer
const& dc,
466 std::enable_if_t<std::is_same_v<
467 typename PtrProdAColl::value_type,
470 using ProdA =
typename PtrProdAColl::value_type::value_type;
472 dc, detail::input_tag<ProdA, ProdB, Data>(tag)};
477 template <
typename ProdB,
typename Data>
478 template <
typename ProdA,
typename DataContainer,
typename Tag>
480 std::initializer_list<
Ptr<ProdA>>
const& ptrs,
481 DataContainer
const& dc,
485 dc, detail::input_tag<ProdA, ProdB, Data>(tag)};
489 template <
typename ProdB,
typename Data>
490 inline cet::maybe_ref<Data const>
497 template <
typename ProdB,
typename Data>
503 cet::maybe_ref<assoc_t const>& item,
505 cet::maybe_ref<Data const>&
data)
const 511 template <
typename ProdB,
typename Data>
519 #undef ART_IPR_BY_PTR
Data const & data_const_reference
typename base::difference_type difference_type
typename base::size_type size_type
typename base::reference reference
typename base::const_reference const_reference
typename bColl_t::const_reference const_reference
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
FindOneP(Handle const &aCollection, DataContainer const &dc, Tag const &tag, std::enable_if_t< detail::is_handle_v< Handle >> *=nullptr)
typename base::assoc_t assoc_t
typename base::value_type value_type
void setStoredException(std::shared_ptr< art::Exception const > &&e)
Data const * data_const_pointer
void get(size_type i, art::Ptr< assoc_t > &item, cet::maybe_ref< Data const > &data) const
Ptr< assoc_t > const & at(size_type i) const
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
dataColl_t dataCollection_
typename bColl_t::reference reference
std::vector< Ptr< assoc_t >> bColl_t
typename bColl_t::difference_type difference_type
cet::maybe_ref< Data const > data(size_type i) const
void throwIfInvalid() const
bool operator==(FindOneP< ProdB, void > const &other) const
typename bColl_t::size_type size_type
typename bColl_t::value_type value_type
void get(size_type i, Ptr< assoc_t > &item) const
bool operator==(FindOneP< ProdB, Data > const &other) const
std::vector< Data const * > dataColl_t