Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
RCustomColumnBase.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_RCUSTOMCOLUMNBASE
12 #define ROOT_RCUSTOMCOLUMNBASE
13 
14 #include "ROOT/RDF/GraphNode.hxx"
16 
17 #include <memory>
18 #include <string>
19 #include <vector>
20 #include <deque>
21 
22 class TTreeReader;
23 
24 namespace ROOT {
25 namespace Detail {
26 namespace RDF {
27 
28 namespace RDFInternal = ROOT::Internal::RDF;
29 class RLoopManager;
30 
31 class RCustomColumnBase {
32 protected:
33  RLoopManager *fLoopManager; ///< A raw pointer to the RLoopManager at the root of this functional graph. It is only
34  /// guaranteed to contain a valid address during an event loop.
35  const std::string fName;
36  unsigned int fNChildren{0}; ///< number of nodes of the functional graph hanging from this object
37  unsigned int fNStopsReceived{0}; ///< number of times that a children node signaled to stop processing entries.
38  const unsigned int fNSlots; ///< number of thread slots used by this node, inherited from parent node.
39  const bool fIsDataSourceColumn; ///< does the custom column refer to a data-source column? (or a user-define column?)
40  std::vector<Long64_t> fLastCheckedEntry;
41  /// A unique ID that identifies this custom column.
42  /// Used e.g. to distinguish custom columns with the same name in different branches of the computation graph.
43  const unsigned int fID = GetNextID();
44  RDFInternal::RBookedCustomColumns fCustomColumns;
45  std::deque<bool> fIsInitialized; // because vector<bool> is not thread-safe
46 
47  static unsigned int GetNextID();
48 
49 public:
50  RCustomColumnBase(RLoopManager *lm, std::string_view name, const unsigned int nSlots, const bool isDSColumn,
51  const RDFInternal::RBookedCustomColumns &customColumns);
52 
53  RCustomColumnBase &operator=(const RCustomColumnBase &) = delete;
54  virtual ~RCustomColumnBase();
55  virtual void InitSlot(TTreeReader *r, unsigned int slot) = 0;
56  virtual void *GetValuePtr(unsigned int slot) = 0;
57  virtual const std::type_info &GetTypeId() const = 0;
58  RLoopManager *GetLoopManagerUnchecked() const;
59  std::string GetName() const;
60  virtual void Update(unsigned int slot, Long64_t entry) = 0;
61  virtual void ClearValueReaders(unsigned int slot) = 0;
62  bool IsDataSourceColumn() const { return fIsDataSourceColumn; }
63  virtual void InitNode();
64  /// Return the unique identifier of this RCustomColumnBase.
65  unsigned int GetID() const { return fID; }
66 };
67 
68 } // ns RDF
69 } // ns Detail
70 } // ns ROOT
71 
72 #endif // ROOT_RCUSTOMCOLUMNBASE