12#ifndef ROOT_TExecutorCRTP
13#define ROOT_TExecutorCRTP
20#include <initializer_list>
106 template <
typename F,
typename... Args>
111 template <
class F,
class... T>
122 template <
class F,
class Cond = val
idMapReturnCond<F>>
123 auto Map(
F func,
unsigned nTimes) -> std::vector<InvokeResult_t<F>>;
124 template <
class F,
class INTEGER,
class Cond = val
idMapReturnCond<F, INTEGER>>
126 template <
class F,
class T,
class Cond = val
idMapReturnCond<F, T>>
127 auto Map(
F func, std::initializer_list<T> args) -> std::vector<InvokeResult_t<F, T>>;
128 template <
class F,
class T,
class Cond = val
idMapReturnCond<F, T>>
129 auto Map(
F func, std::vector<T> &args) -> std::vector<InvokeResult_t<F, T>>;
130 template <
class F,
class T,
class Cond = val
idMapReturnCond<F, T>>
131 auto Map(
F func,
const std::vector<T> &args) -> std::vector<InvokeResult_t<F, T>>;
136 template <
class F,
class R,
class Cond = val
idMapReturnCond<F>>
138 template <
class F,
class INTEGER,
class R,
class Cond = val
idMapReturnCond<F, INTEGER>>
140 template <
class F,
class T,
class R,
class Cond = val
idMapReturnCond<F, T>>
142 template <
class F,
class T,
class R,
class Cond = val
idMapReturnCond<F, T>>
144 template <
class F,
class T,
class R,
class Cond = val
idMapReturnCond<F, T>>
146 template<
class F,
class T,
class Cond = val
idMapReturnCond<F, T>>
148 template<
class F,
class T,
class Cond = val
idMapReturnCond<F, T>>
151 template<
class T> T*
Reduce(
const std::vector<T*> &mergeObjs);
152 template<
class T,
class R>
auto Reduce(
const std::vector<T> &objs,
R redfunc) ->
decltype(redfunc(objs));
158 return *
static_cast<SubC*
>(
this);
162 template <
class F,
class Cond = val
idMapReturnCond<F>>
163 auto MapImpl(
F func,
unsigned nTimes) -> std::vector<InvokeResult_t<F>> =
delete;
165 template <
class F,
class INTEGER,
class Cond = val
idMapReturnCond<F, INTEGER>>
168 template <
class F,
class T,
class Cond = val
idMapReturnCond<F, T>>
169 auto MapImpl(
F func, std::vector<T> &args) -> std::vector<InvokeResult_t<F, T>> =
delete;
171 template <
class F,
class T,
class Cond = val
idMapReturnCond<F, T>>
172 auto MapImpl(
F func,
const std::vector<T> &args) -> std::vector<InvokeResult_t<F, T>> =
delete;
184template <
class F,
class Cond>
187 return Derived().MapImpl(func, nTimes);
197template <
class F,
class INTEGER,
class Cond>
200 return Derived().MapImpl(func, args);
210template <
class F,
class T,
class Cond>
213 std::vector<T> vargs(std::move(args));
214 const auto &reslist = Map(func, vargs);
225template <
class F,
class T,
class Cond>
228 return Derived().MapImpl(func, args);
239template <
class F,
class T,
class Cond>
242 return Derived().MapImpl(func, args);
254template <
class F,
class R,
class Cond>
257 return Reduce(Map(func, nTimes), redfunc);
268template <
class F,
class INTEGER,
class R,
class Cond>
271 return Reduce(Map(func, args), redfunc);
282template <
class F,
class T,
class R,
class Cond>
285 std::vector<T> vargs(std::move(args));
286 return Reduce(Map(func, vargs), redfunc);
297template <
class F,
class T,
class R,
class Cond>
300 return Reduce(Map(func, args), redfunc);
311template <
class F,
class T,
class R,
class Cond>
314 return Reduce(Map(func, args), redfunc);
323template<
class SubC>
template<
class F,
class T,
class Cond>
326 return Reduce(Map(func, args));
335template<
class SubC>
template<
class F,
class T,
class Cond>
338 return Reduce(Map(func, args));
346template<
class SubC>
template<
class T>
351 Error(
"TExecutorCRTP<SubC>::Reduce",
"could not find merge method for the TObject\n. Aborting operation.");
356 for(
unsigned i =1; i<mergeObjs.size(); i++){
360 auto retHist =
dynamic_cast<T*
>((mergeObjs.front())->Clone());
361 if (retHist) retHist->Merge(&
l);
372template<
class SubC>
template<
class T,
class R>
376 static_assert(std::is_same<
decltype(redfunc(objs)), T>
::value,
"redfunc does not have the correct signature");
377 return redfunc(objs);
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
This class defines an interface to execute the same task multiple times, possibly in parallel and wit...
auto MapImpl(F func, std::vector< T > &args) -> std::vector< InvokeResult_t< F, T > >=delete
Implementation of the Map method, left to the derived classes.
ROOT::TypeTraits::InvokeResult_t< F, Args... > InvokeResult_t
auto MapReduce(F func, unsigned nTimes, R redfunc) -> InvokeResult_t< F >
Execute a function without arguments several times (Map) and accumulate the results into a single val...
auto MapReduce(F func, ROOT::TSeq< INTEGER > args, R redfunc) -> InvokeResult_t< F, INTEGER >
Execute a function over a sequence of indexes (Map) and accumulate the results into a single value (R...
auto MapReduce(F func, const std::vector< T > &args, R redfunc) -> InvokeResult_t< F, T >
Execute a function over the elements of an immutable vector (Map) and accumulate the results into a s...
auto Map(F func, std::initializer_list< T > args) -> std::vector< InvokeResult_t< F, T > >
Execute a function over the elements of an initializer_list.
T * MapReduce(F func, const std::vector< T * > &args)
Execute a function over the TObject-inheriting elements of an immutable vector (Map) and merge the ob...
auto MapImpl(F func, unsigned nTimes) -> std::vector< InvokeResult_t< F > >=delete
Implementation of the Map method, left to the derived classes.
auto Map(F func, std::vector< T > &args) -> std::vector< InvokeResult_t< F, T > >
Execute a function over the elements of a vector.
auto Map(F func, const std::vector< T > &args) -> std::vector< InvokeResult_t< F, T > >
Execute a function over the elements of an immutable vector.
TExecutorCRTP(const TExecutorCRTP &)=delete
auto Map(F func, ROOT::TSeq< INTEGER > args) -> std::vector< InvokeResult_t< F, INTEGER > >
Execute a function over a sequence of indexes.
auto Map(F func, unsigned nTimes) -> std::vector< InvokeResult_t< F > >
Execute a function without arguments several times.
std::enable_if_t<!std::is_reference< InvokeResult_t< F, T... > >::value &&!std::is_void< InvokeResult_t< F, T... > >::value > validMapReturnCond
type definition used in templated functions for not allowing mapping functions that return references...
auto MapReduce(F func, std::vector< T > &args, R redfunc) -> InvokeResult_t< F, T >
Execute a function over the elements of a vector (Map) and accumulate the results into a single value...
T * Reduce(const std::vector< T * > &mergeObjs)
"Reduce" an std::vector into a single object by using the object's Merge method.
T * MapReduce(F func, std::vector< T * > &args)
Execute a function over the TObject-inheriting elements of a vector (Map) and merge the objects into ...
auto MapReduce(F func, std::initializer_list< T > args, R redfunc) -> InvokeResult_t< F, T >
Execute a function over the elements of an initializer_list (Map) and accumulate the results into a s...
auto Reduce(const std::vector< T > &objs, R redfunc) -> decltype(redfunc(objs))
"Reduce" an std::vector into a single object by passing a function as the second argument defining th...
TExecutorCRTP & operator=(const TExecutorCRTP &)=delete
auto MapImpl(F func, const std::vector< T > &args) -> std::vector< InvokeResult_t< F, T > >=delete
Implementation of the Map method, left to the derived classes.
auto MapImpl(F func, ROOT::TSeq< INTEGER > args) -> std::vector< InvokeResult_t< F, INTEGER > >=delete
Implementation of the Map method, left to the derived classes.
A pseudo container class which is a generator of indices.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Long64_t(* MergeFunc_t)(void *, TCollection *, TFileMergeInfo *)