OpenStructure
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
Examples
File List
Globals
•
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
stage
include
ost
gui
python_shell
python_interpreter.hh
Go to the documentation of this file.
1
//------------------------------------------------------------------------------
2
// This file is part of the OpenStructure project <www.openstructure.org>
3
//
4
// Copyright (C) 2008-2011 by the OpenStructure authors
5
// Copyright (C) 2003-2010 by the IPLT authors
6
//
7
// This library is free software; you can redistribute it and/or modify it under
8
// the terms of the GNU Lesser General Public License as published by the Free
9
// Software Foundation; either version 3.0 of the License, or (at your option)
10
// any later version.
11
// This library is distributed in the hope that it will be useful, but WITHOUT
12
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14
// details.
15
//
16
// You should have received a copy of the GNU Lesser General Public License
17
// along with this library; if not, write to the Free Software Foundation, Inc.,
18
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
//------------------------------------------------------------------------------
20
21
/*
22
python interpreter
23
24
Authors: Andreas Schenk, Ansgar Philippsen, Marco Biasini
25
*/
26
27
#ifndef PYTHON_INTERPRETER_HH
28
#define PYTHON_INTERPRETER_HH
29
30
#include <vector>
31
32
#include <
ost/gui/module_config.hh
>
33
34
#include <
ost/gui/module_config.hh
>
35
#include "
python_interpreter_worker.hh
"
36
#include "
output_redirector.hh
"
37
#include "
main_thread_runner.hh
"
38
39
#include <QQueue>
40
#include <QMetaType>
41
42
namespace
ost {
namespace
gui {
43
namespace
bp = boost::python;
44
45
enum
InterpreterStatus
{
46
STATUS_OK
,
47
STATUS_ERROR
48
};
49
50
51
typedef
enum
{
52
CODE_BLOCK_COMPLETE
=1,
53
CODE_BLOCK_ERROR
=2,
54
CODE_BLOCK_INCOMPLETE
=4
55
}
CodeBlockStatus
;
56
57
class
DLLEXPORT_OST_GUI
PythonInterpreter
:
public
QObject
58
{
59
Q_OBJECT
60
public
:
61
static
PythonInterpreter
& Instance();
62
63
~
PythonInterpreter
();
64
bool
IsRunning();
65
void
AppendModulePath(
const
QString& entry);
66
67
void
AppendCommandlineArgument(
const
QString& arg);
68
69
bp::dict GetMainNamespace()
const
;
70
bp::object GetMainModule()
const
;
75
CodeBlockStatus
GetCodeBlockStatus(
const
QString& command);
76
77
80
void
Stop();
84
void
Start();
86
void
StopScript();
87
88
89
90
public
slots:
92
unsigned
int
RunScript(
const
QString&
script
);
93
unsigned
int
RunCommand(
const
QString& command);
94
signals:
95
void
Output(
unsigned
int
id
,
const
QString& output);
96
void
ErrorOutput(
unsigned
int
id
,
const
QString& output);
97
void
Finished(
unsigned
int
id
,
bool
error_state);
98
void
Exit();
99
void
WakeWorker();
100
protected
:
101
PythonInterpreter
();
102
bp::object
main_module_
;
103
bp::dict
main_namespace_
;
104
bool
running_
;
105
bp::object
compile_command_
;
106
PythonInterpreterWorker
worker_
;
107
};
108
109
}}
// ns
110
111
#endif
Generated on Mon Nov 11 2013 09:56:11 for OpenStructure by
1.8.1.1