11 #ifndef LARDATA_RECOBASEPROXY_PROXYBASE_COLLECTIONPROXY_H 12 #define LARDATA_RECOBASEPROXY_PROXYBASE_COLLECTIONPROXY_H 32 template <
typename Cont>
35 template <
template <
typename,
typename...>
class F,
typename...>
113 template <
typename CollProxy>
class Element,
174 return details::makeCollectionProxyElement<element_proxy_t>
175 (i, getMainAt(i), aux<AuxColls>().
operator[](i)...);
192 template <
typename AuxTag>
193 auto get()
const -> decltype(
auto) {
return auxByTag<AuxTag>(); }
249 template <
typename Tag,
typename T = std::vector<Tag> const&>
250 [[deprecated(
"Use C++17 constexpr if instead and get() instead")]]
251 auto getIf()
const -> decltype(
auto);
255 template <
typename Tag>
256 static constexpr
bool has()
257 {
return util::has_tag_v<Tag, aux_collections_t>; }
262 using main_collection_proxy_t::mainProxy;
263 using main_collection_proxy_t::getMainAt;
266 template <
typename AuxColl>
267 AuxColl
const&
aux()
const {
return static_cast<AuxColl
const&
>(*this); }
270 template <
typename AuxTag>
272 {
return aux<util::type_with_tag_t<AuxTag, aux_collections_t>>(); }
275 template <
typename Tag,
typename>
276 auto getIfHas(std::bool_constant<true>)
const -> decltype(
auto);
277 template <
typename Tag,
typename T>
278 [[noreturn]]
auto getIfHas(std::bool_constant<false>)
const ->
T;
285 "Some auxiliary data collections share the same tag. They should not.");
300 template <
typename MainColl,
typename... AuxColls>
307 template <
typename... Args>
321 template <
typename...>
class CollProxy,
322 typename MainColl,
typename... AuxColl
326 return CollProxy<MainColl, AuxColl...>
327 (
main, std::forward<AuxColl>(aux)...);
332 template <
typename MainColl,
typename... AuxColl>
335 return createCollectionProxy<CollectionProxy>
336 (
main, std::forward<AuxColl>(aux)...);
346 template <
typename Cont>
360 : fCont(&cont), fIndex(
index) {}
364 {
return fCont->operator[](fIndex); }
371 {
return (other.
fIndex != fIndex) || (other.
fCont != fCont); }
395 template <
typename,
typename...>
class F,
396 typename First,
typename... Others
399 {
using type = F<First, Others...>; };
408 template <
typename CollProxy>
class Element,
412 template <
typename Tag,
typename T>
415 {
return getIfHas<Tag, T>(std::bool_constant<has<Tag>()>{}); }
419 template <
typename CollProxy>
class Element,
423 template <
typename Tag,
typename>
425 (std::bool_constant<true>)
const -> decltype(
auto)
426 {
return get<Tag>(); }
429 template <
typename CollProxy>
class Element,
433 template <
typename Tag,
typename T>
435 (std::bool_constant<false>)
const ->
T 437 throw std::logic_error
438 (
"Tag '" + lar::debug::demangle<Tag>() +
"' not available.");
447 #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.
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.
static int max(int a, int b)
MainColl main_collection_t
Type of the original collection.
bool operator!=(AssnsNode< ArtAssnsIterValue > const &A, typename AssnsNode< ArtAssnsIterValue >::valueptr_t const &B)
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)
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.
QuadExpr operator*(double v, const QuadExpr &e)
auto getIf() const -> decltype(auto)
Returns the auxiliary data specified by type (Tag).