Logo ROOT  
Reference Guide
RBookedDefines.hxx
Go to the documentation of this file.
1// Author: Enrico Guiraud, Danilo Piparo, Massimo Tumolo CERN 06/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_RDFBOOKEDCUSTOMCOLUMNS
12#define ROOT_RDFBOOKEDCUSTOMCOLUMNS
13
14#include <memory>
15#include <map>
16#include <vector>
17#include <string>
18#include <algorithm>
19#include "TString.h"
20
21namespace ROOT {
22namespace Detail {
23namespace RDF {
24class RDefineBase;
25}
26}
27
28namespace Internal {
29namespace RDF {
30
32
33/**
34 * \class ROOT::Internal::RDF::RBookedDefines
35 * \ingroup dataframe
36 * \brief Encapsulates the columns defined by the user
37 */
38
40 using RDefineBasePtrMap_t = std::map<std::string, std::shared_ptr<RDFDetail::RDefineBase>>;
41 using ColumnNames_t = std::vector<std::string>;
42
43 // Since RBookedDefines is meant to be an immutable, copy-on-write object, the actual values are set as const
44 using RDefineBasePtrMapPtr_t = std::shared_ptr<const RDefineBasePtrMap_t>;
45 using ColumnNamesPtr_t = std::shared_ptr<const ColumnNames_t>;
46
47private:
49 ColumnNamesPtr_t fDefinesNames; // also abused to keep track of aliases for each branch of the computation graph
50
51public:
52 ////////////////////////////////////////////////////////////////////////////
53 /// \brief Copy-ctor for RBookedDefines.
54 RBookedDefines(const RBookedDefines &) = default;
55
56 ////////////////////////////////////////////////////////////////////////////
57 /// \brief Move-ctor for RBookedDefines.
59
60 ////////////////////////////////////////////////////////////////////////////
61 /// \brief Copy-assignment operator for RBookedDefines.
63
64 ////////////////////////////////////////////////////////////////////////////
65 /// \brief Creates the object starting from the provided maps
67 : fDefines(defines), fDefinesNames(defineNames)
68 {
69 }
70
71 ////////////////////////////////////////////////////////////////////////////
72 /// \brief Creates a new wrapper with empty maps
74 : fDefines(std::make_shared<RDefineBasePtrMap_t>()),
75 fDefinesNames(std::make_shared<ColumnNames_t>())
76 {
77 }
78
79 ////////////////////////////////////////////////////////////////////////////
80 /// \brief Returns the list of the names of the defined columns
82
83 ////////////////////////////////////////////////////////////////////////////
84 /// \brief Returns the list of the pointers to the defined columns
85 const RDefineBasePtrMap_t &GetColumns() const { return *fDefines; }
86
87 ////////////////////////////////////////////////////////////////////////////
88 /// \brief Check if the provided name is tracked in the names list
89 bool HasName(std::string_view name) const;
90
91 ////////////////////////////////////////////////////////////////////////////
92 /// \brief Add a new booked column.
93 /// Internally it recreates the map with the new column, and swaps it with the old one.
94 void AddColumn(const std::shared_ptr<RDFDetail::RDefineBase> &column, std::string_view name);
95
96 ////////////////////////////////////////////////////////////////////////////
97 /// \brief Add a new name to the list returned by `GetNames` without booking a new column.
98 ///
99 /// This is needed because we abuse fDefinesNames to also keep track of the aliases defined
100 /// in each branch of the computation graph.
101 /// Internally it recreates the vector with the new name, and swaps it with the old one.
103};
104
105} // Namespace RDF
106} // Namespace Internal
107} // Namespace ROOT
108
109#endif
char name[80]
Definition: TGX11.cxx:110
Encapsulates the columns defined by the user.
RBookedDefines & operator=(const RBookedDefines &)=default
Copy-assignment operator for RBookedDefines.
bool HasName(std::string_view name) const
Check if the provided name is tracked in the names list.
std::map< std::string, std::shared_ptr< RDFDetail::RDefineBase > > RDefineBasePtrMap_t
RBookedDefines()
Creates a new wrapper with empty maps.
RBookedDefines(RDefineBasePtrMapPtr_t defines, ColumnNamesPtr_t defineNames)
Creates the object starting from the provided maps.
RBookedDefines(const RBookedDefines &)=default
Copy-ctor for RBookedDefines.
RBookedDefines(RBookedDefines &&)=default
Move-ctor for RBookedDefines.
std::vector< std::string > ColumnNames_t
void AddColumn(const std::shared_ptr< RDFDetail::RDefineBase > &column, std::string_view name)
Add a new booked column.
const RDefineBasePtrMap_t & GetColumns() const
Returns the list of the pointers to the defined columns.
std::shared_ptr< const ColumnNames_t > ColumnNamesPtr_t
ColumnNames_t GetNames() const
Returns the list of the names of the defined columns.
void AddName(std::string_view name)
Add a new name to the list returned by GetNames without booking a new column.
std::shared_ptr< const RDefineBasePtrMap_t > RDefineBasePtrMapPtr_t
basic_string_view< char > string_view
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...