Logo ROOT  
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
22class TClass;
23
24namespace ROOT {
25namespace Experimental {
26
27class REveDataItem;
28
29//==============================================================================
30
32{
33public:
34 typedef std::vector<int> Ids_t;
35
36private:
39
40public:
42
43 TClass *fItemClass{nullptr}; // so far only really need class name
44
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 = "");
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
97 public REveAuntAsList
98{
99protected:
101
102public:
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{
121protected:
123
124public:
125 REveDataTable(const std::string& n = "REveDataTable", const std::string& t = "");
126 virtual ~REveDataTable() {}
127
128 void SetCollection(const REveDataCollection *col) { fCollection = col; }
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{
141public:
143
144protected:
145public:
147 FieldType_e fType; // can we auto detect this?
149
150 std::string fTrue{"*"};
151 std::string fFalse{" "};
152
155 std::function<std::string(void *)> fStringFoo;
156
157public:
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
double
Definition: Converters.cxx:921
ROOT::R::TRInterface & r
Definition: Object.C:4
#define b(i)
Definition: RSha256.hxx:100
#define f(i)
Definition: RSha256.hxx:104
#define g(i)
Definition: RSha256.hxx:105
int Int_t
Definition: RtypesCore.h:43
unsigned char UChar_t
Definition: RtypesCore.h:36
bool Bool_t
Definition: RtypesCore.h:61
short Color_t
Definition: RtypesCore.h:81
const Bool_t kTRUE
Definition: RtypesCore.h:89
int type
Definition: TGX11.cxx:120
typedef void((*Func_t)())
void SetFilterExpr(const TString &filter)
std::function< void(REveDataCollection *)> _handler_func
REveDataItem * GetDataItem(Int_t i) const
std::function< bool(void *)> fFilterFoo
void SetHandlerFuncIds(std::function< void(REveDataCollection *, const Ids_t &)> handler_func)
virtual void ItemChanged(REveDataItem *item)
void AddItem(void *data_ptr, const std::string &n, const std::string &t)
Bool_t SetRnrState(Bool_t) override
Set render state of this element and of its children to the same value.
void SetMainColor(Color_t) override
Set main color of the element.
void SetHandlerFunc(std::function< void(REveDataCollection *)> handler_func)
Int_t WriteCoreJson(nlohmann::json &cj, Int_t rnr_offset) override
Write core json.
std::function< void(REveDataCollection *, const Ids_t &)> _handler_func_ids
REveDataCollection(const std::string &n="REveDataCollection", const std::string &t="")
std::function< double(void *)> fDoubleFoo
std::function< bool(void *)> fBoolFoo
REveDataColumn(const std::string &n="REveDataColumn", const std::string &t="")
std::function< std::string(void *)> fStringFoo
void SetExpressionAndType(const std::string &expr, FieldType_e type)
virtual void FillImpliedSelectedSet(Set_t &impSelSet) override
Populate set impSelSet with derived / dependant elements.
Bool_t SetRnrSelf(Bool_t) override
Set render state of this element, i.e.
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.
REveDataItem(const std::string &n="REveDataItem", const std::string &t="")
virtual Int_t WriteCoreJson(nlohmann::json &cj, Int_t rnr_offset)
Write core json.
const REveDataCollection * GetCollection() const
REveDataTable(const std::string &n="REveDataTable", const std::string &t="")
const REveDataCollection * fCollection
void AddNewColumn(const std::string &expr, const std::string &title, int prec=2)
void SetCollection(const REveDataCollection *col)
std::set< REveElement * > Set_t
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition: TClass.h:80
Basic string class.
Definition: TString.h:131
const Int_t n
Definition: legend1.C:16
void function(const Char_t *name_, T fun, const Char_t *docstring=0)
Definition: RExports.h:151
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Definition: StringConv.hxx:21
basic_json<> json
default JSON class
Definition: REveElement.hxx:88