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
build-2.6
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-2020 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
31
#include "
python_interpreter_worker.hh
"
32
#include "
output_redirector.hh
"
33
#include "
main_thread_runner.hh
"
34
#include <
ost/gui/module_config.hh
>
35
36
#include <QQueue>
37
#include <QMetaType>
38
39
namespace
ost {
namespace
gui {
40
namespace
bp = boost::python;
41
42
enum
InterpreterStatus
{
43
STATUS_OK
,
44
STATUS_ERROR
45
};
46
47
48
typedef
enum
{
49
CODE_BLOCK_COMPLETE
=1,
50
CODE_BLOCK_ERROR
=2,
51
CODE_BLOCK_INCOMPLETE
=4
52
}
CodeBlockStatus
;
53
54
class
DLLEXPORT_OST_GUI
PythonInterpreter
:
public
QObject
55
{
56
Q_OBJECT
57
public
:
58
static
PythonInterpreter
& Instance();
59
60
~
PythonInterpreter
();
61
bool
IsRunning();
62
void
AppendModulePath(
const
QString& entry);
63
64
void
AppendCommandlineArgument(
const
QString& arg);
65
66
bp::dict GetMainNamespace()
const
;
67
bp::object GetMainModule()
const
;
72
CodeBlockStatus
GetCodeBlockStatus(
const
QString& command);
73
74
77
void
Stop();
81
void
Start();
83
void
StopScript();
84
85
86
87
public
slots:
89
unsigned
int
RunScript(
const
QString&
script
);
90
unsigned
int
RunCommand(
const
QString& command);
91
signals:
92
void
Output(
unsigned
int
id
,
const
QString& output);
93
void
ErrorOutput(
unsigned
int
id
,
const
QString& output);
94
void
Finished(
unsigned
int
id
,
bool
error_state);
95
void
Exit();
96
void
WakeWorker();
97
protected
:
98
PythonInterpreter
();
99
bp::object
main_module_
;
100
bp::dict
main_namespace_
;
101
bool
running_
;
102
bp::object
compile_command_
;
103
PythonInterpreterWorker
worker_
;
104
};
105
106
}}
// ns
107
108
#endif
ost.ost_startup.script
list script
Definition:
ost_startup.py:72
ost::gui::CODE_BLOCK_COMPLETE
Definition:
python_interpreter.hh:49
main_thread_runner.hh
ost::gui::PythonInterpreter::main_module_
bp::object main_module_
Definition:
python_interpreter.hh:99
module_config.hh
ost::gui::PythonInterpreter::compile_command_
bp::object compile_command_
Definition:
python_interpreter.hh:102
output_redirector.hh
ost::gui::InterpreterStatus
InterpreterStatus
Definition:
python_interpreter.hh:42
python_interpreter_worker.hh
ost::gui::PythonInterpreterWorker
Definition:
python_interpreter_worker.hh:42
DLLEXPORT_OST_GUI
#define DLLEXPORT_OST_GUI
Definition:
module_config.hh:33
ost::gui::CODE_BLOCK_ERROR
Definition:
python_interpreter.hh:50
ost::gui::PythonInterpreter::worker_
PythonInterpreterWorker worker_
Definition:
python_interpreter.hh:103
ost::gui::PythonInterpreter::main_namespace_
bp::dict main_namespace_
Definition:
python_interpreter.hh:100
ost::gui::CodeBlockStatus
CodeBlockStatus
Definition:
python_interpreter.hh:48
ost::gui::STATUS_ERROR
Definition:
python_interpreter.hh:44
ost::gui::CODE_BLOCK_INCOMPLETE
Definition:
python_interpreter.hh:51
ost::gui::PythonInterpreter::running_
bool running_
Definition:
python_interpreter.hh:101
ost::gui::STATUS_OK
Definition:
python_interpreter.hh:43
ost::gui::PythonInterpreter
Definition:
python_interpreter.hh:54
Generated by
1.8.5