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")]]
255 template <typename Tag>
256 static constexpr
bool has()
257 {
return util::has_tag_v<Tag, aux_collections_t>; }
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>
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>
347 class IndexBasedIterator {
377 std::size_t
fIndex = std::numeric_limits<std::size_t>::max();
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.
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
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.
main_collection_t const & main() const
Returns the wrapped 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 getIf() const -> decltype(auto)
Returns the auxiliary data specified by type (Tag).
const_iterator & operator++()
Returns the value pointed by this iterator.
Iterator to random access collection storing a current index.
std::integral_constant< bool, Value > bool_constant
auto getMainAt(std::size_t i) const -> decltype(auto)
Returns the specified item in the original collection.
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 auxByTag() const -> decltype(auto)
Returns the auxiliary data specified by type.
auto createCollectionProxy(MainColl const &main, AuxColl &&...aux)
Creates a collection proxy of a specified type with the given arguments.
details::IndexBasedIterator< collection_proxy_t > const_iterator
Type of iterator to this collection (constant).
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.
this_t & mainProxy()
Return this object as main collection proxy.
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 operator*() const -> decltype(auto)
Returns the value pointed by this iterator.
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
Element< collection_proxy_t > element_proxy_t
Type of element of this collection proxy.
IndexBasedIterator()=default
Default constructor (required by iterator protocol): an unusable iterator.
AuxColl const & aux() const
Returns the auxiliary data specified by type.
int main(int argc, char **argv)
auto getIfHas(std::bool_constant< true >) const -> decltype(auto)
bool operator!=(const_iterator const &other) const
Returns whether the iterators point to the same element.