Loading...
Searching...
No Matches
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#include <QEventLoop>
51
52namespace te
53{
54 namespace vm
55 {
56 namespace python
57 {
59 {
60 public:
62 std::string readline();
63
64 private:
66 };
67
69 {
70 public:
72 void write(const std::string& str);
73
74 private:
76 };
77
79 {
80 Q_OBJECT
81
82 public:
84
86
87 std::string getName() const;
88
89 std::string getTitle() const;
90
91 std::string getDescription() const;
92
93 void setFileName(QString file);
94
95 std::string readline();
96
97 public slots:
98 void write(const QString& str);
99 void stop();
100 void execute();
101 void readline(QString msg);
102
103 private:
104 std::string m_filename;
108 std::string m_readlineStr;
109 PyThreadState* m_mainThreadState;
110 QEventLoop* m_readlineLoop;
111 };
112
113 } // end namespace python
114 } // end namespace vm
115} // end namespace te
116
117#endif // __TERRALIB_VM_PYTHON_VIRTUALMACHINE_H__
te::vm::core::VirtualMachine * m_vm
VirtualMachineInput(te::vm::core::VirtualMachine *vm=nullptr)
void write(const std::string &str)
te::vm::core::VirtualMachine * m_vm
VirtualMachineOutput(te::vm::core::VirtualMachine *vm=nullptr)
std::string getDescription() const
Returns a brief description about the underlying Virtual Machine.
std::string readline()
readline Method to be used by the language of the Virtual Machine when doing a input operation.
void write(const QString &str)
std::string getName() const
VirtualMachineOutput m_stderr
~VirtualMachine()
Virtual destructor.
void setFileName(QString file)
setFileName Sets the file that will be used in the Virtual Machine.
VirtualMachineOutput m_stdout
std::string getTitle() const
Return the title of Virtual Machine: a name that can be used by applications to show in a GUI.
TerraLib.
#define slots