fc210c33369ba71e36e56525e2605a1b93014d2a
[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
8 //! Create a singleton class to manage our reference to the python interpreter
9 class MussaPython {
10   public:
11     MussaPython();
12
13     //! pass multi-statement code block to the python interpreter
14     void run(std::string);
15     //! pass single expression to the python interpreter and return the result
16     boost::python::object eval(std::string);
17     //! launch read-eval-print loop tied to the provided FILE pointer
18     void interpreter(FILE *fp=stdin);
19     //! return an object in the python namespace
20     boost::python::object operator[](std::string);
21
22   protected:
23     boost::python::object main_namespace;
24 };
25
26 //! return a reference to a single mussa python interpreter
27 MussaPython& get_py();
28
29 #endif // _MUSSA_PYTHON_HPP_