12#ifndef ROOT_TExecutorCRTP
13#define ROOT_TExecutorCRTP
20#include <initializer_list>
105 template <
typename F,
typename... Args>
115 template <
class F,
class... T>
117 std::enable_if_t<
"Function can't return a reference" && !std::is_reference<
InvokeResult_t<
F, T...>>
::value>;
121 template <
class F,
class Cond = noReferenceCond<F>>
122 auto Map(
F func,
unsigned nTimes) -> std::vector<InvokeResult_t<F>>;
123 template <
class F,
class INTEGER,
class Cond = noReferenceCond<F, INTEGER>>
125 template <
class F,
class T,
class Cond = noReferenceCond<F, T>>
126 auto Map(
F func, std::initializer_list<T> args) -> std::vector<InvokeResult_t<F, T>>;
127 template <
class F,
class T,
class Cond = noReferenceCond<F, T>>
128 auto Map(
F func, std::vector<T> &args) -> std::vector<InvokeResult_t<F, T>>;
129 template <
class F,
class T,
class Cond = noReferenceCond<F, T>>
130 auto Map(
F func,
const std::vector<T> &args) -> std::vector<InvokeResult_t<F, T>>;
135 template <
class F,
class R,
class Cond = noReferenceCond<F>>
137 template <
class F,
class INTEGER,
class R,
class Cond = noReferenceCond<F, INTEGER>>
139 template <
class F,
class T,
class R,
class Cond = noReferenceCond<F, T>>
141 template <
class F,
class T,
class R,
class Cond = noReferenceCond<F, T>>
143 template <
class F,
class T,
class R,
class Cond = noReferenceCond<F, T>>
145 template<
class F,
class T,
class Cond = noReferenceCond<F, T>>
147 template<
class F,
class T,
class Cond = noReferenceCond<F, T>>
150 template<
class T> T*
Reduce(
const std::vector<T*> &mergeObjs);
151 template<
class T,
class R>
auto Reduce(
const std::vector<T> &objs,
R redfunc) ->
decltype(redfunc(objs));
157 return *
static_cast<SubC*
>(
this);
161 template <
class F,
class Cond = noReferenceCond<F>>
162 auto MapImpl(
F func,
unsigned nTimes) -> std::vector<InvokeResult_t<F>> =
delete;
164 template <
class F,
class INTEGER,
class Cond = noReferenceCond<F, INTEGER>>
167 template <
class F,
class T,
class Cond = noReferenceCond<F, T>>
168 auto MapImpl(
F func, std::vector<T> &args) -> std::vector<InvokeResult_t<F, T>> =
delete;
170 template <
class F,
class T,
class Cond = noReferenceCond<F, T>>
171 auto MapImpl(
F func,
const std::vector<T> &args) -> std::vector<InvokeResult_t<F, T>> =
delete;
183template <
class F,
class Cond>
186 return Derived().MapImpl(func, nTimes);
196template <
class F,
class INTEGER,
class Cond>
199 return Derived().MapImpl(func, args);
209template <
class F,
class T,
class Cond>
212 std::vector<T> vargs(std::move(args));
213 const auto &reslist = Map(func, vargs);
224template <
class F,
class T,
class Cond>
227 return Derived().MapImpl(func, args);
238template <
class F,
class T,
class Cond>
241 return Derived().MapImpl(func, args);
253template <
class F,
class R,
class Cond>
256 return Reduce(Map(func, nTimes), redfunc);
267template <
class F,
class INTEGER,
class R,
class Cond>
270 return Reduce(Map(func, args), redfunc);
281template <
class F,
class T,
class R,
class Cond>
284 std::vector<T> vargs(std::move(args));
285 return Reduce(Map(func, vargs), redfunc);
296template <
class F,
class T,
class R,
class Cond>
299 return Reduce(Map(func, args), redfunc);
310template <
class F,
class T,
class R,
class Cond>
313 return Reduce(Map(func, args), redfunc);
322template<
class SubC>
template<
class F,
class T,
class Cond>
325 return Reduce(Map(func, args));
334template<
class SubC>
template<
class F,
class T,
class Cond>
337 return Reduce(Map(func, args));
345template<
class SubC>
template<
class T>
350 Error(
"TExecutorCRTP<SubC>::Reduce",
"could not find merge method for the TObject\n. Aborting operation.");
355 for(
unsigned i =1; i<mergeObjs.size(); i++){
359 auto retHist =
dynamic_cast<T*
>((mergeObjs.front())->Clone());
360 if (retHist) retHist->Merge(&
l);
371template<
class SubC>
template<
class T,
class R>
375 static_assert(std::is_same<
decltype(redfunc(objs)), T>
::value,
"redfunc does not have the correct signature");
376 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.
std::enable_if_t<"Function can't return a reference" &&!std::is_reference< InvokeResult_t< F, T... > >::value > noReferenceCond
type definition in used in templated functions for not allowing mapping functions that return referen...
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.
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.
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.
Long64_t(* MergeFunc_t)(void *, TCollection *, TFileMergeInfo *)