Avogadro  1.1.0
/home/kitware/dashboards/avogadro/libavogadro/src/pythoninterpreter.h
00001 /**********************************************************************
00002   PythonInterpreter - Python Internal Interactive Interpreter
00003 
00004   Copyright (C) 2008 Donald Ephraim Curtis
00005 
00006   This file is part of the Avogadro molecular editor project.
00007   For more information, see <http://avogadro.openmolecules.net/>
00008 
00009   Avogadro is free software; you can redistribute it and/or modify
00010   it under the terms of the GNU General Public License as published by
00011   the Free Software Foundation; either version 2 of the License, or
00012   (at your option) any later version.
00013 
00014   Avogadro is distributed in the hope that it will be useful,
00015   but WITHOUT ANY WARRANTY; without even the implied warranty of
00016   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017   GNU General Public License for more details.
00018 
00019   You should have received a copy of the GNU General Public License
00020   along with this program; if not, write to the Free Software
00021   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00022   02110-1301, USA.
00023  **********************************************************************/
00024 
00025 #ifndef PYTHONINTERPRETER_H
00026 #define PYTHONINTERPRETER_H
00027 
00028 #include <avogadro/global.h>
00029 #include <boost/python.hpp>
00030 #include <avogadro/primitive.h>
00031 #include <QString>
00032 
00033 namespace Avogadro {
00034 
00035   class Molecule;
00036 
00050   class PythonInterpreterPrivate;
00051   class A_EXPORT PythonInterpreter
00052   {
00053     public:
00057       PythonInterpreter();
00058 
00062       ~PythonInterpreter();
00063 
00067       void setMolecule(Molecule *molecule);
00068 
00069       void addSearchPath(const QString &path);
00070 
00074       QString exec(const QString &command);
00075 
00076       QString exec(const QString &command, boost::python::object local);
00077 
00078       QString eval(const QString &string, boost::python::object local);
00079 
00080     private:
00081       PythonInterpreterPrivate *const d;
00082       static int m_initCount;
00083 
00084       boost::python::object execWrapper(const QString &command, boost::python::object main, boost::python::object local);
00085       boost::python::object evalWrapper(const QString &string, boost::python::object main, boost::python::object local);
00086   };
00087 
00088 }
00089 
00090 #endif