Fledge
An open source edge computing platform for industrial users
pyruntime.h
1 #ifndef _PYRUNTIME_H
2 #define _PYRUNTIME_H
3 /*
4  * Fledge Python Runtime.
5  *
6  * Copyright (c) 2021 Dianomic Systems
7  *
8  * Released under the Apache 2.0 Licence
9  *
10  * Author: Mark Riddoch
11  */
12 #include <Python.h>
13 
15  public:
17  static bool initialised() { return m_instance != NULL; };
18  static void shutdown();
19  void execute(const std::string& python);
20  PyObject *call(const std::string& name, const std::string& fmt, ...);
21  PyObject *call(PyObject *module, const std::string& name, const std::string& fmt, ...);
22  PyObject *importModule(const std::string& name);
23  private:
24  PythonRuntime();
25  ~PythonRuntime();
26  PythonRuntime(const PythonRuntime& rhs);
27  PythonRuntime& operator=(const PythonRuntime& rhs);
28  void logException(const std::string& name);
29 
30  static PythonRuntime *m_instance;
31 
32 };
33 
34 #endif
35 
static PythonRuntime * getPythonRuntime()
Get PythonRuntime singleton instance for the process.
Definition: pyruntime.cpp:28
void execute(const std::string &python)
Execute simple Python script passed as a string.
Definition: pyruntime.cpp:77
PyObject * importModule(const std::string &name)
Import a Python module.
Definition: pyruntime.cpp:316
static void shutdown()
Shutdown an instance of a Python runtime if one has been started.
Definition: pyruntime.cpp:336
Definition: pyruntime.h:14