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 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
95 public REveAuntAsList
96{
97protected:
99
100public:
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{
119protected:
121
122public:
123 REveDataTable(const std::string& n = "REveDataTable", const std::string& t = "");
124 virtual ~REveDataTable() {}
125
126 void SetCollection(const REveDataCollection *col) { fCollection = col; }
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{
139public:
141
142protected:
143public:
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
155public:
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
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:41
unsigned char UChar_t
Definition: RtypesCore.h:34
bool Bool_t
Definition: RtypesCore.h:59
short Color_t
Definition: RtypesCore.h:79
int type
Definition: TGX11.cxx:120
typedef void((*Func_t)())
virtual void SetCollectionColorRGB(UChar_t r, UChar_t g, UChar_t b)
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)
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.
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
Definition: REveElement.hxx:79
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition: TClass.h:75
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
VSD Structures.
Definition: StringConv.hxx:21