Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RDefineReader.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
17ROOT::Internal::RDF::RDefinesWithReaders::RDefinesWithReaders(std::shared_ptr<ROOT::Detail::RDF::RDefineBase> define,
18 unsigned int nSlots,
20 : fDefine(std::move(define)), fReadersPerVariation(nSlots), fCachedColNames(cachedColNames)
21{
22 assert(fDefine != nullptr);
23}
24
26ROOT::Internal::RDF::RDefinesWithReaders::GetReader(unsigned int slot, std::string_view variationName)
27{
28 auto nameIt = fCachedColNames.Insert(std::string(variationName));
29 auto &defineReaders = fReadersPerVariation[slot];
30
31 auto it = defineReaders.find(*nameIt);
32 if (it != defineReaders.end())
33 return *it->second;
34
35 auto *define = fDefine.get();
36 if (*nameIt != "nominal")
37 define = &define->GetVariedDefine(std::string(variationName));
38
39#if !defined(__clang__) && __GNUC__ >= 7 && __GNUC_MINOR__ >= 3
40 const auto insertion =
41 defineReaders.insert({*nameIt, std::make_unique<ROOT::Internal::RDF::RDefineReader>(slot, *define)});
42 return *insertion.first->second;
43#else
44 // gcc < 7.3 has issues with passing the non-movable std::pair temporary into the insert call
45 auto reader = std::make_unique<ROOT::Internal::RDF::RDefineReader>(slot, *define);
46 auto &ret = *reader;
47 defineReaders[*nameIt] = std::move(reader);
48 return ret;
49#endif
50}
Column reader for defined columns.
std::shared_ptr< ROOT::Detail::RDF::RDefineBase > fDefine
RDefinesWithReaders(std::shared_ptr< ROOT::Detail::RDF::RDefineBase > define, unsigned int nSlots, ROOT::Internal::RDF::RStringCache &cachedColNames)
ROOT::Internal::RDF::RDefineReader & GetReader(unsigned int slot, std::string_view variationName)
A Thread-safe cache for strings.
Definition Utils.hxx:286