Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RActionImpl.hxx
Go to the documentation of this file.
1/*************************************************************************
2 * Copyright (C) 1995-2022, Rene Brun and Fons Rademakers. *
3 * All rights reserved. *
4 * *
5 * For the licensing terms see $ROOTSYS/LICENSE. *
6 * For the list of contributors see $ROOTSYS/README/CREDITS. *
7 *************************************************************************/
8
9#ifndef ROOT_RDF_DETAIL_RACTIONIMPL
10#define ROOT_RDF_DETAIL_RACTIONIMPL
11
12#include <ROOT/RDF/RSampleInfo.hxx> // SampleCallback_t
13
14#include <memory> // std::unique_ptr
15#include <stdexcept> // std::logic_error
16#include <utility> // std::declval
17
18namespace ROOT::Internal::RDF {
19template <typename T>
21 template <typename C, typename = decltype(std::declval<C>().MakeNew((void *)(nullptr), std::string_view{}))>
22 static std::true_type Test(int);
23 template <typename C>
24 static std::false_type Test(...);
25
26public:
27 static constexpr bool value = decltype(Test<T>(0))::value;
28};
29} // namespace ROOT::Internal::RDF
30
31namespace ROOT {
32namespace Detail {
33namespace RDF {
34
35class RMergeableValueBase;
36
37/// Base class for action helpers, see RInterface::Book() for more information.
38template <typename Helper>
40public:
41 virtual ~RActionImpl() = default;
42 // call Helper::FinalizeTask if present, do nothing otherwise
43 template <typename T = Helper>
44 auto CallFinalizeTask(unsigned int slot) -> decltype(std::declval<T>().FinalizeTask(slot))
45 {
46 static_cast<Helper *>(this)->FinalizeTask(slot);
47 }
48
49 template <typename... Args>
50 void CallFinalizeTask(unsigned int, Args...) {}
51
52 template <typename H = Helper>
53 auto CallPartialUpdate(unsigned int slot) -> decltype(std::declval<H>().PartialUpdate(slot), (void *)(nullptr))
54 {
55 return &static_cast<Helper *>(this)->PartialUpdate(slot);
56 }
57
58 template <typename... Args>
60 {
61 throw std::logic_error("This action does not support callbacks!");
62 }
63
64 Helper CallMakeNew(void *typeErasedResSharedPtr, std::string_view variation = "nominal")
65 {
67 return static_cast<Helper *>(this)->MakeNew(typeErasedResSharedPtr, variation);
68 else {
69 // Avoid unused parameter warning with GCC
71 (void)variation;
72 const auto &actionName = static_cast<Helper *>(this)->GetActionName();
73 throw std::logic_error("The MakeNew method is not implemented for this action helper (" + actionName +
74 "). Cannot Vary its result.");
75 }
76 }
77
78 // Helper functions for RMergeableValue
79 virtual std::unique_ptr<RMergeableValueBase> GetMergeableValue() const
80 {
81 throw std::logic_error("`GetMergeableValue` is not implemented for this type of action.");
82 }
83
84 /// Override this method to register a callback that is executed before the processing a new data sample starts.
85 /// The callback will be invoked in the same conditions as with DefinePerSample().
87};
88
89} // namespace RDF
90} // namespace Detail
91} // namespace ROOT
92
93#endif // ROOT_RDF_DETAIL_RACTIONIMPL
94
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Base class for action helpers, see RInterface::Book() for more information.
auto CallFinalizeTask(unsigned int slot) -> decltype(std::declval< T >().FinalizeTask(slot))
virtual ~RActionImpl()=default
virtual ROOT::RDF::SampleCallback_t GetSampleCallback()
Override this method to register a callback that is executed before the processing a new data sample ...
auto CallPartialUpdate(unsigned int slot) -> decltype(std::declval< H >().PartialUpdate(slot),(void *)(nullptr))
virtual std::unique_ptr< RMergeableValueBase > GetMergeableValue() const
Helper CallMakeNew(void *typeErasedResSharedPtr, std::string_view variation="nominal")
void CallFinalizeTask(unsigned int, Args...)
static constexpr bool value
static std::false_type Test(...)
static std::true_type Test(int)
std::function< void(unsigned int, const ROOT::RDF::RSampleInfo &)> SampleCallback_t
The type of a data-block callback, registered with an RDataFrame computation graph via e....
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...