Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RVariationReader.cxx
Go to the documentation of this file.
1/**
2 \author Vincenzo Eduardo Padulano
3 \date 2024-04
4*/
5
6/*************************************************************************
7 * Copyright (C) 1995-2024, Rene Brun and Fons Rademakers. *
8 * All rights reserved. *
9 * *
10 * For the licensing terms see $ROOTSYS/LICENSE. *
11 * For the list of contributors see $ROOTSYS/README/CREDITS. *
12 *************************************************************************/
13#include <cassert>
14
16#include "ROOT/RDF/Utils.hxx" // IsStrInVec
17
19 std::shared_ptr<ROOT::Internal::RDF::RVariationBase> variation, unsigned int nSlots)
20 : fVariation(std::move(variation)), fReadersPerVariation(nSlots)
21{
22 assert(fVariation != nullptr);
23}
24
25////////////////////////////////////////////////////////////////////////////
26/// Return a column reader for the given slot, column and variation.
28ROOT::Internal::RDF::RVariationsWithReaders::GetReader(unsigned int slot, const std::string &colName,
29 const std::string &variationName)
30{
31 assert(ROOT::Internal::RDF::IsStrInVec(variationName, fVariation->GetVariationNames()));
32 assert(ROOT::Internal::RDF::IsStrInVec(colName, fVariation->GetColumnNames()));
33
34 auto &varReaders = fReadersPerVariation[slot];
35
36 auto it = varReaders.find(variationName);
37 if (it != varReaders.end())
38 return *it->second;
39
40#if !defined(__clang__) && __GNUC__ >= 7 && __GNUC_MINOR__ >= 3
41 const auto insertion = varReaders.insert({variationName, std::make_unique<ROOT::Internal::RDF::RVariationReader>(
42 slot, colName, variationName, *fVariation)});
43 return *insertion.first->second;
44#else
45 // gcc < 7.3 has issues with passing the non-movable std::pair temporary into the insert call
46 auto reader = std::make_unique<ROOT::Internal::RDF::RVariationReader>(slot, colName, variationName, *fVariation);
47 auto &ret = *reader;
48 varReaders[variationName] = std::move(reader);
49 return ret;
50#endif
51}
Column reader that reads the value for a specific column, variation and slot.
RVariationReader & GetReader(unsigned int slot, const std::string &colName, const std::string &variationName)
Return a column reader for the given slot, column and variation.
RVariationsWithReaders(std::shared_ptr< RVariationBase > variation, unsigned int nSlots)
std::shared_ptr< RVariationBase > fVariation
bool IsStrInVec(const std::string &str, const std::vector< std::string > &vec)
Definition RDFUtils.cxx:424