Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-16 09:09:55

0001 // Author: Enric Tejedor CERN  08/2019
0002 // Original PyROOT code by Wim Lavrijsen, LBL
0003 //
0004 // /*************************************************************************
0005 //  * Copyright (C) 1995-2019, 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_TPyReturn
0013 #define ROOT_TPyReturn
0014 
0015 // ROOT
0016 #include "Rtypes.h"
0017 
0018 // Python
0019 struct _object;
0020 typedef _object PyObject;
0021 
0022 /// Morphing return type from evaluating python expressions. 
0023 class TPyReturn {
0024 public:
0025    TPyReturn();
0026    TPyReturn(PyObject *pyobject);
0027    TPyReturn(const TPyReturn &);
0028    TPyReturn &operator=(const TPyReturn &);
0029    virtual ~TPyReturn();
0030 
0031    // conversions to standard types, may fail if unconvertible
0032    operator char *() const;
0033    operator const char *() const;
0034    operator Char_t() const;
0035 
0036    operator Long_t() const;
0037    operator Int_t() const { return (Int_t) operator Long_t(); }
0038    operator Short_t() const { return (Short_t) operator Long_t(); }
0039 
0040    operator ULong_t() const;
0041    operator UInt_t() const { return (UInt_t) operator ULong_t(); }
0042    operator UShort_t() const { return (UShort_t) operator ULong_t(); }
0043 
0044    operator Double_t() const;
0045    operator Float_t() const { return (Float_t) operator Double_t(); }
0046 
0047    // used for both TObject and PyObject conversions
0048    operator void *() const;
0049 
0050    template <class T>
0051    operator T *() const
0052    {
0053       return (T *)(void *)*this;
0054    }
0055 
0056    // used strictly for PyObject conversions
0057    operator PyObject *() const;
0058 
0059    ClassDef(TPyReturn, 1) // Python morphing return object
0060 
0061 private:
0062    PyObject *fPyObject; //! actual python object
0063 };
0064 
0065 #endif