Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/ROOT/TPyDispatcher.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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 // ROOT
0016 #include "TObject.h"
0017 
0018 class TDNDData;
0019 class TEveDigitSet;
0020 class TEveElement;
0021 class TEveTrack;
0022 class TEveWindow;
0023 class TGFrame;
0024 class TGListTreeItem;
0025 class TGMdiFrame;
0026 class TGLPhysicalShape;
0027 class TGShutterItem;
0028 class TGLVEntry;
0029 class TGLViewerBase;
0030 class TGVFileSplitter;
0031 class TList;
0032 class TObject;
0033 class TPad;
0034 class TQCommand;
0035 class TSocket;
0036 class TVirtualPad;
0037 
0038 struct Event_t;
0039 
0040 // Python
0041 struct _object;
0042 typedef _object PyObject;
0043 
0044 /// Dispatcher for C++ callbacks into Python code.
0045 class TPyDispatcher : public TObject {
0046 public:
0047    TPyDispatcher(PyObject *callable);
0048    TPyDispatcher(const TPyDispatcher &);
0049    TPyDispatcher &operator=(const TPyDispatcher &);
0050    ~TPyDispatcher() override;
0051 
0052 public:
0053    PyObject *DispatchVA(const char *format = 0, ...);
0054    PyObject *DispatchVA1(const char *clname, void *obj, const char *format, ...);
0055 
0056    // pre-defined dispatches, same as per TQObject::Emit(); note that
0057    // Emit() maps exclusively to this set, so several builtin types (e.g.
0058    // Int_t, Bool_t, Float_t, etc.) have been omitted here
0059    PyObject *Dispatch() { return DispatchVA(0); }
0060    PyObject *Dispatch(const char *param) { return DispatchVA("s", param); }
0061    PyObject *Dispatch(Double_t param) { return DispatchVA("d", param); }
0062    PyObject *Dispatch(Long_t param) { return DispatchVA("l", param); }
0063    PyObject *Dispatch(Long64_t param) { return DispatchVA("L", param); }
0064 
0065    // further selection of pre-defined, existing dispatches
0066    PyObject *Dispatch(Bool_t param) { return DispatchVA("i", param); }
0067    PyObject *Dispatch(char *param) { return DispatchVA("s", param); }
0068    PyObject *Dispatch(const char *text, Int_t len) { return DispatchVA("si", text, len); }
0069    PyObject *Dispatch(Int_t param) { return DispatchVA("i", param); }
0070    PyObject *Dispatch(Int_t x, Int_t y) { return DispatchVA("ii", x, y); }
0071    PyObject *Dispatch(ULong_t param) { return DispatchVA("k", param); }
0072    // ULong_t also for Handle_t (and Window_t, etc. ... )
0073 
0074    PyObject *Dispatch(Event_t *event) { return DispatchVA1("Event_t", event, 0); }
0075    PyObject *Dispatch(Event_t *event, ULong_t wid) { return DispatchVA1("Event_t", event, "k", wid); }
0076    PyObject *Dispatch(TEveDigitSet *qs, Int_t idx) { return DispatchVA1("TEveDigitSet", qs, "i", idx); }
0077    PyObject *Dispatch(TEveElement *el) { return DispatchVA1("TEveElement", el, 0); }
0078    PyObject *Dispatch(TEveTrack *et) { return DispatchVA1("TEveTrack", et, 0); }
0079    PyObject *Dispatch(TEveWindow *window) { return DispatchVA1("TEveWindow", window, 0); }
0080    PyObject *Dispatch(TGFrame *frame) { return DispatchVA1("TGFrame", frame, 0); }
0081    PyObject *Dispatch(TGFrame *frame, Int_t btn) { return DispatchVA1("TGFrame", frame, "i", btn); }
0082    PyObject *Dispatch(TGFrame *frame, Int_t btn, Int_t x, Int_t y)
0083    {
0084       return DispatchVA1("TGFrame", frame, "iii", btn, x, y);
0085    }
0086    PyObject *Dispatch(TGFrame *frame, UInt_t keysym, UInt_t mask)
0087    {
0088       return DispatchVA1("TGFrame", frame, "II", keysym, mask);
0089    }
0090    PyObject *Dispatch(TGListTreeItem *entry) { return DispatchVA1("TGListTreeItem", entry, 0); }
0091    PyObject *Dispatch(TGListTreeItem *entry, UInt_t mask) { return DispatchVA1("TGListTreeItem", entry, "I", mask); }
0092    PyObject *Dispatch(TGListTreeItem *entry, UInt_t keysym, UInt_t mask)
0093    {
0094       return DispatchVA1("TGListTreeItem", entry, "II", keysym, mask);
0095    }
0096    PyObject *Dispatch(TGListTreeItem *entry, Int_t btn) { return DispatchVA1("TGListTreeItem", entry, "i", btn); }
0097    PyObject *Dispatch(TGListTreeItem *entry, Int_t btn, Int_t x, Int_t y)
0098    {
0099       return DispatchVA1("TGListTreeItem", entry, "iii", btn, x, y);
0100    }
0101    PyObject *Dispatch(TGLVEntry *entry, Int_t btn) { return DispatchVA1("TGLVEntry", entry, "i", btn); }
0102    PyObject *Dispatch(TGLVEntry *entry, Int_t btn, Int_t x, Int_t y)
0103    {
0104       return DispatchVA1("TGLVEntry", entry, "iii", btn, x, y);
0105    }
0106    PyObject *Dispatch(TGLViewerBase *viewer) { return DispatchVA1("TGLViewerBase", viewer, 0); }
0107    PyObject *Dispatch(TGLPhysicalShape *shape) { return DispatchVA1("TGLPhysicalShape", shape, 0); }
0108    PyObject *Dispatch(TGLPhysicalShape *shape, UInt_t u1, UInt_t u2)
0109    {
0110       return DispatchVA1("TGLPhysicalShape", shape, "II", u1, u2);
0111    }
0112    PyObject *Dispatch(TGMdiFrame *frame) { return DispatchVA1("TGMdiFrame", frame, 0); }
0113    PyObject *Dispatch(TGShutterItem *item) { return DispatchVA1("TGShutterItem", item, 0); }
0114    PyObject *Dispatch(TGVFileSplitter *frame) { return DispatchVA1("TGVFileSplitter", frame, 0); }
0115    PyObject *Dispatch(TList *objs) { return DispatchVA1("TList", objs, 0); }
0116    PyObject *Dispatch(TObject *obj) { return DispatchVA1("TObject", obj, 0); }
0117    PyObject *Dispatch(TObject *obj, Bool_t check) { return DispatchVA1("TObject", obj, "i", check); }
0118    PyObject *Dispatch(TObject *obj, UInt_t state) { return DispatchVA1("TObject", obj, "I", state); }
0119    PyObject *Dispatch(TObject *obj, UInt_t button, UInt_t state)
0120    {
0121       return DispatchVA1("TObject", obj, "II", button, state);
0122    }
0123    PyObject *Dispatch(TSocket *sock) { return DispatchVA1("TSocket", sock, 0); }
0124    PyObject *Dispatch(TVirtualPad *pad) { return DispatchVA1("TVirtualPad", pad, 0); }
0125 
0126    PyObject *Dispatch(TPad *selpad, TObject *selected, Int_t event);
0127    PyObject *Dispatch(Int_t event, Int_t x, Int_t y, TObject *selected);
0128    PyObject *Dispatch(TVirtualPad *pad, TObject *obj, Int_t event);
0129    PyObject *Dispatch(TGListTreeItem *item, TDNDData *data);
0130    PyObject *Dispatch(const char *name, const TList *attr);
0131 
0132 private:
0133    PyObject *fCallable; //! callable object to be dispatched
0134 };
0135 
0136 #endif