Skip to content

Commit 9a71393

Browse files
committed
allow iterators for Produces<> (sigh)
1 parent 260f878 commit 9a71393

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

Framework/Core/include/Framework/AnalysisHelpers.h

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,16 +152,19 @@ class TableConsumer;
152152
// int64_t mCount = -1;
153153
// };
154154

155-
template <soa::ng_table T>
155+
template <typename T>
156+
concept producable = soa::has_ng_metadata<T> || soa::has_ng_metadata<typename T::parent_t>;
157+
158+
template <producable T>
156159
struct WritingCursor {
157160
public:
158-
using persistent_table_t = T;
159-
using cursor_t = decltype(std::declval<TableBuilder>().cursor<T>());
161+
using persistent_table_t = decltype([](){ if constexpr (soa::ng_iterator<T>) { return typename T::parent_t{nullptr}; } else { return T{nullptr}; } }());//std::conditional<soa::ng_iterator<T>, typename T::parent_t, T>;
162+
using cursor_t = decltype(std::declval<TableBuilder>().cursor<persistent_table_t>());
160163

161164
template <typename... Ts>
162165
void operator()(Ts... args)
163166
{
164-
static_assert(sizeof...(Ts) == framework::pack_size(typename T::persistent_columns_t{}), "Argument number mismatch");
167+
static_assert(sizeof...(Ts) == framework::pack_size(typename persistent_table_t::persistent_columns_t{}), "Argument number mismatch");
165168
++mCount;
166169
cursor(0, extract(args)...);
167170
}
@@ -189,7 +192,7 @@ struct WritingCursor {
189192
/// spend time reallocating the buffers.
190193
void reserve(int64_t size)
191194
{
192-
mBuilder->reserve(typename T::column_types{}, size);
195+
mBuilder->reserve(typename persistent_table_t::column_types{}, size);
193196
}
194197

195198
void release()
@@ -206,7 +209,7 @@ struct WritingCursor {
206209
if constexpr (soa::ng_iterator<A>) {
207210
return arg.globalIndex();
208211
} else {
209-
static_assert(!framework::has_type<A>(typename T::persistent_columns_t{}), "Argument type mismatch");
212+
static_assert(!framework::has_type<A>(typename persistent_table_t::persistent_columns_t{}), "Argument type mismatch");
210213
return arg;
211214
}
212215
}
@@ -259,7 +262,7 @@ struct OutputForTable {
259262
// struct Produces : WritingCursor<typename soa::PackToTable<aod::MetadataTrait<T>::metadata::origin(), typename T::table_t::persistent_columns_t>::table> {
260263
// };
261264

262-
template <soa::has_ng_metadata T>
265+
template <producable T>
263266
struct Produces : WritingCursor<T> {
264267
};
265268

Framework/Core/include/Framework/AnalysisManagers.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -305,25 +305,25 @@ struct OutputManager {
305305
// }
306306
// };
307307

308-
template <typename TABLE>
309-
struct OutputManager<Produces<TABLE>> {
310-
static bool appendOutput(std::vector<OutputSpec>& outputs, Produces<TABLE>& /*what*/, uint32_t)
308+
template <producable T>
309+
struct OutputManager<Produces<T>> {
310+
static bool appendOutput(std::vector<OutputSpec>& outputs, Produces<T>& /*what*/, uint32_t)
311311
{
312-
outputs.emplace_back(OutputForTable<TABLE>::spec());
312+
outputs.emplace_back(OutputForTable<typename Produces<T>::persistent_table_t>::spec());
313313
return true;
314314
}
315-
static bool prepare(ProcessingContext& context, Produces<TABLE>& what)
315+
static bool prepare(ProcessingContext& context, Produces<T>& what)
316316
{
317-
what.resetCursor(std::move(context.outputs().make<TableBuilder>(OutputForTable<TABLE>::ref())));
317+
what.resetCursor(std::move(context.outputs().make<TableBuilder>(OutputForTable<typename Produces<T>::persistent_table_t>::ref())));
318318
return true;
319319
}
320-
static bool finalize(ProcessingContext&, Produces<TABLE>& what)
320+
static bool finalize(ProcessingContext&, Produces<T>& what)
321321
{
322-
what.setLabel(o2::aod::Hash<TABLE::ref.label_hash>::str);
322+
what.setLabel(o2::aod::Hash<Produces<T>::persistent_table_t::ref.label_hash>::str);
323323
what.release();
324324
return true;
325325
}
326-
static bool postRun(EndOfStreamContext&, Produces<TABLE>&)
326+
static bool postRun(EndOfStreamContext&, Produces<T>&)
327327
{
328328
return true;
329329
}

0 commit comments

Comments
 (0)