Logo ROOT  
Reference Guide
RActionBase.hxx
Go to the documentation of this file.
1// Author: Enrico Guiraud, Danilo Piparo CERN 09/2018
2
3/*************************************************************************
4 * Copyright (C) 1995-2020, Rene Brun and Fons Rademakers. *
5 * All rights reserved. *
6 * *
7 * For the licensing terms see $ROOTSYS/LICENSE. *
8 * For the list of contributors see $ROOTSYS/README/CREDITS. *
9 *************************************************************************/
10
11#ifndef ROOT_RACTIONBASE
12#define ROOT_RACTIONBASE
13
16#include "ROOT/RDF/Utils.hxx" // ColumnNames_t
17#include "RtypesCore.h"
18
19#include <memory>
20#include <string>
21
22namespace ROOT {
23
24namespace Detail {
25namespace RDF {
26class RLoopManager;
27class RDefineBase;
28class RMergeableValueBase;
29} // namespace RDF
30} // namespace Detail
31
32namespace Internal {
33namespace RDF {
34namespace GraphDrawing {
35class GraphNode;
36}
37
38using namespace ROOT::Detail::RDF;
39
41protected:
42 /// A raw pointer to the RLoopManager at the root of this functional graph.
43 /// Never null: children nodes have shared ownership of parent nodes in the graph.
45
46private:
47 const unsigned int fNSlots; ///< Number of thread slots used by this node.
48 bool fHasRun = false;
50
52
53public:
54 RActionBase(RLoopManager *lm, const ColumnNames_t &colNames, const RColumnRegister &colRegister);
55 RActionBase(const RActionBase &) = delete;
56 RActionBase &operator=(const RActionBase &) = delete;
57 virtual ~RActionBase();
58
59 const ColumnNames_t &GetColumnNames() const { return fColumnNames; }
62 unsigned int GetNSlots() const { return fNSlots; }
63 virtual void Run(unsigned int slot, Long64_t entry) = 0;
64 virtual void Initialize() = 0;
65 virtual void InitSlot(TTreeReader *r, unsigned int slot) = 0;
66 virtual void TriggerChildrenCount() = 0;
67 virtual void FinalizeSlot(unsigned int) = 0;
68 virtual void Finalize() = 0;
69 /// This method is invoked to update a partial result during the event loop, right before passing the result to a
70 /// user-defined callback registered via RResultPtr::RegisterCallback
71 virtual void *PartialUpdate(unsigned int slot) = 0;
72
73 // overridden by RJittedAction
74 virtual bool HasRun() const { return fHasRun; }
75 virtual void SetHasRun() { fHasRun = true; }
76
77 virtual std::shared_ptr<ROOT::Internal::RDF::GraphDrawing::GraphNode>
78 GetGraph(std::unordered_map<void *, std::shared_ptr<ROOT::Internal::RDF::GraphDrawing::GraphNode>> &visitedMap) = 0;
79
80 /**
81 Retrieve a wrapper to the result of the action that knows how to merge
82 with others of the same type.
83 */
84 virtual std::unique_ptr<RMergeableValueBase> GetMergeableValue() const = 0;
85
87};
88} // namespace RDF
89} // namespace Internal
90} // namespace ROOT
91
92#endif // ROOT_RACTIONBASE
ROOT::R::TRInterface & r
Definition: Object.C:4
long long Long64_t
Definition: RtypesCore.h:80
The head node of a RDF computation graph.
Class used to create the operation graph to be printed in the dot representation.
Definition: GraphNode.hxx:26
const ColumnNames_t fColumnNames
Definition: RActionBase.hxx:49
const unsigned int fNSlots
Number of thread slots used by this node.
Definition: RActionBase.hxx:47
RActionBase & operator=(const RActionBase &)=delete
virtual std::unique_ptr< RMergeableValueBase > GetMergeableValue() const =0
Retrieve a wrapper to the result of the action that knows how to merge with others of the same type.
virtual void TriggerChildrenCount()=0
unsigned int GetNSlots() const
Definition: RActionBase.hxx:62
virtual void Run(unsigned int slot, Long64_t entry)=0
const ColumnNames_t & GetColumnNames() const
Definition: RActionBase.hxx:59
virtual void FinalizeSlot(unsigned int)=0
virtual ROOT::RDF::SampleCallback_t GetSampleCallback()=0
RActionBase(const RActionBase &)=delete
virtual bool HasRun() const
Definition: RActionBase.hxx:74
virtual void * PartialUpdate(unsigned int slot)=0
This method is invoked to update a partial result during the event loop, right before passing the res...
RLoopManager * fLoopManager
A raw pointer to the RLoopManager at the root of this functional graph.
Definition: RActionBase.hxx:44
RColumnRegister & GetColRegister()
Definition: RActionBase.hxx:60
virtual void InitSlot(TTreeReader *r, unsigned int slot)=0
RActionBase(RLoopManager *lm, const ColumnNames_t &colNames, const RColumnRegister &colRegister)
Definition: RActionBase.cxx:16
virtual std::shared_ptr< ROOT::Internal::RDF::GraphDrawing::GraphNode > GetGraph(std::unordered_map< void *, std::shared_ptr< ROOT::Internal::RDF::GraphDrawing::GraphNode > > &visitedMap)=0
A binder for user-defined columns and aliases.
A simple, robust and fast interface to read values from ROOT columnar datasets such as TTree,...
Definition: TTreeReader.h:44
std::vector< std::string > ColumnNames_t
Definition: Utils.hxx:35
std::function< void(unsigned int, const ROOT::RDF::RSampleInfo &)> SampleCallback_t
The type of a data-block callback, registered with a RDataFrame computation graph via e....
Definition: RSampleInfo.hxx:84
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.