File indexing completed on 2025-12-16 10:29:48
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef ROOT_RDF_DETAIL_RACTIONIMPL
0010 #define ROOT_RDF_DETAIL_RACTIONIMPL
0011
0012 #include <ROOT/RDF/RSampleInfo.hxx> // SampleCallback_t
0013
0014 #include <memory> // std::unique_ptr
0015 #include <stdexcept> // std::logic_error
0016 #include <utility> // std::declval
0017
0018 namespace ROOT::Internal::RDF {
0019 template <typename T>
0020 class HasMakeNew {
0021 template <typename C, typename = decltype(std::declval<C>().MakeNew((void *)(nullptr), std::string_view{}))>
0022 static std::true_type Test(int);
0023 template <typename C>
0024 static std::false_type Test(...);
0025
0026 public:
0027 static constexpr bool value = decltype(Test<T>(0))::value;
0028 };
0029 }
0030
0031 namespace ROOT {
0032 namespace Detail {
0033 namespace RDF {
0034
0035 class RMergeableValueBase;
0036
0037
0038 template <typename Helper>
0039 class R__CLING_PTRCHECK(off) RActionImpl {
0040 public:
0041 virtual ~RActionImpl() = default;
0042
0043 template <typename T = Helper>
0044 auto CallFinalizeTask(unsigned int slot) -> decltype(std::declval<T>().FinalizeTask(slot))
0045 {
0046 static_cast<Helper *>(this)->FinalizeTask(slot);
0047 }
0048
0049 template <typename... Args>
0050 void CallFinalizeTask(unsigned int, Args...) {}
0051
0052 template <typename H = Helper>
0053 auto CallPartialUpdate(unsigned int slot) -> decltype(std::declval<H>().PartialUpdate(slot), (void *)(nullptr))
0054 {
0055 return &static_cast<Helper *>(this)->PartialUpdate(slot);
0056 }
0057
0058 template <typename... Args>
0059 [[noreturn]] void *CallPartialUpdate(...)
0060 {
0061 throw std::logic_error("This action does not support callbacks!");
0062 }
0063
0064 Helper CallMakeNew(void *typeErasedResSharedPtr, std::string_view variation = "nominal")
0065 {
0066 if constexpr (ROOT::Internal::RDF::HasMakeNew<Helper>::value)
0067 return static_cast<Helper *>(this)->MakeNew(typeErasedResSharedPtr, variation);
0068 else {
0069
0070 (void)typeErasedResSharedPtr;
0071 (void)variation;
0072 const auto &actionName = static_cast<Helper *>(this)->GetActionName();
0073 throw std::logic_error("The MakeNew method is not implemented for this action helper (" + actionName +
0074 "). Cannot Vary its result.");
0075 }
0076 }
0077
0078
0079 virtual std::unique_ptr<RMergeableValueBase> GetMergeableValue() const
0080 {
0081 throw std::logic_error("`GetMergeableValue` is not implemented for this type of action.");
0082 }
0083
0084
0085
0086 virtual ROOT::RDF::SampleCallback_t GetSampleCallback() { return {}; }
0087 };
0088
0089 }
0090 }
0091 }
0092
0093 #endif
0094