Support Forum G3D Web Page |
This class implements the Singleton design pattern. More...
Public Member Functions | |
PythonInterpreter (PythonInterpreter const ©)=delete | |
Stop the compiler generating methods of copying the object. More... | |
virtual | ~PythonInterpreter () |
template<typename Out , typename In > | |
void | call (const String &name, Out &output, const In &input) |
void | finishPython () |
Close python interpreter. More... | |
void | importFunctionFromModule (const String &function, const String &module) |
void | importModule (const String &module) |
PythonInterpreter & | operator= (PythonInterpreter const ©)=delete |
void | startPython (const String &pythonHome) |
Initialize Python interpreter. More... | |
Static Public Member Functions | |
static const char * | assertPythonOk (const char *variable) |
Examine python error state. More... | |
static shared_ptr< PythonInterpreter > & | interpreterHandle () |
Protected Member Functions | |
template<typename T > | |
T | convertToCObject (PyObject *input) |
template<typename T > | |
PyObject * | convertToPythonArgument (const std::vector< size_t > &dimensions, T *data) |
template<typename T > | |
PyObject * | convertToPythonArgument (const T &input) |
Protected Attributes | |
Table< String, PyObject * > | m_functions |
Table< String, PyObject * > | m_modules |
bool | m_pythonRunning = false |
Table< int, int > | test |
This class implements the Singleton design pattern.
It is not thread-safe. For more, see: https://www.aristeia.com/Papers/DDJ_Jul_Aug_2004_revised.pdf (Scott Meyer's paper on the thread safety of singletons, where he argues that making a Singleton truly thread-safe in a portable way is (nearly?) impossible.) Even so, we choose Singleton for the following reasons:
|
delete |
Stop the compiler generating methods of copying the object.
Make these deleted functions public for more useful error messages.
|
inlinevirtual |
|
static |
Examine python error state.
variable is the name of the most recent python object ptr that was intialized by a call to the Python API.
void G3D::PythonInterpreter::call | ( | const String & | name, |
Out & | output, | ||
const In & | input | ||
) |
|
inlineprotected |
|
protected |
|
inlineprotected |
void G3D::PythonInterpreter::finishPython | ( | ) |
Close python interpreter.
All resources should be released with Py_DECREF at this point.
Referenced by ~PythonInterpreter().
void G3D::PythonInterpreter::importFunctionFromModule | ( | const String & | function, |
const String & | module | ||
) |
void G3D::PythonInterpreter::importModule | ( | const String & | module | ) |
|
inlinestatic |
|
delete |
void G3D::PythonInterpreter::startPython | ( | const String & | pythonHome | ) |
Initialize Python interpreter.
|
protected |
Referenced by ~PythonInterpreter().
|
protected |