Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/TPyReturn.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  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 //////////////////////////////////////////////////////////////////////////////
0016 //                                                                          //
0017 // TPyReturn                                                                //
0018 //                                                                          //
0019 // Morphing return type from evaluating python expressions.                 //
0020 //                                                                          //
0021 //////////////////////////////////////////////////////////////////////////////
0022 
0023 // ROOT
0024 #include "Rtypes.h"
0025 
0026 // Python
0027 struct _object;
0028 typedef _object PyObject;
0029 
0030 class TPyReturn {
0031 public:
0032    TPyReturn();
0033    TPyReturn(PyObject *pyobject);
0034    TPyReturn(const TPyReturn &);
0035    TPyReturn &operator=(const TPyReturn &);
0036    virtual ~TPyReturn();
0037 
0038    // conversions to standard types, may fail if unconvertible
0039    operator char *() const;
0040    operator const char *() const;
0041    operator Char_t() const;
0042 
0043    operator Long_t() const;
0044    operator Int_t() const { return (Int_t) operator Long_t(); }
0045    operator Short_t() const { return (Short_t) operator Long_t(); }
0046 
0047    operator ULong_t() const;
0048    operator UInt_t() const { return (UInt_t) operator ULong_t(); }
0049    operator UShort_t() const { return (UShort_t) operator ULong_t(); }
0050 
0051    operator Double_t() const;
0052    operator Float_t() const { return (Float_t) operator Double_t(); }
0053 
0054    // used for both TObject and PyObject conversions
0055    operator void *() const;
0056 
0057    template <class T>
0058    operator T *() const
0059    {
0060       return (T *)(void *)*this;
0061    }
0062 
0063    // used strictly for PyObject conversions
0064    operator PyObject *() const;
0065 
0066    ClassDef(TPyReturn, 1) // Python morphing return object
0067 
0068 private:
0069    PyObject *fPyObject; //! actual python object
0070 };
0071 
0072 #endif