Logo ROOT  
Reference Guide
REveTableInfo.hxx
Go to the documentation of this file.
1 // @(#)root/eve7:$Id$
2 // Authors: Matevz Tadel & Alja Mrak-Tadel: 2018
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT7_REveTableInfo
13 #define ROOT7_REveTableInfo
14 
15 #include <ROOT/REveElement.hxx>
16 #include <ROOT/REveDataClasses.hxx>
17 
18 namespace ROOT {
19 namespace Experimental {
20 
21 ///////////////////////////////////////////////////////////////////////////////
22 /// REveTableEntry
23 ///////////////////////////////////////////////////////////////////////////////
24 
25 class REveTableEntry {
26 public:
27  std::string fName;
28  int fPrecision;
29  std::string fExpression;
31 
32  REveTableEntry() : fName("unknown"), fPrecision(2), fType(REveDataColumn::FT_Double) {}
33 
34  REveTableEntry(const std::string &name, int precision, const std::string &expression)
35  : fName(name), fPrecision(precision), fExpression(expression), fType(REveDataColumn::FT_Double)
36  {
37  }
38 
39  void Print() const
40  {
41  printf("TableEntry\n");
42  printf("name: %s expression: %s\n", fName.c_str(), fExpression.c_str());
43  }
44 };
45 
46 ///////////////////////////////////////////////////////////////////////////////
47 /// REveTableHandle
48 ///////////////////////////////////////////////////////////////////////////////
49 
51 {
52  friend class REveTableViewInfo;
53 
54 public:
55  typedef std::vector<REveTableEntry> Entries_t;
56  typedef std::map<std::string, Entries_t> Specs_t;
57 
58  // REveTableHandle() {}
59 
61  column(const std::string &name, int precision, const std::string &expression)
62  {
63  fSpecs[fClassName].emplace_back(name, precision, expression);
64  return *this;
65  }
66 
67  REveTableHandle &column(const std::string &label, int precision)
68  {
69  return column(label, precision, label);
70  }
71 
72  REveTableHandle(std::string className, Specs_t &specs)
73  :fClassName(className), fSpecs(specs)
74  {
75  }
76 
77 protected:
78  std::string fClassName;
80 };
81 
82 ///////////////////////////////////////////////////////////////////////////////
83 /// REveTableViewInfo
84 ///////////////////////////////////////////////////////////////////////////////
85 
86 class REveTableViewInfo : public REveElement
87 {
88 public:
89  REveTableViewInfo(const std::string &name = "TableViewManager", const std::string &title = "");
90 
92 
95 
96  void AddNewColumnToCurrentCollection(const std::string& expr, const std::string& title, int prec = 2);
97 
98  void AddDelegate(Delegate_t d) { fDelegates.push_back(d); }
99 
100  Int_t WriteCoreJson(nlohmann::json &j, Int_t rnr_offset) override;
101 
102  // read
104 
105  // filling
106  REveTableHandle table(std::string className)
107  {
108  REveTableHandle handle(className, fSpecs);
109  return handle;
110  }
111 
112  bool GetConfigChanged() const { return fConfigChanged; }
113 
114 
115 private:
116  int fDisplayedCollection{0};
117  std::vector<Delegate_t> fDelegates;
119  bool fConfigChanged{false};
120 };
121 
122 
123 }
124 }
125 
126 #endif
ROOT::Experimental::REveTableViewInfo::AddDelegate
void AddDelegate(Delegate_t d)
Definition: REveTableInfo.hxx:110
nlohmann::json
basic_json<> json
Definition: REveElement.hxx:58
ROOT::Experimental::REveTableViewInfo::Delegate_t
std::function< void()> Delegate_t
Definition: REveTableInfo.hxx:103
Int_t
int Int_t
Definition: RtypesCore.h:45
ROOT::Experimental::REveTableViewInfo::SetDisplayedCollection
void SetDisplayedCollection(ElementId_t)
Definition: REveTableInfo.cxx:33
ROOT::Experimental::REveTableHandle::fSpecs
Specs_t & fSpecs
Definition: REveTableInfo.hxx:91
ROOT::Experimental::REveTableViewInfo::AddNewColumnToCurrentCollection
void AddNewColumnToCurrentCollection(const std::string &expr, const std::string &title, int prec=2)
Definition: REveTableInfo.cxx:45
ROOT::Experimental::REveElement
Definition: REveElement.hxx:79
ROOT::Experimental::REveDataColumn::FieldType_e
FieldType_e
Definition: REveDataClasses.hxx:142
ROOT::Experimental::REveTableHandle::Specs_t
std::map< std::string, Entries_t > Specs_t
Definition: REveTableInfo.hxx:68
ROOT::Experimental::REveTableViewInfo::WriteCoreJson
Int_t WriteCoreJson(nlohmann::json &j, Int_t rnr_offset) override
Fill core part of JSON representation.
Definition: REveTableInfo.cxx:157
ROOT::Experimental::REveTableViewInfo::fConfigChanged
bool fConfigChanged
Definition: REveTableInfo.hxx:131
ROOT::Experimental::REveTableHandle::REveTableHandle
REveTableHandle(std::string className, Specs_t &specs)
Definition: REveTableInfo.hxx:84
ROOT::Experimental::REveTableViewInfo::fDisplayedCollection
int fDisplayedCollection
Definition: REveTableInfo.hxx:128
ROOT::Experimental::REveTableViewInfo::RefTableEntries
REveTableHandle::Entries_t & RefTableEntries(std::string cname)
Find column definitions for given class name.
Definition: REveTableInfo.cxx:86
REveElement.hxx
REveDataClasses.hxx
ROOT::Experimental::REveTableEntry::fPrecision
int fPrecision
Definition: REveTableInfo.hxx:46
ROOT::R::function
void function(const Char_t *name_, T fun, const Char_t *docstring=0)
Definition: RExports.h:151
ROOT::Experimental::REveTableHandle
REveTableHandle.
Definition: REveTableInfo.hxx:62
ROOT::Experimental::REveTableEntry::REveTableEntry
REveTableEntry()
Definition: REveTableInfo.hxx:50
ROOT::Experimental::REveTableHandle::fClassName
std::string fClassName
Definition: REveTableInfo.hxx:90
ROOT::Experimental::REveTableViewInfo::fDelegates
std::vector< Delegate_t > fDelegates
Definition: REveTableInfo.hxx:129
void
typedef void((*Func_t)())
unsigned int
ROOT::Experimental::REveTableViewInfo
REveTableViewInfo.
Definition: REveTableInfo.hxx:98
ROOT::Experimental::REveTableViewInfo::fSpecs
REveTableHandle::Specs_t fSpecs
Definition: REveTableInfo.hxx:130
ROOT::Experimental::REveTableEntry::fName
std::string fName
Definition: REveTableInfo.hxx:45
ROOT::Experimental::REveTableViewInfo::REveTableViewInfo
REveTableViewInfo(const std::string &name="TableViewManager", const std::string &title="")
Definition: REveTableInfo.cxx:29
ROOT::Experimental::REveTableHandle::Entries_t
std::vector< REveTableEntry > Entries_t
Definition: REveTableInfo.hxx:67
ROOT::Experimental::REveTableHandle::column
REveTableHandle & column(const std::string &name, int precision, const std::string &expression)
Definition: REveTableInfo.hxx:73
name
char name[80]
Definition: TGX11.cxx:110
ROOT::Experimental::REveTableViewInfo::GetDisplayedCollection
ElementId_t GetDisplayedCollection() const
Definition: REveTableInfo.hxx:106
ROOT::Experimental::REveTableEntry::Print
void Print() const
Definition: REveTableInfo.hxx:57
d
#define d(i)
Definition: RSha256.hxx:120
ROOT::Experimental::REveTableViewInfo::table
REveTableHandle table(std::string className)
Definition: REveTableInfo.hxx:118
ROOT::Experimental::REveTableViewInfo::GetConfigChanged
bool GetConfigChanged() const
Definition: REveTableInfo.hxx:124
ROOT
VSD Structures.
Definition: StringConv.hxx:21
ROOT::Experimental::REveTableEntry::fExpression
std::string fExpression
Definition: REveTableInfo.hxx:47
ROOT::Experimental::REveTableEntry::fType
REveDataColumn::FieldType_e fType
Definition: REveTableInfo.hxx:48