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 dataset metadata
36
37 This class should be passed to an RSample object which represents a single dataset sample.
38 Once a dataframe is built with RMetaData object, it could be accessed via DefinePerSample.
39*/
40class RMetaData {
41public:
42
43 RMetaData();
44 // Note: each RMetaData instance should own its own fJson object, just as if
45 // the underlying nlohmann::json object would be owned by value.
46 RMetaData(RMetaData const&);
51
52 void Add(const std::string &key, int val);
53 void Add(const std::string &key, double val);
54 void Add(const std::string &key, const std::string &val);
55
56 std::string Dump(const std::string &key) const; // always returns a string
57 int GetI(const std::string &key) const;
58 double GetD(const std::string &key) const;
59 std::string GetS(const std::string &key) const;
60 int GetI(const std::string &key, int defaultVal) const;
61 double GetD(const std::string &key, double defaultVal) const;
62 const std::string GetS(const std::string &key, const std::string &defaultVal) const;
63
64private:
65 std::unique_ptr<Internal::RDF::RMetaDataJson> fJson;
66};
67
68} // namespace Experimental
69} // namespace RDF
70} // namespace ROOT
71
72#endif // ROOT_RDF_RMETADATA
Class behaving as a heterogenuous dictionary to store dataset metadata.
Definition RMetaData.hxx:40
std::string Dump(const std::string &key) const
Definition RMetaData.cxx:54
std::unique_ptr< Internal::RDF::RMetaDataJson > fJson
Definition RMetaData.hxx:65
std::string GetS(const std::string &key) const
Definition RMetaData.cxx:77
void Add(const std::string &key, int val)
Definition RMetaData.cxx:39
double GetD(const std::string &key) const
Definition RMetaData.cxx:68
int GetI(const std::string &key) const
Definition RMetaData.cxx:59
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.