11 #ifndef LARDATA_RECOBASEPROXY_PROXYBASE_COLLECTIONPROXY_H 12 #define LARDATA_RECOBASEPROXY_PROXYBASE_COLLECTIONPROXY_H 31 template <
typename Cont>
34 template <
template <
typename,
typename...>
class F,
typename...>
109 template <
template <
typename CollProxy>
class Element,
typename MainColl,
typename... AuxColls>
164 return details::makeCollectionProxyElement<element_proxy_t>(
165 i, getMainAt(i), aux<AuxColls>().
operator[](i)...);
181 template <
typename AuxTag>
182 auto get()
const -> decltype(
auto)
184 return auxByTag<AuxTag>();
240 template <
typename Tag,
typename T = std::vector<Tag> const&>
241 [[deprecated(
"Use C++17 constexpr if instead and get() instead")]]
auto getIf()
const 245 template <
typename Tag>
246 static constexpr
bool has()
248 return util::has_tag_v<Tag, aux_collections_t>;
252 using main_collection_proxy_t::getMainAt;
254 using main_collection_proxy_t::mainProxy;
257 template <
typename AuxColl>
258 AuxColl
const&
aux()
const 260 return static_cast<AuxColl const&
>(*this);
264 template <
typename AuxTag>
267 return aux<util::type_with_tag_t<AuxTag, aux_collections_t>>();
270 template <
typename Tag,
typename>
271 auto getIfHas(std::bool_constant<true>)
const -> decltype(
auto);
272 template <
typename Tag,
typename T>
273 [[noreturn]]
auto getIfHas(std::bool_constant<false>)
const -> T;
279 "Some auxiliary data collections share the same tag. They should not.");
293 template <
typename MainColl,
typename... AuxColls>
298 template <
typename... Args>
310 template <
template <
typename...>
class CollProxy,
typename MainColl,
typename... AuxColl>
313 return CollProxy<MainColl, AuxColl...>(
main, std::forward<AuxColl>(aux)...);
318 template <
typename MainColl,
typename... AuxColl>
321 return createCollectionProxy<CollectionProxy>(
main, std::forward<AuxColl>(aux)...);
331 template <
typename Cont>
345 : fCont(&cont), fIndex(index)
349 auto operator*() const -> decltype(auto) {
return fCont->operator[](fIndex); }
361 return (other.
fIndex != fIndex) || (other.
fCont != fCont);
368 std::size_t fIndex = std::numeric_limits<std::size_t>::max();
384 template <
template <
typename,
typename...>
class F,
typename First,
typename... Others>
386 using type = F<First, Others...>;
394 template <
template <
typename CollProxy>
class Element,
typename MainColl,
typename... AuxColls>
395 template <
typename Tag,
typename T>
398 return getIfHas<Tag, T>(std::bool_constant<has<Tag>()>{});
401 template <
template <
typename CollProxy>
class Element,
typename MainColl,
typename... AuxColls>
402 template <
typename Tag,
typename>
409 template <
template <
typename CollProxy>
class Element,
typename MainColl,
typename... AuxColls>
410 template <
typename Tag,
typename T>
412 std::bool_constant<false>) const -> T
414 throw std::logic_error(
"Tag '" + lar::debug::demangle<Tag>() +
"' not available.");
421 #endif // LARDATA_RECOBASEPROXY_PROXYBASE_COLLECTIONPROXY_H const_iterator begin() const
Returns an iterator to the first element of the collection.
std::tuple< AuxColls... > aux_collections_t
Tuple of all auxiliary data collections (wrappers).
util::collection_value_t< MainColl > main_element_t
Type of the elements in the original collection.
std::size_t fIndex
Current index in the main collection.
CollectionProxyBase< CollectionProxyElement, MainColl, AuxColls... > CollectionProxy
Base representation of a collection of proxied objects.
typename details::TemplateAdaptorOnePlus< CollectionProxy, Args... >::type CollectionProxyFromArgs
CollectionProxyBase(main_collection_t const &main, AuxColls &&...aux)
Constructor: uses the specified data.
auto auxByTag() const -> decltype(auto)
Returns the auxiliary data specified by type.
const_iterator & operator++()
Returns the value pointed by this iterator.
Iterator to random access collection storing a current index.
Base representation of a collection of proxied objects.
Wrapper for the main collection of a proxy.
auto makeCollectionProxy(MainColl const &main, AuxColl &&...aux)
Creates a CollectionProxy object with the given arguments.
auto createCollectionProxy(MainColl const &main, AuxColl &&...aux)
Creates a collection proxy of a specified type with the given arguments.
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
const_iterator makeIterator(std::size_t i) const
Returns an iterator pointing to the specified index of this collection.
Proxy class for charged space point proxy elements.
bool empty() const
Returns whether this collection is empty.
Utilities for the main collection of a collection proxy.
Utilities for a single element of a collection proxy.
auto operator*() const -> decltype(auto)
Returns the value pointed by this iterator.
Encloses LArSoft data product proxy objects and utilities.See this doxygen module for an introduction...
MainColl main_collection_t
Type of the original collection.
const_iterator end() const
Returns an iterator past the last element of the collection.
container_t const * fCont
Pointer to the original container.
IndexBasedIterator(container_t const &cont, std::size_t index=0)
Constructor: initializes from an iterator of the proxy main collection.
std::size_t size() const
Returns the size of this collection.
static constexpr bool has()
Returns whether this class knowns about the specified type (Tag).
An element of a collection proxy.
auto getIfHas(std::bool_constant< true >) const -> decltype(auto)
element_proxy_t const operator[](std::size_t i) const
Returns the element of this collection with the specified index.
Utilities to address elements of a tuple-like class by tag.
util::collection_value_t< container_t > value_type
AuxColl const & aux() const
Returns the auxiliary data specified by type.
auto getIf() const -> decltype(auto)
Returns the auxiliary data specified by type (Tag).
bool operator!=(const_iterator const &other) const
Returns whether the iterators point to the same element.