LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
art::FindOne< ProdB, void > Class Template Reference

#include "FindOne.h"

Public Types

using assoc_t = ProdB
 
using bColl_t = std::vector< ProdB const * >
 
using value_type = typename bColl_t::value_type
 
using size_type = typename bColl_t::size_type
 
using difference_type = typename bColl_t::difference_type
 
using const_reference = typename bColl_t::const_reference
 
using reference = typename bColl_t::reference
 

Public Member Functions

template<typename Handle , typename DataContainer , typename Tag >
 FindOne (Handle const &aCollection, DataContainer const &dc, Tag const &tag, std::enable_if_t< detail::is_handle_v< Handle >> *=nullptr)
 
template<typename ProdAColl , typename DataContainer , typename Tag >
 FindOne (ProdAColl const &view, DataContainer const &dc, Tag const &tag, std::enable_if_t< std::is_pointer_v< typename ProdAColl::value_type >> *=nullptr)
 
template<typename PtrProdAColl , typename DataContainer , typename Tag >
 FindOne (PtrProdAColl const &aPtrColl, DataContainer const &dc, Tag const &tag, std::enable_if_t< std::is_same_v< typename PtrProdAColl::value_type, art::Ptr< typename PtrProdAColl::value_type::value_type >>> *=nullptr)
 
template<typename ProdA , typename DataContainer , typename Tag >
 FindOne (std::initializer_list< Ptr< ProdA >> const &ptrs, DataContainer const &dc, Tag const &tag)
 
bool isValid () const
 
size_type size () const
 
cet::maybe_ref< assoc_t const > at (size_type i) const
 
void get (size_type i, cet::maybe_ref< assoc_t const > &item) const
 
bool operator== (FindOne< ProdB, void > const &other) const
 

Protected Member Functions

 FindOne ()=default
 
bColl_tbCollection ()
 
void setStoredException (std::shared_ptr< art::Exception const > &&e)
 
void throwIfInvalid () const
 

Private Attributes

bColl_t bCollection_ {}
 
std::shared_ptr< art::Exception const > storedException_ {}
 

Detailed Description

template<typename ProdB>
class art::FindOne< ProdB, void >

Definition at line 143 of file FindOne.h.

Member Typedef Documentation

template<typename ProdB >
using art::FindOne< ProdB, void >::assoc_t = ProdB

Definition at line 146 of file FindOne.h.

template<typename ProdB >
using art::FindOne< ProdB, void >::bColl_t = std::vector<ProdB const*>

Definition at line 151 of file FindOne.h.

template<typename ProdB >
using art::FindOne< ProdB, void >::const_reference = typename bColl_t::const_reference

Definition at line 156 of file FindOne.h.

template<typename ProdB >
using art::FindOne< ProdB, void >::difference_type = typename bColl_t::difference_type

Definition at line 155 of file FindOne.h.

template<typename ProdB >
using art::FindOne< ProdB, void >::reference = typename bColl_t::reference

Definition at line 157 of file FindOne.h.

template<typename ProdB >
using art::FindOne< ProdB, void >::size_type = typename bColl_t::size_type

Definition at line 154 of file FindOne.h.

template<typename ProdB >
using art::FindOne< ProdB, void >::value_type = typename bColl_t::value_type

Definition at line 153 of file FindOne.h.

Constructor & Destructor Documentation

template<typename ProdB >
template<typename Handle , typename DataContainer , typename Tag >
art::FindOne< ProdB, void >::FindOne ( Handle const &  aCollection,
DataContainer const &  dc,
Tag const &  tag,
std::enable_if_t< detail::is_handle_v< Handle >> *  = nullptr 
)

Definition at line 293 of file FindOne.h.

298 {
299  using ProdA = typename Handle::element_type::value_type;
300  detail::IPRHelper<ProdA, ProdB, void, void, DataContainer> finder{
301  dc, detail::input_tag<ProdA, ProdB, void>(tag)};
302  storedException_ = finder(*aCollection, bCollection_);
303 }
std::shared_ptr< art::Exception const > storedException_
Definition: FindOne.h:214
template<typename ProdB >
template<typename ProdAColl , typename DataContainer , typename Tag >
art::FindOne< ProdB, void >::FindOne ( ProdAColl const &  view,
DataContainer const &  dc,
Tag const &  tag,
std::enable_if_t< std::is_pointer_v< typename ProdAColl::value_type >> *  = nullptr 
)

Definition at line 307 of file FindOne.h.

312 {
313  using ProdA =
314  std::remove_const_t<std::remove_pointer_t<typename ProdAColl::value_type>>;
315  detail::IPRHelper<ProdA, ProdB, void, void, DataContainer> finder{
316  dc, detail::input_tag<ProdA, ProdB, void>(tag)};
317  storedException_ = finder(view, bCollection_);
318 }
std::shared_ptr< art::Exception const > storedException_
Definition: FindOne.h:214
template<typename ProdB >
template<typename PtrProdAColl , typename DataContainer , typename Tag >
art::FindOne< ProdB, void >::FindOne ( PtrProdAColl const &  aPtrColl,
DataContainer const &  dc,
Tag const &  tag,
std::enable_if_t< std::is_same_v< typename PtrProdAColl::value_type, art::Ptr< typename PtrProdAColl::value_type::value_type >>> *  = nullptr 
)

Definition at line 322 of file FindOne.h.

329 {
330  using ProdA = typename PtrProdAColl::value_type::value_type;
331  detail::IPRHelper<ProdA, ProdB, void, void, DataContainer> finder{
332  dc, detail::input_tag<ProdA, ProdB, void>(tag)};
333  storedException_ = finder(aPtrColl, bCollection_);
334 }
std::shared_ptr< art::Exception const > storedException_
Definition: FindOne.h:214
template<typename ProdB >
template<typename ProdA , typename DataContainer , typename Tag >
art::FindOne< ProdB, void >::FindOne ( std::initializer_list< Ptr< ProdA >> const &  ptrs,
DataContainer const &  dc,
Tag const &  tag 
)

Definition at line 338 of file FindOne.h.

342 {
343  detail::IPRHelper<ProdA, ProdB, void, void, DataContainer> finder{
344  dc, detail::input_tag<ProdA, ProdB, void>(tag)};
345  storedException_ = finder(ptrs, bCollection_);
346 }
std::shared_ptr< art::Exception const > storedException_
Definition: FindOne.h:214
template<typename ProdB >
art::FindOne< ProdB, void >::FindOne ( )
protecteddefault

Member Function Documentation

template<typename ProdB >
auto art::FindOne< ProdB, void >::at ( size_type  i) const
inline

Definition at line 365 of file FindOne.h.

372 {
373  throwIfInvalid();
374 #ifdef ART_IPR_BY_PTR
375  return bCollection_.at(i);
376 #else
377  return cet::maybe_ref<assoc_t const>{*bCollection_.at(i)};
378 #endif
379 }
void throwIfInvalid() const
Definition: FindOne.h:418
template<typename ProdB >
bColl_t& art::FindOne< ProdB, void >::bCollection ( )
inlineprotected

Definition at line 207 of file FindOne.h.

References e.

Referenced by art::FindOne< ProdB, Data >::FindOne().

207 { return bCollection_; }
template<typename ProdB >
void art::FindOne< ProdB, void >::get ( size_type  i,
cet::maybe_ref< assoc_t const > &  item 
) const
inline

Definition at line 383 of file FindOne.h.

Referenced by art::FindOne< ProdB, Data >::get().

390 {
391  throwIfInvalid();
392 #ifdef ART_IPR_BY_PTR
393  item = bCollection_.at(i);
394 #else
395  item.reseat(*bCollection_.at(i));
396 #endif
397 }
void throwIfInvalid() const
Definition: FindOne.h:418
template<typename ProdB >
bool art::FindOne< ProdB, void >::isValid ( ) const
inline

Definition at line 358 of file FindOne.h.

References art::FindOne< ProdB, Data >::get().

359 {
360  return storedException_.get() == nullptr;
361 }
std::shared_ptr< art::Exception const > storedException_
Definition: FindOne.h:214
template<typename ProdB >
bool art::FindOne< ProdB, void >::operator== ( FindOne< ProdB, void > const &  other) const
inline

Definition at line 401 of file FindOne.h.

References bCollection_.

Referenced by art::FindOne< ProdB, Data >::operator==().

403 {
404  throwIfInvalid();
405  return bCollection_ == other.bCollection_;
406 }
void throwIfInvalid() const
Definition: FindOne.h:418
template<typename ProdB >
void art::FindOne< ProdB, void >::setStoredException ( std::shared_ptr< art::Exception const > &&  e)
inlineprotected

Definition at line 410 of file FindOne.h.

References e.

Referenced by art::FindOne< ProdB, Data >::FindOne().

412 {
413  storedException_ = std::move(e);
414 }
Float_t e
Definition: plot.C:35
std::shared_ptr< art::Exception const > storedException_
Definition: FindOne.h:214
template<typename ProdB >
auto art::FindOne< ProdB, void >::size ( void  ) const
inline

Definition at line 350 of file FindOne.h.

351 {
352  throwIfInvalid();
353  return bCollection_.size();
354 }
void throwIfInvalid() const
Definition: FindOne.h:418
template<typename ProdB >
void art::FindOne< ProdB, void >::throwIfInvalid ( ) const
inlineprotected

Definition at line 418 of file FindOne.h.

References art::errors::LogicError.

Referenced by art::FindOne< ProdB, Data >::data().

419 {
420  if (!isValid()) {
421  throw Exception(
422  errors::LogicError, "Invalid FindOne", *storedException_)
423  << "Attempt to use a FindOne where the underlying "
424  "art::Assns product was not found.";
425  }
426 }
bool isValid() const
Definition: FindOne.h:358
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::shared_ptr< art::Exception const > storedException_
Definition: FindOne.h:214

Member Data Documentation

template<typename ProdB >
bColl_t art::FindOne< ProdB, void >::bCollection_ {}
private

Definition at line 213 of file FindOne.h.

Referenced by operator==().

template<typename ProdB >
std::shared_ptr<art::Exception const> art::FindOne< ProdB, void >::storedException_ {}
private

Definition at line 214 of file FindOne.h.


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