VirtualMachine.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
3 
4  This file is part of the TerraLib - a Framework for building GIS enabled
5  applications.
6 
7  TerraLib is free software: you can redistribute it and/or modify
8  it under the terms of the GNU Lesser General Public License as published by
9  the Free Software Foundation, either version 3 of the License,
10  or (at your option) any later version.
11 
12  TerraLib is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public License
18  along with TerraLib. See COPYING. If not, write to
19  TerraLib Team at <terralib-team@terralib.org>.
20  */
21 
22 /*!
23  \file terralib/vm/python/VirtualMachine.h
24 
25  \brief Implementation of a virtual machine for the Python Programming
26  Language.
27 
28  \author Frederico Augusto BedĂȘ
29 */
30 
31 #ifndef __TERRALIB_VM_PYTHON_VIRTUALMACHINE_H__
32 #define __TERRALIB_VM_PYTHON_VIRTUALMACHINE_H__
33 
34 // TerraLib
35 #include "../core/VirtualMachine.h"
36 
37 // STL
38 #include <iostream> // workaround because of python
39 // Python
40 #undef slots // python conflicts with qt #define slots
41 #ifdef _DEBUG
42 #undef _DEBUG
43 #include <Python.h>
44 #define _DEBUG
45 #else
46 #include <Python.h>
47 #endif
48 #define slots Q_SLOTS // redefine slots
49 
50 // Boost
51 #include <boost/python.hpp>
52 
53 #include <QEventLoop>
54 
55 namespace te
56 {
57  namespace vm
58  {
59  namespace python
60  {
62  {
63  public:
65  std::string readline();
66 
67  private:
69  };
70 
72  {
73  public:
75  void write(const std::string& str);
76 
77  private:
79  };
80 
82  {
83  Q_OBJECT
84 
85  public:
87 
88  ~VirtualMachine();
89 
90  std::string getName() const;
91 
92  std::string getTitle() const;
93 
94  std::string getDescription() const;
95 
96  void setFileName(QString file);
97 
98  std::string readline();
99 
100  public slots:
101  void write(const QString& str);
102  void stop();
103  void execute();
104  void readline(QString msg);
105 
106  private:
107  std::string m_filename;
111  std::string m_readlineStr;
112  PyThreadState* m_mainThreadState;
113  QEventLoop* m_readlineLoop;
114  };
115 
116  } // end namespace python
117  } // end namespace vm
118 } // end namespace te
119 
120 #endif // __TERRALIB_VM_PYTHON_VIRTUALMACHINE_H__
#define slots
VirtualMachineOutput m_stderr
te::vm::core::VirtualMachine * m_vm
te::vm::core::VirtualMachine * m_vm
VirtualMachineOutput m_stdout
URI C++ Library.
VirtualMachineInput(te::vm::core::VirtualMachine *vm=nullptr)