Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:10:51

0001 // Author: Enric Tejedor CERN  07/2020
0002 // Original PyROOT code by Wim Lavrijsen, LBL
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2020, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TPyDispatcher
0013 #define ROOT_TPyDispatcher
0014 
0015 //////////////////////////////////////////////////////////////////////////////
0016 //                                                                          //
0017 // TPyDispatcher                                                            //
0018 //                                                                          //
0019 // Dispatcher for C++ callbacks into Python code.                           //
0020 //                                                                          //
0021 //////////////////////////////////////////////////////////////////////////////
0022 
0023 // ROOT
0024 #include "TObject.h"
0025 
0026 class TDNDData;
0027 class TEveDigitSet;
0028 class TEveElement;
0029 class TEveTrack;
0030 class TEveWindow;
0031 class TGFrame;
0032 class TGListTreeItem;
0033 class TGMdiFrame;
0034 class TGLPhysicalShape;
0035 class TGShutterItem;
0036 class TGLVEntry;
0037 class TGLViewerBase;
0038 class TGVFileSplitter;
0039 class TList;
0040 class TObject;
0041 class TPad;
0042 class TProofProgressInfo;
0043 class TQCommand;
0044 class TSlave;
0045 class TSocket;
0046 class TVirtualPad;
0047 
0048 struct Event_t;
0049 
0050 // Python
0051 struct _object;
0052 typedef _object PyObject;
0053 
0054 class TPyDispatcher : public TObject {
0055 public:
0056    TPyDispatcher(PyObject *callable);
0057    TPyDispatcher(const TPyDispatcher &);
0058    TPyDispatcher &operator=(const TPyDispatcher &);
0059    ~TPyDispatcher();
0060 
0061 public:
0062    PyObject *DispatchVA(const char *format = 0, ...);
0063    PyObject *DispatchVA1(const char *clname, void *obj, const char *format, ...);
0064 
0065    // pre-defined dispatches, same as per TQObject::Emit(); note that
0066    // Emit() maps exclusively to this set, so several builtin types (e.g.
0067    // Int_t, Bool_t, Float_t, etc.) have been omitted here
0068    PyObject *Dispatch() { return DispatchVA(0); }
0069    PyObject *Dispatch(const char *param) { return DispatchVA("s", param); }
0070    PyObject *Dispatch(Double_t param) { return DispatchVA("d", param); }
0071    PyObject *Dispatch(Long_t param) { return DispatchVA("l", param); }
0072    PyObject *Dispatch(Long64_t param) { return DispatchVA("L", param); }
0073 
0074    // further selection of pre-defined, existing dispatches
0075    PyObject *Dispatch(Bool_t param) { return DispatchVA("i", param); }
0076    PyObject *Dispatch(char *param) { return DispatchVA("s", param); }
0077    PyObject *Dispatch(const char *text, Int_t len) { return DispatchVA("si", text, len); }
0078    PyObject *Dispatch(Int_t param) { return DispatchVA("i", param); }
0079    PyObject *Dispatch(Int_t x, Int_t y) { return DispatchVA("ii", x, y); }
0080    PyObject *Dispatch(ULong_t param) { return DispatchVA("k", param); }
0081    // ULong_t also for Handle_t (and Window_t, etc. ... )
0082 
0083    PyObject *Dispatch(Event_t *event) { return DispatchVA1("Event_t", event, 0); }
0084    PyObject *Dispatch(Event_t *event, ULong_t wid) { return DispatchVA1("Event_t", event, "k", wid); }
0085    PyObject *Dispatch(TEveDigitSet *qs, Int_t idx) { return DispatchVA1("TEveDigitSet", qs, "i", idx); }
0086    PyObject *Dispatch(TEveElement *el) { return DispatchVA1("TEveElement", el, 0); }
0087    PyObject *Dispatch(TEveTrack *et) { return DispatchVA1("TEveTrack", et, 0); }
0088    PyObject *Dispatch(TEveWindow *window) { return DispatchVA1("TEveWindow", window, 0); }
0089    PyObject *Dispatch(TGFrame *frame) { return DispatchVA1("TGFrame", frame, 0); }
0090    PyObject *Dispatch(TGFrame *frame, Int_t btn) { return DispatchVA1("TGFrame", frame, "i", btn); }
0091    PyObject *Dispatch(TGFrame *frame, Int_t btn, Int_t x, Int_t y)
0092    {
0093       return DispatchVA1("TGFrame", frame, "iii", btn, x, y);
0094    }
0095    PyObject *Dispatch(TGFrame *frame, UInt_t keysym, UInt_t mask)
0096    {
0097       return DispatchVA1("TGFrame", frame, "II", keysym, mask);
0098    }
0099    PyObject *Dispatch(TGListTreeItem *entry) { return DispatchVA1("TGListTreeItem", entry, 0); }
0100    PyObject *Dispatch(TGListTreeItem *entry, UInt_t mask) { return DispatchVA1("TGListTreeItem", entry, "I", mask); }
0101    PyObject *Dispatch(TGListTreeItem *entry, UInt_t keysym, UInt_t mask)
0102    {
0103       return DispatchVA1("TGListTreeItem", entry, "II", keysym, mask);
0104    }
0105    PyObject *Dispatch(TGListTreeItem *entry, Int_t btn) { return DispatchVA1("TGListTreeItem", entry, "i", btn); }
0106    PyObject *Dispatch(TGListTreeItem *entry, Int_t btn, Int_t x, Int_t y)
0107    {
0108       return DispatchVA1("TGListTreeItem", entry, "iii", btn, x, y);
0109    }
0110    PyObject *Dispatch(TGLVEntry *entry, Int_t btn) { return DispatchVA1("TGLVEntry", entry, "i", btn); }
0111    PyObject *Dispatch(TGLVEntry *entry, Int_t btn, Int_t x, Int_t y)
0112    {
0113       return DispatchVA1("TGLVEntry", entry, "iii", btn, x, y);
0114    }
0115    PyObject *Dispatch(TGLViewerBase *viewer) { return DispatchVA1("TGLViewerBase", viewer, 0); }
0116    PyObject *Dispatch(TGLPhysicalShape *shape) { return DispatchVA1("TGLPhysicalShape", shape, 0); }
0117    PyObject *Dispatch(TGLPhysicalShape *shape, UInt_t u1, UInt_t u2)
0118    {
0119       return DispatchVA1("TGLPhysicalShape", shape, "II", u1, u2);
0120    }
0121    PyObject *Dispatch(TGMdiFrame *frame) { return DispatchVA1("TGMdiFrame", frame, 0); }
0122    PyObject *Dispatch(TGShutterItem *item) { return DispatchVA1("TGShutterItem", item, 0); }
0123    PyObject *Dispatch(TGVFileSplitter *frame) { return DispatchVA1("TGVFileSplitter", frame, 0); }
0124    PyObject *Dispatch(TList *objs) { return DispatchVA1("TList", objs, 0); }
0125    PyObject *Dispatch(TObject *obj) { return DispatchVA1("TObject", obj, 0); }
0126    PyObject *Dispatch(TObject *obj, Bool_t check) { return DispatchVA1("TObject", obj, "i", check); }
0127    PyObject *Dispatch(TObject *obj, UInt_t state) { return DispatchVA1("TObject", obj, "I", state); }
0128    PyObject *Dispatch(TObject *obj, UInt_t button, UInt_t state)
0129    {
0130       return DispatchVA1("TObject", obj, "II", button, state);
0131    }
0132    PyObject *Dispatch(TSocket *sock) { return DispatchVA1("TSocket", sock, 0); }
0133    PyObject *Dispatch(TVirtualPad *pad) { return DispatchVA1("TVirtualPad", pad, 0); }
0134 
0135    PyObject *Dispatch(TPad *selpad, TObject *selected, Int_t event);
0136    PyObject *Dispatch(Int_t event, Int_t x, Int_t y, TObject *selected);
0137    PyObject *Dispatch(TVirtualPad *pad, TObject *obj, Int_t event);
0138    PyObject *Dispatch(TGListTreeItem *item, TDNDData *data);
0139    PyObject *Dispatch(const char *name, const TList *attr);
0140 
0141    // for PROOF
0142    PyObject *Dispatch(const char *msg, Bool_t all) { return DispatchVA("si", msg, all); }
0143    PyObject *Dispatch(Long64_t total, Long64_t processed) { return DispatchVA("LL", total, processed); }
0144    PyObject *Dispatch(Long64_t total, Long64_t processed, Long64_t bytesread, Float_t initTime, Float_t procTime,
0145                       Float_t evtrti, Float_t mbrti)
0146    {
0147       return DispatchVA("LLLffff", total, processed, bytesread, initTime, procTime, evtrti, mbrti);
0148    }
0149    PyObject *Dispatch(Long64_t total, Long64_t processed, Long64_t bytesread, Float_t initTime, Float_t procTime,
0150                       Float_t evtrti, Float_t mbrti, Int_t actw, Int_t tses, Float_t eses)
0151    {
0152       return DispatchVA("LLLffffiif", total, processed, bytesread, initTime, procTime, evtrti, mbrti, actw, tses, eses);
0153    }
0154    PyObject *Dispatch(const char *sel, Int_t sz, Long64_t fst, Long64_t ent)
0155    {
0156       return DispatchVA("siLL", sel, sz, fst, ent);
0157    }
0158    PyObject *Dispatch(const char *msg, Bool_t status, Int_t done, Int_t total)
0159    {
0160       return DispatchVA("siii", msg, status, done, total);
0161    }
0162 
0163    PyObject *Dispatch(TSlave *slave, Long64_t total, Long64_t processed)
0164    {
0165       return DispatchVA1("TSlave", slave, "LL", total, processed);
0166    }
0167    PyObject *Dispatch(TProofProgressInfo *pi) { return DispatchVA1("TProofProgressInfo", pi, 0); }
0168    PyObject *Dispatch(TSlave *slave) { return DispatchVA("TSlave", slave, 0); }
0169    PyObject *Dispatch(TSlave *slave, TProofProgressInfo *pi);
0170 
0171 private:
0172    PyObject *fCallable; //! callable object to be dispatched
0173 };
0174 
0175 #endif