make compiled in python extension initialization more flexable
[mussa.git] / py / python.hpp
index a9fc02534e5efd02073cbc1e2e70a7638defd453..990305f611e4f97c6e68245b1831edbbe1c88a56 100644 (file)
@@ -2,15 +2,21 @@
 #define _MUSSA_PYTHON_HPP_
 #include <boost/python.hpp>
 #include <string>
-
-extern "C" void initmussa();
-extern "C" void initmussaqui();
+#include <list>
+#include <utility>
 
 //! Create a singleton class to manage our reference to the python interpreter
 class MussaPython {
   public:
+    typedef void (*python_module_init)(void);
     MussaPython();
 
+    //! initalize interpreter
+    void init_interpreter();
+    //! add a python module that was statically compiled into this executable
+    void add_module(const std::string& name, python_module_init); 
+    //! return main python namespace(initializing the interpreter if needed)
+    boost::python::object get_namespace();
     //! pass multi-statement code block to the python interpreter
     void run(std::string);
     //! pass single expression to the python interpreter and return the result
@@ -21,12 +27,16 @@ class MussaPython {
     void simple_interpreter(FILE *fp=stdin);
     //! return an object in the python namespace
     boost::python::object operator[](std::string);
-
   protected:
+    typedef std::pair<std::string, python_module_init> module_item;
+    typedef std::list<module_item> module_list;
+    module_list python_modules;
     boost::python::object main_namespace;
+    
+    static void AppendInittab(const module_item &item);
 };
 
 //! return a reference to a single mussa python interpreter
-MussaPythonget_py();
+MussaPython *get_py();
 
 #endif // _MUSSA_PYTHON_HPP_