Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
RActionBase.hxx
Go to the documentation of this file.
1 // Author: Enrico Guiraud, Danilo Piparo CERN 09/2018
2 
3 /*************************************************************************
4  * Copyright (C) 1995-2018, 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 
15 #include "ROOT/RDF/Utils.hxx" // ColumnNames_t
16 #include "RtypesCore.h"
17 
18 #include <memory>
19 #include <string>
20 
21 namespace ROOT {
22 
23 namespace Detail {
24 namespace RDF {
25 class RLoopManager;
26 class RCustomColumnBase;
27 }
28 }
29 
30 namespace Internal {
31 namespace RDF {
32 namespace GraphDrawing {
33 class GraphNode;
34 }
35 
36 using namespace ROOT::Detail::RDF;
37 
38 // fwd decl for RActionBase
39 namespace GraphDrawing {
40 bool CheckIfDefaultOrDSColumn(const std::string &name,
41  const std::shared_ptr<ROOT::Detail::RDF::RCustomColumnBase> &column);
42 } // namespace GraphDrawing
43 
44 class RActionBase {
45 protected:
46  /// A raw pointer to the RLoopManager at the root of this functional graph.
47  /// Never null: children nodes have shared ownership of parent nodes in the graph.
48  RLoopManager *fLoopManager;
49 
50 private:
51  const unsigned int fNSlots; ///< Number of thread slots used by this node.
52  bool fHasRun = false;
53  const ColumnNames_t fColumnNames;
54 
55  RBookedCustomColumns fCustomColumns;
56 
57 public:
58  RActionBase(RLoopManager *lm, const ColumnNames_t &colNames, RBookedCustomColumns &&customColumns);
59  RActionBase(const RActionBase &) = delete;
60  RActionBase &operator=(const RActionBase &) = delete;
61  virtual ~RActionBase();
62 
63  const ColumnNames_t &GetColumnNames() const { return fColumnNames; }
64  RBookedCustomColumns &GetCustomColumns() { return fCustomColumns; }
65  RLoopManager *GetLoopManager() { return fLoopManager; }
66  unsigned int GetNSlots() const { return fNSlots; }
67  virtual void Run(unsigned int slot, Long64_t entry) = 0;
68  virtual void Initialize() = 0;
69  virtual void InitSlot(TTreeReader *r, unsigned int slot) = 0;
70  virtual void TriggerChildrenCount() = 0;
71  virtual void ClearValueReaders(unsigned int slot) = 0;
72  virtual void FinalizeSlot(unsigned int) = 0;
73  virtual void Finalize() = 0;
74  /// This method is invoked to update a partial result during the event loop, right before passing the result to a
75  /// user-defined callback registered via RResultPtr::RegisterCallback
76  virtual void *PartialUpdate(unsigned int slot) = 0;
77 
78  // overridden by RJittedAction
79  virtual bool HasRun() const { return fHasRun; }
80  virtual void SetHasRun() { fHasRun = true; }
81 
82  virtual std::shared_ptr<ROOT::Internal::RDF::GraphDrawing::GraphNode> GetGraph() = 0;
83 };
84 
85 } // ns RDF
86 } // ns Internal
87 } // ns ROOT
88 
89 #endif // ROOT_RACTIONBASE