Logo ROOT   6.21/01
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 
26 public:
27  std::string fName;
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 
87 {
88 public:
89  REveTableViewInfo(const std::string &name = "TableViewManager", const std::string &title = "");
90 
91  typedef std::function<void ()> Delegate_t;
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
103  REveTableHandle::Entries_t &RefTableEntries(std::string cname);
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:
117  std::vector<Delegate_t> fDelegates;
119  bool fConfigChanged{false};
120 };
121 
122 
123 }
124 }
125 
126 #endif
REveTableHandle & column(const std::string &label, int precision)
Returns the available number of logical cores.
Definition: StringConv.hxx:21
REveTableEntry(const std::string &name, int precision, const std::string &expression)
void AddNewColumnToCurrentCollection(const std::string &expr, const std::string &title, int prec=2)
std::map< std::string, Entries_t > Specs_t
Int_t WriteCoreJson(nlohmann::json &j, Int_t rnr_offset) override
Fill core part of JSON representation.
int Int_t
Definition: RtypesCore.h:41
REveTableHandle::Entries_t & RefTableEntries(std::string cname)
Find column definitions for given class name.
std::vector< Delegate_t > fDelegates
ElementId_t GetDisplayedCollection() const
std::vector< REveTableEntry > Entries_t
REveTableHandle & column(const std::string &name, int precision, const std::string &expression)
REveTableViewInfo(const std::string &name="TableViewManager", const std::string &title="")
unsigned int ElementId_t
Definition: REveTypes.hxx:25
#define d(i)
Definition: RSha256.hxx:102
REveTableHandle(std::string className, Specs_t &specs)
REveDataColumn::FieldType_e fType
REveTableHandle table(std::string className)
char name[80]
Definition: TGX11.cxx:109