Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RDefineBase.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
16
17#include <deque>
18#include <map>
19#include <memory>
20#include <string>
21#include <vector>
22
23class TTreeReader;
24
25namespace ROOT {
26namespace RDF {
27class RDataSource;
28}
29namespace Detail {
30namespace RDF {
31
33
35protected:
36 const std::string fName; ///< The name of the custom column
37 const std::string fType; ///< The type of the custom column as a text string
38 unsigned int fNChildren{0}; ///< number of nodes of the functional graph hanging from this object
39 unsigned int fNStopsReceived{0}; ///< number of times that a children node signaled to stop processing entries.
40 const unsigned int fNSlots; ///< number of thread slots used by this node, inherited from parent node.
41 std::vector<Long64_t> fLastCheckedEntry;
42 /// A unique ID that identifies this custom column.
43 /// Used e.g. to distinguish custom columns with the same name in different branches of the computation graph.
44 const unsigned int fID = GetNextID();
46 std::deque<bool> fIsInitialized; // because vector<bool> is not thread-safe
47 const std::map<std::string, std::vector<void *>> &fDSValuePtrs; // reference to RLoopManager's data member
48 ROOT::RDF::RDataSource *fDataSource; ///< non-owning ptr to the RDataSource, if any. Used to retrieve column readers.
49
50 static unsigned int GetNextID();
51
52public:
53 RDefineBase(std::string_view name, std::string_view type, unsigned int nSlots,
54 const RDFInternal::RBookedDefines &defines,
55 const std::map<std::string, std::vector<void *>> &DSValuePtrs, ROOT::RDF::RDataSource *ds);
56
57 RDefineBase &operator=(const RDefineBase &) = delete;
59 virtual ~RDefineBase();
60 virtual void InitSlot(TTreeReader *r, unsigned int slot) = 0;
61 /// Return the (type-erased) address of the Define'd value for the given processing slot.
62 virtual void *GetValuePtr(unsigned int slot) = 0;
63 virtual const std::type_info &GetTypeId() const = 0;
64 std::string GetName() const;
65 std::string GetTypeName() const;
66 /// Update the value at the address returned by GetValuePtr with the content corresponding to the given entry
67 virtual void Update(unsigned int slot, Long64_t entry) = 0;
68 /// Clean-up operations to be performed at the end of a task.
69 virtual void FinaliseSlot(unsigned int slot) = 0;
70 /// Return the unique identifier of this RDefineBase.
71 unsigned int GetID() const { return fID; }
72};
73
74} // ns RDF
75} // ns Detail
76} // ns ROOT
77
78#endif // ROOT_RCUSTOMCOLUMNBASE
ROOT::R::TRInterface & r
Definition Object.C:4
long long Long64_t
Definition RtypesCore.h:73
char name[80]
Definition TGX11.cxx:110
int type
Definition TGX11.cxx:121
unsigned int fNChildren
number of nodes of the functional graph hanging from this object
virtual void * GetValuePtr(unsigned int slot)=0
Return the (type-erased) address of the Define'd value for the given processing slot.
RDFInternal::RBookedDefines fDefines
const unsigned int fID
A unique ID that identifies this custom column.
std::deque< bool > fIsInitialized
const std::string fType
The type of the custom column as a text string.
std::string GetTypeName() const
unsigned int GetID() const
Return the unique identifier of this RDefineBase.
virtual void Update(unsigned int slot, Long64_t entry)=0
Update the value at the address returned by GetValuePtr with the content corresponding to the given e...
virtual void InitSlot(TTreeReader *r, unsigned int slot)=0
std::string GetName() const
unsigned int fNStopsReceived
number of times that a children node signaled to stop processing entries.
static unsigned int GetNextID()
virtual void FinaliseSlot(unsigned int slot)=0
Clean-up operations to be performed at the end of a task.
ROOT::RDF::RDataSource * fDataSource
non-owning ptr to the RDataSource, if any. Used to retrieve column readers.
std::vector< Long64_t > fLastCheckedEntry
const std::string fName
The name of the custom column.
const unsigned int fNSlots
number of thread slots used by this node, inherited from parent node.
virtual const std::type_info & GetTypeId() const =0
const std::map< std::string, std::vector< void * > > & fDSValuePtrs
RDefineBase & operator=(const RDefineBase &)=delete
RDefineBase & operator=(RDefineBase &&)=delete
Encapsulates the columns defined by the user.
RDataSource defines an API that RDataFrame can use to read arbitrary data formats.
A simple, robust and fast interface to read values from ROOT columnar datasets such as TTree,...
Definition TTreeReader.h:44
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...