Logo ROOT  
Reference Guide
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
17#include "ROOT/RDF/Utils.hxx"
18#include "ROOT/RVec.hxx"
19
20#include <deque>
21#include <map>
22#include <memory>
23#include <string>
24#include <vector>
25
26class TTreeReader;
27
28namespace ROOT {
29namespace RDF {
30class RDataSource;
31}
32namespace Detail {
33namespace RDF {
34
36
38protected:
39 const std::string fName; ///< The name of the custom column
40 const std::string fType; ///< The type of the custom column as a text string
41 std::vector<Long64_t> fLastCheckedEntry;
43 std::deque<bool> fIsInitialized; // because vector<bool> is not thread-safe
44 const std::map<std::string, std::vector<void *>> &fDSValuePtrs; // reference to RLoopManager's data member
45 ROOT::RDF::RDataSource *fDataSource; ///< non-owning ptr to the RDataSource, if any. Used to retrieve column readers.
47 /// The nth flag signals whether the nth input column is a custom column or not.
49
50public:
52 const RDFInternal::RBookedDefines &defines,
53 const std::map<std::string, std::vector<void *>> &DSValuePtrs, ROOT::RDF::RDataSource *ds,
54 const ColumnNames_t &columnNames);
55
56 RDefineBase &operator=(const RDefineBase &) = delete;
58 virtual ~RDefineBase();
59 virtual void InitSlot(TTreeReader *r, unsigned int slot) = 0;
60 /// Return the (type-erased) address of the Define'd value for the given processing slot.
61 virtual void *GetValuePtr(unsigned int slot) = 0;
62 virtual const std::type_info &GetTypeId() const = 0;
63 std::string GetName() const;
64 std::string GetTypeName() const;
65 /// Update the value at the address returned by GetValuePtr with the content corresponding to the given entry
66 virtual void Update(unsigned int slot, Long64_t entry) = 0;
67 /// Update function to be called once per sample, used if the derived type is a RDefinePerSample
68 virtual void Update(unsigned int /*slot*/, const ROOT::RDF::RSampleInfo &/*id*/) {}
69 /// Clean-up operations to be performed at the end of a task.
70 virtual void FinaliseSlot(unsigned int slot) = 0;
71};
72
73} // ns RDF
74} // ns Detail
75} // ns ROOT
76
77#endif // ROOT_RCUSTOMCOLUMNBASE
ROOT::R::TRInterface & r
Definition: Object.C:4
long long Long64_t
Definition: RtypesCore.h:80
char name[80]
Definition: TGX11.cxx:110
int type
Definition: TGX11.cxx:121
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
Definition: RDefineBase.hxx:42
std::deque< bool > fIsInitialized
Definition: RDefineBase.hxx:43
ROOT::RVecB fIsDefine
The nth flag signals whether the nth input column is a custom column or not.
Definition: RDefineBase.hxx:48
const std::string fType
The type of the custom column as a text string.
Definition: RDefineBase.hxx:40
virtual void Update(unsigned int, const ROOT::RDF::RSampleInfo &)
Update function to be called once per sample, used if the derived type is a RDefinePerSample.
Definition: RDefineBase.hxx:68
RDefineBase(std::string_view name, std::string_view type, unsigned int nSlots, const RDFInternal::RBookedDefines &defines, const std::map< std::string, std::vector< void * > > &DSValuePtrs, ROOT::RDF::RDataSource *ds, const ColumnNames_t &columnNames)
Definition: RDefineBase.cxx:23
std::string GetTypeName() const
Definition: RDefineBase.cxx:44
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
Definition: RDefineBase.cxx:39
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.
Definition: RDefineBase.hxx:45
const ROOT::RDF::ColumnNames_t fColumnNames
Definition: RDefineBase.hxx:46
std::vector< Long64_t > fLastCheckedEntry
Definition: RDefineBase.hxx:41
const std::string fName
The name of the custom column.
Definition: RDefineBase.hxx:39
virtual const std::type_info & GetTypeId() const =0
const std::map< std::string, std::vector< void * > > & fDSValuePtrs
Definition: RDefineBase.hxx:44
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.
This type represents a sample identifier, to be used in conjunction with RDataFrame features such as ...
Definition: RSampleInfo.hxx:32
A simple, robust and fast interface to read values from ROOT columnar datasets such as TTree,...
Definition: TTreeReader.h:44
basic_string_view< char > string_view
std::vector< std::string > ColumnNames_t
Definition: Utils.hxx:35
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...