Logo ROOT   6.21/01
Reference Guide
RBookedCustomColumns.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 
21 namespace ROOT {
22 namespace Detail {
23 namespace RDF {
24 class RCustomColumnBase;
25 }
26 }
27 
28 namespace Internal {
29 namespace RDF {
30 
31 namespace RDFDetail = ROOT::Detail::RDF;
32 
33 /**
34  * \class ROOT::Internal::RDF::RBookedCustomColumns
35  * \ingroup dataframe
36  * \brief Encapsulates the columns defined by the user
37  */
38 
40  using RCustomColumnBasePtrMap_t = std::map<std::string, std::shared_ptr<RDFDetail::RCustomColumnBase>>;
41  using ColumnNames_t = std::vector<std::string>;
42 
43  // Since RBookedCustomColumns is meant to be an immutable, copy-on-write object, the actual values are set as const
44  using RCustomColumnBasePtrMapPtr_t = std::shared_ptr<const RCustomColumnBasePtrMap_t>;
45  using ColumnNamesPtr_t = std::shared_ptr<const ColumnNames_t>;
46 
47 private:
50 
51 public:
52  ////////////////////////////////////////////////////////////////////////////
53  /// \brief Copy-ctor for RBookedCustomColumns.
54  RBookedCustomColumns(const RBookedCustomColumns &) = default;
55 
56  ////////////////////////////////////////////////////////////////////////////
57  /// \brief Move-ctor for RBookedCustomColumns.
59 
60  ////////////////////////////////////////////////////////////////////////////
61  /// \brief Copy-assignment operator for RBookedCustomColumns.
63 
64  ////////////////////////////////////////////////////////////////////////////
65  /// \brief Creates the object starting from the provided maps
67  : fCustomColumns(customColumns), fCustomColumnsNames(customColumnNames)
68  {
69  }
70 
71  ////////////////////////////////////////////////////////////////////////////
72  /// \brief Creates a new wrapper with empty maps
74  : fCustomColumns(std::make_shared<RCustomColumnBasePtrMap_t>()),
75  fCustomColumnsNames(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
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 Internally it recreates the map with the new column, and swaps with the old one.
93  void AddColumn(const std::shared_ptr<RDFDetail::RCustomColumnBase> &column, std::string_view name);
94 
95  ////////////////////////////////////////////////////////////////////////////
96  /// \brief Internally it recreates the map with the new column name, and swaps with the old one.
97  void AddName(std::string_view name);
98 };
99 
100 } // Namespace RDF
101 } // Namespace Internal
102 } // Namespace ROOT
103 
104 #endif
void AddName(std::string_view name)
Internally it recreates the map with the new column name, and swaps with the old one.
Returns the available number of logical cores.
Definition: StringConv.hxx:21
void AddColumn(const std::shared_ptr< RDFDetail::RCustomColumnBase > &column, std::string_view name)
Internally it recreates the map with the new column, and swaps with the old one.
std::map< std::string, std::shared_ptr< RDFDetail::RCustomColumnBase > > RCustomColumnBasePtrMap_t
std::shared_ptr< const ColumnNames_t > ColumnNamesPtr_t
STL namespace.
RBookedCustomColumns()
Creates a new wrapper with empty maps.
RBookedCustomColumns & operator=(const RBookedCustomColumns &)=default
Copy-assignment operator for RBookedCustomColumns.
std::shared_ptr< const RCustomColumnBasePtrMap_t > RCustomColumnBasePtrMapPtr_t
const RCustomColumnBasePtrMap_t & GetColumns() const
Returns the list of the pointers to the defined columns.
bool HasName(std::string_view name) const
Check if the provided name is tracked in the names list.
RBookedCustomColumns(RCustomColumnBasePtrMapPtr_t customColumns, ColumnNamesPtr_t customColumnNames)
Creates the object starting from the provided maps.
Encapsulates the columns defined by the user.
ColumnNames_t GetNames() const
Returns the list of the names of the defined columns.
char name[80]
Definition: TGX11.cxx:109