Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RVariationReader.hxx
Go to the documentation of this file.
1// Author: Enrico Guiraud CERN 11/2021
2
3/*************************************************************************
4 * Copyright (C) 1995-2021, 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_RDF_RVARIATIONREADER
12#define ROOT_RDF_RVARIATIONREADER
13
14#include "RColumnReaderBase.hxx"
15#include "RVariationBase.hxx"
16#include <Rtypes.h> // Long64_t, R__CLING_PTRCHECK
17
18#include <limits>
19#include <type_traits>
20
21namespace ROOT {
22namespace Internal {
23namespace RDF {
24
25/// Column reader that reads the value for a specific column, variation and slot.
26class R__CLING_PTRCHECK(off) RVariationReader final : public ROOT::Detail::RDF::RColumnReaderBase {
28
29 /// Non-owning ptr to the value of the variation.
30 void *fValuePtr = nullptr;
31
32 /// The slot this value belongs to.
33 unsigned int fSlot = std::numeric_limits<unsigned int>::max();
34
35 void *GetImpl(Long64_t entry) final
36 {
37 fVariation->Update(fSlot, entry);
38 return fValuePtr;
39 }
40
41public:
42 RVariationReader(unsigned int slot, const std::string &colName, const std::string &variationName,
43 RVariationBase &variation)
44 : fVariation(&variation), fValuePtr(variation.GetValuePtr(slot, colName, variationName)), fSlot(slot)
45 {
46 }
47};
48
50 // this is a shared_ptr only because we have to track its lifetime with a weak_ptr that we pass to jitted code
51 // (see BookVariationJit). it is never null.
52 std::shared_ptr<RVariationBase> fVariation;
53 // Column readers for this RVariation for a given variation (map key) and a given slot (vector element).
54 std::vector<std::unordered_map<std::string, std::unique_ptr<RVariationReader>>> fReadersPerVariation;
55
56public:
57 RVariationsWithReaders(std::shared_ptr<RVariationBase> variation, unsigned int nSlots);
58 RVariationBase &GetVariation() const { return *fVariation; }
59 RVariationReader &GetReader(unsigned int slot, const std::string &colName, const std::string &variationName);
60};
61
62} // namespace RDF
63} // namespace Internal
64} // namespace ROOT
65
66#endif
long long Long64_t
Definition RtypesCore.h:69
This type includes all parts of RVariation that do not depend on the callable signature.
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...
Column reader that reads the value for a specific column, variation and slot.
RVariationReader(unsigned int slot, const std::string &colName, const std::string &variationName, RVariationBase &variation)
void * GetImpl(Long64_t entry) final
std::vector< std::unordered_map< std::string, std::unique_ptr< RVariationReader > > > fReadersPerVariation
std::shared_ptr< RVariationBase > fVariation
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...