Logo ROOT  
Reference Guide
 
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 {
18
19namespace Internal {
20namespace RDF {
21// To avoid unnecessary dependence on nlohman json in the interface. Note that
22// we should not forward declare nlohmann::json directly, since its declaration
23// might change (it is currently a typedef). With this wrapper type, we are
24// completely decoupled on nlohmann::json in the RMetaData interface.
25struct RMetaDataJson;
26}
27}
28
29namespace RDF {
30namespace Experimental {
31
32/**
33\class ROOT::RDF::Experimental::RMetaData
34\ingroup dataframe
35\brief Class behaving as a heterogenuous dictionary to store the metadata of a dataset.
36
37 The supported types of the metadata are: std::string, int and double. An example of creating the RMetaData object:
38 ~~~{.cpp}
39 ROOT::RDF::Experimental::RMetaData meta;
40 meta.Add("sample_name", "name"");
41 meta.Add("luminosity", 10064);
42 meta.Add("xsecs", 1.0);
43 ~~~
44
45 The RMetaData object is passed to an RSample object which represents a single dataset sample.
46
47 A dataframe built with the RMetaData object can be accessed with the \ref ROOT::RDF::RInterface< Proxied,
48DS_t>::DefinePerSample "DefinePerSample()" method.
49**/
50class RMetaData {
51public:
52
53 RMetaData();
54 // Note: each RMetaData instance should own its own fJson object, just as if
55 // the underlying nlohmann::json object would be owned by value.
56 RMetaData(RMetaData const&);
61
62 void Add(const std::string &key, int val);
63 void Add(const std::string &key, double val);
64 void Add(const std::string &key, const std::string &val);
65
66 std::string Dump(const std::string &key) const; // always returns a string
67 int GetI(const std::string &key) const;
68 double GetD(const std::string &key) const;
69 std::string GetS(const std::string &key) const;
70 int GetI(const std::string &key, int defaultVal) const;
71 double GetD(const std::string &key, double defaultVal) const;
72 const std::string GetS(const std::string &key, const std::string &defaultVal) const;
73
74private:
75 std::unique_ptr<Internal::RDF::RMetaDataJson> fJson;
76};
77
78} // namespace Experimental
79} // namespace RDF
80} // namespace ROOT
81
82#endif // ROOT_RDF_RMETADATA
Class behaving as a heterogenuous dictionary to store the metadata of a dataset.
Definition RMetaData.hxx:50
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:75
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 &&)
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.