Warning, file /include/root/PoolUtils.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef ROOT_PoolUtils
0013 #define ROOT_PoolUtils
0014
0015 #include "TError.h"
0016 #include "TList.h"
0017 #include "TObject.h"
0018 #include <vector>
0019
0020
0021 namespace ROOT {
0022
0023
0024
0025
0026
0027
0028 namespace ExecutorUtils {
0029
0030
0031
0032
0033
0034 template <class T>
0035 class ReduceObjects{
0036 public:
0037 T operator()(const std::vector<T> &objs){
0038 static_assert(std::is_constructible<TObject *, T>::value,
0039 "The argument should be a vector of pointers to TObject or derived classes");
0040 if(objs.size() == 0)
0041 return nullptr;
0042
0043 if(objs.size() == 1)
0044 return objs[0];
0045
0046
0047 auto obj = objs[0];
0048
0049 ROOT::MergeFunc_t merge = obj->IsA()->GetMerge();
0050 if(!merge) {
0051 Error("PoolUtils::ReduceObjects", "could not find merge method for the TObject\n. Aborting operation.");
0052 return nullptr;
0053 }
0054
0055
0056 TList mergelist;
0057 unsigned NObjs = objs.size();
0058 for(unsigned i=1; i<NObjs; ++i)
0059 mergelist.Add(objs[i]);
0060
0061
0062 merge(obj, &mergelist, nullptr);
0063 mergelist.Delete();
0064
0065
0066 return obj;
0067 }
0068 };
0069 }
0070 }
0071
0072
0073 namespace PoolUtils = ROOT::ExecutorUtils;
0074
0075 namespace ROOT {
0076 namespace Internal {
0077 namespace ExecutorUtils {
0078
0079
0080 template <class O, class F>
0081 class ResultCaster {
0082 public:
0083 static O CastIfNeeded(O &&obj)
0084 {
0085 return obj;
0086 }
0087 };
0088 template <class F>
0089 class ResultCaster<TObject *, F> {
0090 public:
0091 static typename std::enable_if<std::is_pointer<F>::value, F>::type CastIfNeeded(TObject *obj)
0092 {
0093 return static_cast<F>(obj);
0094 }
0095 };
0096 }
0097
0098 namespace PoolUtils = ExecutorUtils;
0099 }
0100 }
0101
0102
0103 #endif