Logo ROOT  
Reference Guide
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Loading...
Searching...
No Matches
RMetaData.hxx
Go to the documentation of this file.
1// Author: Ivan Kabadzhov CERN 10/2022
2
3/*************************************************************************
4 * Copyright (C) 1995-2022, 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_RMETADATA
12#define ROOT_RDF_RMETADATA
13
14#include <string>
15#include <memory>
16
17namespace ROOT {
18namespace RDF {
19namespace Experimental {
20class RMetaData;
21}
22} // namespace RDF
23
24namespace Internal {
25namespace RDF {
26// To avoid unnecessary dependence on nlohman json in the interface. Note that
27// we should not forward declare nlohmann::json directly, since its declaration
28// might change (it is currently a typedef). With this wrapper type, we are
29// completely decoupled on nlohmann::json in the RMetaData interface.
30void ImportJSON(ROOT::RDF::Experimental::RMetaData &metadata, const std::string &jsonString);
32struct RMetaDataJson;
33}
34}
35
36namespace RDF {
37namespace Experimental {
38
39/**
40\class ROOT::RDF::Experimental::RMetaData
41\ingroup dataframe
42\brief Class behaving as a heterogenuous dictionary to store the metadata of a dataset.
43
44 The supported types of the metadata are: std::string, int and double. An example of creating the RMetaData object:
45 ~~~{.cpp}
46 ROOT::RDF::Experimental::RMetaData meta;
47 meta.Add("sample_name", "name"");
48 meta.Add("luminosity", 10064);
49 meta.Add("xsecs", 1.0);
50 ~~~
51
52 The RMetaData object is passed to an RSample object which represents a single dataset sample.
53
54 A dataframe built with the RMetaData object can be accessed with the \ref ROOT::RDF::RInterface< Proxied,
55DS_t>::DefinePerSample "DefinePerSample()" method.
56**/
57class RMetaData {
60
61public:
62
63 RMetaData();
64 // Note: each RMetaData instance should own its own fJson object, just as if
65 // the underlying nlohmann::json object would be owned by value.
66 RMetaData(RMetaData const&);
71
72 void Add(const std::string &key, int val);
73 void Add(const std::string &key, double val);
74 void Add(const std::string &key, const std::string &val);
75
76 std::string Dump(const std::string &key) const; // always returns a string
77 int GetI(const std::string &key) const;
78 double GetD(const std::string &key) const;
79 std::string GetS(const std::string &key) const;
80 int GetI(const std::string &key, int defaultVal) const;
81 double GetD(const std::string &key, double defaultVal) const;
82 const std::string GetS(const std::string &key, const std::string &defaultVal) const;
83
84private:
85 std::unique_ptr<Internal::RDF::RMetaDataJson> fJson;
86};
87
88} // namespace Experimental
89} // namespace RDF
90} // namespace ROOT
91
92#endif // ROOT_RDF_RMETADATA
Class behaving as a heterogenuous dictionary to store the metadata of a dataset.
Definition RMetaData.hxx:57
std::string Dump(const std::string &key) const
Dump the value of the metadata value given the key.
Definition RMetaData.cxx:67
std::unique_ptr< Internal::RDF::RMetaDataJson > fJson
Definition RMetaData.hxx:85
std::string GetS(const std::string &key) const
Return the metadata value of type string given the key, or an error if the metadata value is of a non...
Definition RMetaData.cxx:96
void Add(const std::string &key, int val)
Add an RMetaData class instance.
Definition RMetaData.cxx:42
double GetD(const std::string &key) const
Return the metadata value of type double given the key, or an error if the metadata value is of a non...
Definition RMetaData.cxx:84
int GetI(const std::string &key) const
Return the metadata value of type int given the key, or an error if the metadata value is of a non-in...
Definition RMetaData.cxx:73
RMetaData & operator=(RMetaData const &)
Definition RMetaData.cxx:29
RMetaData & operator=(RMetaData &&)
void ImportJSON(ROOT::RDF::Experimental::RMetaData &metadata, const std::string &jsonString)
std::string ExportJSON(ROOT::RDF::Experimental::RMetaData &metadata)
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...