a9fc02534e5efd02073cbc1e2e70a7638defd453
[mussa.git] / py / python.hpp
1 #ifndef _MUSSA_PYTHON_HPP_
2 #define _MUSSA_PYTHON_HPP_
3 #include <boost/python.hpp>
4 #include <string>
5
6 extern "C" void initmussa();
7 extern "C" void initmussaqui();
8
9 //! Create a singleton class to manage our reference to the python interpreter
10 class MussaPython {
11   public:
12     MussaPython();
13
14     //! pass multi-statement code block to the python interpreter
15     void run(std::string);
16     //! pass single expression to the python interpreter and return the result
17     boost::python::object eval(std::string);
18     //! use InteractiveConsole for readloop
19     void interpreter();
20     //! launch fgets based read-eval-print loop tied to the provided FILE pointer
21     void simple_interpreter(FILE *fp=stdin);
22     //! return an object in the python namespace
23     boost::python::object operator[](std::string);
24
25   protected:
26     boost::python::object main_namespace;
27 };
28
29 //! return a reference to a single mussa python interpreter
30 MussaPython& get_py();
31
32 #endif // _MUSSA_PYTHON_HPP_