Logo ROOT  
Reference Guide
TPyDispatcher.h
Go to the documentation of this file.
1// Author: Enric Tejedor CERN 07/2020
2// Original PyROOT code by Wim Lavrijsen, LBL
3
4/*************************************************************************
5 * Copyright (C) 1995-2020, 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 ROOT_TPyDispatcher
13#define ROOT_TPyDispatcher
14
15//////////////////////////////////////////////////////////////////////////////
16// //
17// TPyDispatcher //
18// //
19// Dispatcher for C++ callbacks into Python code. //
20// //
21//////////////////////////////////////////////////////////////////////////////
22
23// ROOT
24#include "TObject.h"
25
26class TDNDData;
27class TEveDigitSet;
28class TEveElement;
29class TEveTrack;
30class TEveWindow;
31class TGFrame;
32class TGListTreeItem;
33class TGMdiFrame;
35class TGShutterItem;
36class TGLVEntry;
37class TGLViewerBase;
38class TGVFileSplitter;
39class TList;
40class TObject;
41class TPad;
43class TQCommand;
44class TSlave;
45class TSocket;
46class TVirtualPad;
47
48struct Event_t;
49
50// Python
51struct _object;
52typedef _object PyObject;
53
54class TPyDispatcher : public TObject {
55public:
56 TPyDispatcher(PyObject *callable);
60
61public:
62#ifndef __CINT__
63 PyObject *DispatchVA(const char *format = 0, ...);
64#else
65 PyObject *DispatchVA(const char *format, ...);
66#endif
67 PyObject *DispatchVA1(const char *clname, void *obj, const char *format, ...);
68
69 // pre-defined dispatches, same as per TQObject::Emit(); note that
70 // Emit() maps exclusively to this set, so several builtin types (e.g.
71 // Int_t, Bool_t, Float_t, etc.) have been omitted here
72 PyObject *Dispatch() { return DispatchVA(0); }
73 PyObject *Dispatch(const char *param) { return DispatchVA("s", param); }
74 PyObject *Dispatch(Double_t param) { return DispatchVA("d", param); }
75 PyObject *Dispatch(Long_t param) { return DispatchVA("l", param); }
76 PyObject *Dispatch(Long64_t param) { return DispatchVA("L", param); }
77
78 // further selection of pre-defined, existing dispatches
79 PyObject *Dispatch(Bool_t param) { return DispatchVA("i", param); }
80 PyObject *Dispatch(char *param) { return DispatchVA("s", param); }
81 PyObject *Dispatch(const char *text, Int_t len) { return DispatchVA("si", text, len); }
82 PyObject *Dispatch(Int_t param) { return DispatchVA("i", param); }
83 PyObject *Dispatch(Int_t x, Int_t y) { return DispatchVA("ii", x, y); }
84 PyObject *Dispatch(ULong_t param) { return DispatchVA("k", param); }
85 // ULong_t also for Handle_t (and Window_t, etc. ... )
86
87 PyObject *Dispatch(Event_t *event) { return DispatchVA1("Event_t", event, 0); }
88 PyObject *Dispatch(Event_t *event, ULong_t wid) { return DispatchVA1("Event_t", event, "k", wid); }
89 PyObject *Dispatch(TEveDigitSet *qs, Int_t idx) { return DispatchVA1("TEveDigitSet", qs, "i", idx); }
90 PyObject *Dispatch(TEveElement *el) { return DispatchVA1("TEveElement", el, 0); }
91 PyObject *Dispatch(TEveTrack *et) { return DispatchVA1("TEveTrack", et, 0); }
92 PyObject *Dispatch(TEveWindow *window) { return DispatchVA1("TEveWindow", window, 0); }
93 PyObject *Dispatch(TGFrame *frame) { return DispatchVA1("TGFrame", frame, 0); }
94 PyObject *Dispatch(TGFrame *frame, Int_t btn) { return DispatchVA1("TGFrame", frame, "i", btn); }
96 {
97 return DispatchVA1("TGFrame", frame, "iii", btn, x, y);
98 }
99 PyObject *Dispatch(TGFrame *frame, UInt_t keysym, UInt_t mask)
100 {
101 return DispatchVA1("TGFrame", frame, "II", keysym, mask);
102 }
103 PyObject *Dispatch(TGListTreeItem *entry) { return DispatchVA1("TGListTreeItem", entry, 0); }
104 PyObject *Dispatch(TGListTreeItem *entry, UInt_t mask) { return DispatchVA1("TGListTreeItem", entry, "I", mask); }
106 {
107 return DispatchVA1("TGListTreeItem", entry, "II", keysym, mask);
108 }
109 PyObject *Dispatch(TGListTreeItem *entry, Int_t btn) { return DispatchVA1("TGListTreeItem", entry, "i", btn); }
111 {
112 return DispatchVA1("TGListTreeItem", entry, "iii", btn, x, y);
113 }
114 PyObject *Dispatch(TGLVEntry *entry, Int_t btn) { return DispatchVA1("TGLVEntry", entry, "i", btn); }
116 {
117 return DispatchVA1("TGLVEntry", entry, "iii", btn, x, y);
118 }
119 PyObject *Dispatch(TGLViewerBase *viewer) { return DispatchVA1("TGLViewerBase", viewer, 0); }
120 PyObject *Dispatch(TGLPhysicalShape *shape) { return DispatchVA1("TGLPhysicalShape", shape, 0); }
122 {
123 return DispatchVA1("TGLPhysicalShape", shape, "II", u1, u2);
124 }
125 PyObject *Dispatch(TGMdiFrame *frame) { return DispatchVA1("TGMdiFrame", frame, 0); }
126 PyObject *Dispatch(TGShutterItem *item) { return DispatchVA1("TGShutterItem", item, 0); }
127 PyObject *Dispatch(TGVFileSplitter *frame) { return DispatchVA1("TGVFileSplitter", frame, 0); }
128 PyObject *Dispatch(TList *objs) { return DispatchVA1("TList", objs, 0); }
129 PyObject *Dispatch(TObject *obj) { return DispatchVA1("TObject", obj, 0); }
130 PyObject *Dispatch(TObject *obj, Bool_t check) { return DispatchVA1("TObject", obj, "i", check); }
131 PyObject *Dispatch(TObject *obj, UInt_t state) { return DispatchVA1("TObject", obj, "I", state); }
132 PyObject *Dispatch(TObject *obj, UInt_t button, UInt_t state)
133 {
134 return DispatchVA1("TObject", obj, "II", button, state);
135 }
136 PyObject *Dispatch(TSocket *sock) { return DispatchVA1("TSocket", sock, 0); }
137 PyObject *Dispatch(TVirtualPad *pad) { return DispatchVA1("TVirtualPad", pad, 0); }
138
139 PyObject *Dispatch(TPad *selpad, TObject *selected, Int_t event);
140 PyObject *Dispatch(Int_t event, Int_t x, Int_t y, TObject *selected);
141 PyObject *Dispatch(TVirtualPad *pad, TObject *obj, Int_t event);
143 PyObject *Dispatch(const char *name, const TList *attr);
144
145 // for PROOF
146 PyObject *Dispatch(const char *msg, Bool_t all) { return DispatchVA("si", msg, all); }
147 PyObject *Dispatch(Long64_t total, Long64_t processed) { return DispatchVA("LL", total, processed); }
148 PyObject *Dispatch(Long64_t total, Long64_t processed, Long64_t bytesread, Float_t initTime, Float_t procTime,
149 Float_t evtrti, Float_t mbrti)
150 {
151 return DispatchVA("LLLffff", total, processed, bytesread, initTime, procTime, evtrti, mbrti);
152 }
153 PyObject *Dispatch(Long64_t total, Long64_t processed, Long64_t bytesread, Float_t initTime, Float_t procTime,
154 Float_t evtrti, Float_t mbrti, Int_t actw, Int_t tses, Float_t eses)
155 {
156 return DispatchVA("LLLffffiif", total, processed, bytesread, initTime, procTime, evtrti, mbrti, actw, tses, eses);
157 }
158 PyObject *Dispatch(const char *sel, Int_t sz, Long64_t fst, Long64_t ent)
159 {
160 return DispatchVA("siLL", sel, sz, fst, ent);
161 }
162 PyObject *Dispatch(const char *msg, Bool_t status, Int_t done, Int_t total)
163 {
164 return DispatchVA("siii", msg, status, done, total);
165 }
166
168 {
169 return DispatchVA1("TSlave", slave, "LL", total, processed);
170 }
171 PyObject *Dispatch(TProofProgressInfo *pi) { return DispatchVA1("TProofProgressInfo", pi, 0); }
172 PyObject *Dispatch(TSlave *slave) { return DispatchVA("TSlave", slave, 0); }
174
175private:
176 PyObject *fCallable; //! callable object to be dispatched
177};
178
179#endif
_object PyObject
Definition: PyMethodBase.h:41
int Int_t
Definition: RtypesCore.h:43
unsigned long ULong_t
Definition: RtypesCore.h:53
long Long_t
Definition: RtypesCore.h:52
double Double_t
Definition: RtypesCore.h:57
long long Long64_t
Definition: RtypesCore.h:71
float Float_t
Definition: RtypesCore.h:55
static unsigned int total
char name[80]
Definition: TGX11.cxx:109
_object PyObject
Definition: TPyDispatcher.h:51
Base-class for storage of digit collections; provides transformation matrix (TEveTrans),...
Definition: TEveDigitSet.h:34
Base class for TEveUtil visualization elements, providing hierarchy management, rendering control and...
Definition: TEveElement.h:34
Visual representation of a track.
Definition: TEveTrack.h:33
Abstract base-class for representing eve-windows.
Definition: TEveWindow.h:210
Concrete physical shape - a GL drawable.
Base class for GL viewers.
Definition: TGLViewerBase.h:37
A doubly linked list.
Definition: TList.h:44
Mother of all ROOT objects.
Definition: TObject.h:37
The most important graphics class in the ROOT system.
Definition: TPad.h:29
PyObject * Dispatch(TGMdiFrame *frame)
PyObject * Dispatch(TGLPhysicalShape *shape, UInt_t u1, UInt_t u2)
PyObject * Dispatch(TEveElement *el)
Definition: TPyDispatcher.h:90
PyObject * Dispatch(TSlave *slave, Long64_t total, Long64_t processed)
PyObject * Dispatch(TGListTreeItem *entry, Int_t btn)
TPyDispatcher & operator=(const TPyDispatcher &)
Assignment operator. Applies python object reference counting.
PyObject * Dispatch(TGFrame *frame, UInt_t keysym, UInt_t mask)
Definition: TPyDispatcher.h:99
PyObject * DispatchVA1(const char *clname, void *obj, const char *format,...)
PyObject * Dispatch(TGLVEntry *entry, Int_t btn, Int_t x, Int_t y)
PyObject * Dispatch(TGFrame *frame)
Definition: TPyDispatcher.h:93
PyObject * Dispatch(TGShutterItem *item)
PyObject * Dispatch(Long_t param)
Definition: TPyDispatcher.h:75
PyObject * Dispatch(TProofProgressInfo *pi)
PyObject * Dispatch(const char *text, Int_t len)
Definition: TPyDispatcher.h:81
~TPyDispatcher()
Destructor. Reference counting for the held python object is in effect.
PyObject * Dispatch(const char *msg, Bool_t all)
PyObject * Dispatch(TGLViewerBase *viewer)
PyObject * Dispatch(TGListTreeItem *entry, UInt_t keysym, UInt_t mask)
PyObject * Dispatch(TGLPhysicalShape *shape)
PyObject * Dispatch(Long64_t total, Long64_t processed, Long64_t bytesread, Float_t initTime, Float_t procTime, Float_t evtrti, Float_t mbrti)
PyObject * Dispatch(Int_t param)
Definition: TPyDispatcher.h:82
PyObject * Dispatch(TList *objs)
PyObject * Dispatch(const char *param)
Definition: TPyDispatcher.h:73
PyObject * Dispatch(Bool_t param)
Definition: TPyDispatcher.h:79
PyObject * Dispatch(Int_t x, Int_t y)
Definition: TPyDispatcher.h:83
TPyDispatcher(PyObject *callable)
PyObject * Dispatch(TGVFileSplitter *frame)
PyObject * Dispatch(ULong_t param)
Definition: TPyDispatcher.h:84
PyObject * Dispatch(const char *sel, Int_t sz, Long64_t fst, Long64_t ent)
PyObject * Dispatch(TObject *obj, UInt_t state)
PyObject * Dispatch(char *param)
Definition: TPyDispatcher.h:80
PyObject * Dispatch(Long64_t total, Long64_t processed, Long64_t bytesread, Float_t initTime, Float_t procTime, Float_t evtrti, Float_t mbrti, Int_t actw, Int_t tses, Float_t eses)
PyObject * Dispatch(TObject *obj, UInt_t button, UInt_t state)
PyObject * Dispatch(TGFrame *frame, Int_t btn, Int_t x, Int_t y)
Definition: TPyDispatcher.h:95
PyObject * Dispatch(TObject *obj, Bool_t check)
PyObject * Dispatch()
Definition: TPyDispatcher.h:72
PyObject * Dispatch(TGListTreeItem *entry)
PyObject * Dispatch(Double_t param)
Definition: TPyDispatcher.h:74
PyObject * Dispatch(Long64_t param)
Definition: TPyDispatcher.h:76
PyObject * Dispatch(TGLVEntry *entry, Int_t btn)
PyObject * Dispatch(TSlave *slave)
PyObject * Dispatch(TObject *obj)
PyObject * Dispatch(const char *msg, Bool_t status, Int_t done, Int_t total)
PyObject * Dispatch(Event_t *event)
Definition: TPyDispatcher.h:87
PyObject * Dispatch(TEveTrack *et)
Definition: TPyDispatcher.h:91
PyObject * Dispatch(TEveDigitSet *qs, Int_t idx)
Definition: TPyDispatcher.h:89
PyObject * Dispatch(TGListTreeItem *entry, UInt_t mask)
PyObject * Dispatch(TGListTreeItem *entry, Int_t btn, Int_t x, Int_t y)
PyObject * Dispatch(Event_t *event, ULong_t wid)
Definition: TPyDispatcher.h:88
PyObject * Dispatch(Long64_t total, Long64_t processed)
PyObject * Dispatch(TGFrame *frame, Int_t btn)
Definition: TPyDispatcher.h:94
PyObject * Dispatch(TEveWindow *window)
Definition: TPyDispatcher.h:92
PyObject * fCallable
PyObject * Dispatch(TVirtualPad *pad)
PyObject * Dispatch(TSocket *sock)
PyObject * DispatchVA(const char *format=0,...)
The Command design pattern is based on the idea, that all editing in an application is done by creati...
Definition: TQCommand.h:27
Class describing a PROOF worker server.
Definition: TSlave.h:46
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition: TVirtualPad.h:51
TText * text
Double_t y[n]
Definition: legend1.C:17
Double_t x[n]
Definition: legend1.C:17
static constexpr double pi