Logo ROOT   master
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  Bool_t SingleRnrState() const override { return kTRUE; }
63  Bool_t SetRnrState(Bool_t) override;
64 
65  TClass *GetItemClass() const { return fItemClass; }
66  void SetItemClass(TClass *cls) { fItemClass = cls; }
67 
68  void ReserveItems(Int_t items_size) { fItems.reserve(items_size); }
69  void AddItem(void *data_ptr, const std::string& n, const std::string& t);
70  void ClearItems() { fItems.clear(); }
71 
72  void SetFilterExpr(const TString &filter);
73  void ApplyFilter();
74 
75  Int_t GetNItems() const { return (Int_t)fItems.size(); }
76  void *GetDataPtr(Int_t i) const { return fItems[i].fDataPtr; }
77  REveDataItem *GetDataItem(Int_t i) const { return fItems[i].fItemPtr; }
78 
79  Int_t WriteCoreJson(nlohmann::json &cj, Int_t rnr_offset) override;
80 
81  void SetMainColor(Color_t) override;
82  virtual void ItemChanged(REveDataItem *item);
83 
84  void SetHandlerFunc (std::function<void (REveDataCollection*)> handler_func)
85  {
86  _handler_func = handler_func;
87  }
88  void SetHandlerFuncIds (std::function<void (REveDataCollection*, const Ids_t&)> handler_func)
89  {
90  _handler_func_ids= handler_func;
91  }
92 };
93 
94 //==============================================================================
95 
96 class REveDataItem : public REveElement,
97  public REveAuntAsList
98 {
99 protected:
101 
102 public:
103  REveDataItem(const std::string& n = "REveDataItem", const std::string& t = "");
104  virtual ~REveDataItem() {}
105 
106  Bool_t GetFiltered() const { return fFiltered; }
107  void SetFiltered(Bool_t f);
108 
109  virtual void SetItemColorRGB(UChar_t r, UChar_t g, UChar_t b);
110  Bool_t SetRnrSelf(Bool_t) override;
111 
112  virtual void FillImpliedSelectedSet(Set_t& impSelSet) override;
113 
114  Int_t WriteCoreJson(nlohmann::json &cj, Int_t rnr_offset) override;
115 };
116 
117 //==============================================================================
118 
120 {
121 protected:
123 
124 public:
125  REveDataTable(const std::string& n = "REveDataTable", const std::string& t = "");
126  virtual ~REveDataTable() {}
127 
128  void SetCollection(const REveDataCollection *col) { fCollection = col; }
129  const REveDataCollection *GetCollection() const { return fCollection; }
130 
131  void PrintTable();
132  virtual Int_t WriteCoreJson(nlohmann::json &cj, Int_t rnr_offset);
133 
134  void AddNewColumn(const std::string& expr, const std::string& title, int prec = 2);
135 };
136 
137 //==============================================================================
138 
140 {
141 public:
143 
144 protected:
145 public:
147  FieldType_e fType; // can we auto detect this?
149 
150  std::string fTrue{"*"};
151  std::string fFalse{" "};
152 
153  std::function<double(void *)> fDoubleFoo;
154  std::function<bool(void *)> fBoolFoo;
155  std::function<std::string(void *)> fStringFoo;
156 
157 public:
158  REveDataColumn(const std::string& n = "REveDataColumn", const std::string& t = "");
159  virtual ~REveDataColumn() {}
160 
161  void SetExpressionAndType(const std::string &expr, FieldType_e type);
162  void SetPrecision(Int_t prec);
163 
164  std::string EvalExpr(void *iptr);
165 };
166 
167 
168 } // namespace Experimental
169 } // namespace ROOT
170 
171 #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)
Bool_t SetRnrState(Bool_t) override
Set render state of this element and of its children to the same value.
Bool_t SetRnrSelf(Bool_t) override
Set render state of this element, i.e.
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.
void SetMainColor(Color_t) override
Set main color of the element.
std::function< bool(void *)> fFilterFoo
std::set< REveElement * > Set_t
Definition: REveElement.hxx:89
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)
basic_json<> json
Definition: REveElement.hxx:58
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 Bool_t kTRUE
Definition: RtypesCore.h:87
const Int_t n
Definition: legend1.C:16
void SetFilterExpr(const TString &filter)
void SetHandlerFuncIds(std::function< void(REveDataCollection *, const Ids_t &)> handler_func)