|
||||
File indexing completed on 2025-01-18 09:57:45
0001 /***********************************************************************************\ 0002 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations * 0003 * * 0004 * This software is distributed under the terms of the Apache version 2 licence, * 0005 * copied verbatim in the file "LICENSE". * 0006 * * 0007 * In applying this licence, CERN does not waive the privileges and immunities * 0008 * granted to it by virtue of its status as an Intergovernmental Organization * 0009 * or submit itself to any jurisdiction. * 0010 \***********************************************************************************/ 0011 #ifndef GAUDIPYTHON_CALLBACKSTREAMBUF_H 0012 #define GAUDIPYTHON_CALLBACKSTREAMBUF_H 0013 // ============================================================================ 0014 #include "Python.h" //included for the python API 0015 // ============================================================================ 0016 #include <array> 0017 #include <sstream> //included for stringbuf 0018 // ============================================================================ 0019 #include "GaudiKernel/Kernel.h" 0020 #include "GaudiPython/GaudiPython.h" 0021 // ============================================================================ 0022 0023 namespace GaudiPython { 0024 int GAUDI_API call_python_method( PyObject* self, const char* method, char* buf ); 0025 0026 class GAUDI_API CallbackStreamBuf : public std::stringbuf { 0027 private: 0028 class PyObject_t { 0029 PyObject* m_obj; 0030 0031 public: 0032 PyObject_t( PyObject* obj = nullptr ) : m_obj( obj ) { 0033 if ( m_obj ) Py_INCREF( m_obj ); 0034 } 0035 ~PyObject_t() { 0036 if ( m_obj ) Py_DECREF( m_obj ); 0037 } 0038 PyObject* get() { return m_obj; } 0039 }; 0040 PyObject_t m_self; 0041 std::array<char, 512> m_callbackBuff; // used for passing the flushed chars in the python callback 0042 0043 public: 0044 CallbackStreamBuf( PyObject* self ); 0045 int sync() override; 0046 }; 0047 } // namespace GaudiPython 0048 0049 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |