Logo ROOT   6.21/01
Reference Guide
REveDataClasses.hxx
Go to the documentation of this file.
1 // @(#)root/eve7:$Id$
2 // Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007, 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 
13 #ifndef ROOT7_REveDataClasses
14 #define ROOT7_REveDataClasses
15 
16 #include <ROOT/REveElement.hxx>
17 
18 #include <functional>
19 #include <vector>
20 #include <iostream>
21 
22 class TClass;
23 
24 namespace ROOT {
25 namespace Experimental {
26 
27 class REveDataItem;
28 
29 //==============================================================================
30 
32 {
33 public:
34  typedef std::vector<int> Ids_t;
35 
36 private:
37  std::function<void (REveDataCollection*)> _handler_func;
38  std::function<void (REveDataCollection*, const Ids_t&)> _handler_func_ids;
39 
40 public:
42 
43  TClass *fItemClass{nullptr}; // so far only really need class name
44 
45  struct ItemInfo_t
46  {
47  void *fDataPtr{nullptr};
49 
50  ItemInfo_t() = default;
51  ItemInfo_t(void *dp, REveDataItem *di) : fDataPtr(dp), fItemPtr(di) {}
52  };
53 
54  std::vector<ItemInfo_t> fItems;
55 
57  std::function<bool(void *)> fFilterFoo = [](void *) { return true; };
58 
59  REveDataCollection(const std::string& n = "REveDataCollection", const std::string& t = "");
60  virtual ~REveDataCollection() {}
61 
62  TClass *GetItemClass() const { return fItemClass; }
63  void SetItemClass(TClass *cls) { fItemClass = cls; }
64 
65  void ReserveItems(Int_t items_size) { fItems.reserve(items_size); }
66  void AddItem(void *data_ptr, const std::string& n, const std::string& t);
67  void ClearItems() { fItems.clear(); }
68 
69  void SetFilterExpr(const TString &filter);
70  void ApplyFilter();
71 
72  Int_t GetNItems() const { return (Int_t)fItems.size(); }
73  void *GetDataPtr(Int_t i) const { return fItems[i].fDataPtr; }
74  REveDataItem *GetDataItem(Int_t i) const { return fItems[i].fItemPtr; }
75 
76  Int_t WriteCoreJson(nlohmann::json &cj, Int_t rnr_offset) override;
77 
79  virtual void SetCollectionVisible(bool);
80  virtual void ItemChanged(REveDataItem *item);
81 
82  void SetHandlerFunc (std::function<void (REveDataCollection*)> handler_func)
83  {
84  _handler_func = handler_func;
85  }
86  void SetHandlerFuncIds (std::function<void (REveDataCollection*, const Ids_t&)> handler_func)
87  {
88  _handler_func_ids= handler_func;
89  }
90 };
91 
92 //==============================================================================
93 
94 class REveDataItem : public REveElement,
95  public REveAuntAsList
96 {
97 protected:
98  Bool_t fFiltered{false};
99 
100 public:
101  REveDataItem(const std::string& n = "REveDataItem", const std::string& t = "");
102  virtual ~REveDataItem() {}
103 
104  Bool_t GetFiltered() const { return fFiltered; }
105  void SetFiltered(Bool_t f);
106 
107  virtual void SetItemColorRGB(UChar_t r, UChar_t g, UChar_t b);
108  virtual void SetItemRnrSelf(bool);
109 
110  virtual void FillImpliedSelectedSet(Set_t& impSelSet) override;
111 
112  Int_t WriteCoreJson(nlohmann::json &cj, Int_t rnr_offset) override;
113 };
114 
115 //==============================================================================
116 
118 {
119 protected:
121 
122 public:
123  REveDataTable(const std::string& n = "REveDataTable", const std::string& t = "");
124  virtual ~REveDataTable() {}
125 
126  void SetCollection(const REveDataCollection *col) { fCollection = col; }
127  const REveDataCollection *GetCollection() const { return fCollection; }
128 
129  void PrintTable();
130  virtual Int_t WriteCoreJson(nlohmann::json &cj, Int_t rnr_offset);
131 
132  void AddNewColumn(const std::string& expr, const std::string& title, int prec = 2);
133 };
134 
135 //==============================================================================
136 
138 {
139 public:
141 
142 protected:
143 public:
145  FieldType_e fType; // can we auto detect this?
147 
148  std::string fTrue{"*"};
149  std::string fFalse{" "};
150 
151  std::function<double(void *)> fDoubleFoo;
152  std::function<bool(void *)> fBoolFoo;
153  std::function<std::string(void *)> fStringFoo;
154 
155 public:
156  REveDataColumn(const std::string& n = "REveDataColumn", const std::string& t = "");
157  virtual ~REveDataColumn() {}
158 
159  void SetExpressionAndType(const std::string &expr, FieldType_e type);
160  void SetPrecision(Int_t prec);
161 
162  std::string EvalExpr(void *iptr);
163 };
164 
165 
166 } // namespace Experimental
167 } // namespace ROOT
168 
169 #endif
REveDataTable(const std::string &n="REveDataTable", const std::string &t="")
REveDataCollection(const std::string &n="REveDataCollection", const std::string &t="")
void SetCollection(const REveDataCollection *col)
Returns the available number of logical cores.
Definition: StringConv.hxx:21
virtual void FillImpliedSelectedSet(Set_t &impSelSet) override
Populate set impSelSet with derived / dependant elements.
std::function< double(void *)> fDoubleFoo
#define g(i)
Definition: RSha256.hxx:105
void SetHandlerFunc(std::function< void(REveDataCollection *)> handler_func)
const REveDataCollection * GetCollection() const
REveDataItem(const std::string &n="REveDataItem", const std::string &t="")
Basic string class.
Definition: TString.h:131
#define f(i)
Definition: RSha256.hxx:104
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
std::function< void(REveDataCollection *, const Ids_t &)> _handler_func_ids
const REveDataCollection * fCollection
virtual void ItemChanged(REveDataItem *item)
void AddNewColumn(const std::string &expr, const std::string &title, int prec=2)
void function(const Char_t *name_, T fun, const Char_t *docstring=0)
Definition: RExports.h:151
Int_t WriteCoreJson(nlohmann::json &cj, Int_t rnr_offset) override
Write core json.
short Color_t
Definition: RtypesCore.h:79
REveDataItem * GetDataItem(Int_t i) const
REveDataColumn(const std::string &n="REveDataColumn", const std::string &t="")
ROOT::R::TRInterface & r
Definition: Object.C:4
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition: TClass.h:75
std::function< std::string(void *)> fStringFoo
virtual Int_t WriteCoreJson(nlohmann::json &cj, Int_t rnr_offset)
Write core json.
virtual void SetCollectionColorRGB(UChar_t r, UChar_t g, UChar_t b)
std::function< bool(void *)> fFilterFoo
std::set< REveElement * > Set_t
Definition: REveElement.hxx:79
void AddItem(void *data_ptr, const std::string &n, const std::string &t)
int type
Definition: TGX11.cxx:120
std::function< bool(void *)> fBoolFoo
void SetExpressionAndType(const std::string &expr, FieldType_e type)
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630
virtual void SetItemColorRGB(UChar_t r, UChar_t g, UChar_t b)
Int_t WriteCoreJson(nlohmann::json &cj, Int_t rnr_offset) override
Write core json.
unsigned char UChar_t
Definition: RtypesCore.h:34
std::function< void(REveDataCollection *)> _handler_func
const Int_t n
Definition: legend1.C:16
void SetFilterExpr(const TString &filter)
void SetHandlerFuncIds(std::function< void(REveDataCollection *, const Ids_t &)> handler_func)