11 #ifndef LARDATA_RECOBASEPROXY_PROXYBASE_ONETO01DATA_H 12 #define LARDATA_RECOBASEPROXY_PROXYBASE_ONETO01DATA_H 26 #include <type_traits> 66 template <
typename Main,
typename Aux,
typename Metadata ,
typename Tag
107 static_assert(std::is_convertible<decltype(
get(index)),
auxiliary_data_t>(),
108 "Inconsistent data types.");
154 template <
typename Tag,
typename Assns>
157 template <
typename Assns>
160 return makeOneTo01data<typename Assns::right_t>(assns, minSize);
183 template <
typename Tag,
typename MainColl,
typename Assns>
186 return makeOneTo01data<Tag>(assns, mainColl.size());
189 template <
typename MainColl,
typename Assns>
192 return makeOneTo01data<typename Assns::right_t>(mainColl, assns);
208 template <
typename T>
210 typename std::vector<T>::size_type index,
211 typename std::vector<T>::value_type
const&
value)
213 if (index >= v.size()) {
214 v.reserve(index + 1);
224 template <
typename T>
226 typename std::vector<T>::size_type index,
227 typename std::vector<T>::value_type&&
value)
229 if (index >= v.size()) {
230 v.reserve(index + 1);
232 v.push_back(std::move(
value));
235 v[index] = std::move(
value);
239 template <std::
size_t Key, std::
size_t Data,
typename Iter>
248 using value_type =
typename Iter::value_type;
249 using data_t = std::tuple_element_t<Data, value_type>;
250 std::vector<data_t> data(n);
251 for (
auto it = begin; it !=
end; ++it) {
252 auto const& keyPtr = std::get<Key>(*it);
263 template <
typename Tag,
typename Assns>
266 using Main_t =
typename Assns::left_t;
267 using Aux_t =
typename Assns::right_t;
273 return AssociatedData_t(
274 details::associationOneToOneFullSequence<0U, 1U>(
cbegin(assns),
cend(assns), minSize));
281 #endif // LARDATA_RECOBASEPROXY_PROXYBASE_ONETO01DATA_H
auto makeOneTo01data(Assns const &assns, std::size_t minSize=0)
Processes and returns an one-to-(zero/one) associated data object.
decltype(auto) constexpr cend(T &&obj)
ADL-aware version of std::cend.
art::Ptr< aux_t > aux_ptr_t
Type of art pointer to associated datum.
bool has(std::size_t i) const
Returns whether the element i is associated with auxiliary datum.
OneTo01Data(aux_coll_t &&data)
Main main_t
Type of main datum.
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Object for one-to-zero/or/one associated data interface.
Encloses LArSoft data product proxy objects and utilities.See this doxygen module for an introduction...
Aux aux_t
Type of associated datum.
auto operator[](std::size_t index) const -> decltype(auto)
Returns the range with the specified index (no check performed).
Utilities to address elements of a tuple-like class by tag.
Traits for art associations.
Metadata metadata_t
Type of associated metadata.
decltype(auto) constexpr cbegin(T &&obj)
ADL-aware version of std::cbegin.
void extendAndAssign(std::vector< T > &v, typename std::vector< T >::size_type index, typename std::vector< T >::value_type const &value)
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
std::vector< aux_ptr_t > aux_coll_t
Type of collection of auxiliary data for all main elements.
aux_coll_t auxData
Data associated to the main collection.
util::add_tag_t< aux_ptr_t, tag > auxiliary_data_t
Type of auxiliary data associated with a main item.
auto associationOneToOneFullSequence(Iter begin, Iter end, std::size_t n)