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