GNU Octave  6.2.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
interpreter-qobject.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 2011-2021 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if ! defined (octave_interpreter_qobject_h)
27 #define octave_interpreter_qobject_h 1
28 
29 #include <QObject>
30 
31 #include "qt-interpreter-events.h"
32 
33 namespace octave
34 {
35  class interpreter;
36 
37  class base_qobject;
38 
40  {
41  Q_OBJECT
42 
43  public:
44 
46 
47  ~interpreter_qobject (void) = default;
48 
50 
51  void interpreter_event (const fcn_callback& fcn);
52 
53  void interpreter_event (const meth_callback& meth);
54 
55  signals:
56 
57  void ready (void);
58 
59  void execution_finished (int);
60 
61  void shutdown_finished (int);
62 
63  public slots:
64 
65  // Programming Note: With the current design of the interpreter,
66  // additional signals will not be noticed because the execute
67  // function starts the Octave interpreter and it doesn't return
68  // until the interpreter exits. So the Qt event loop running in the
69  // thread where the interpreter_qobject object lives never has a
70  // chance to see another signal. Changing the design of the
71  // terminal widget as proposed and discussed here:
72  //
73  // https://lists.gnu.org/archive/html/octave-maintainers/2019-05/msg00115.html
74  // https://lists.gnu.org/archive/html/octave-maintainers/2019-06/msg00009.html
75  //
76  // coulld solve that problem. Briefly, instead of having the Octave
77  // interpreter block and wait for keyboard input, the terminal
78  // widget would be in charge of accepting keyboard events and use
79  // readline in callback mode. Then the terminal widget and the
80  // interpreter will not block except when executing code. Then we
81  // could have the interpreter qobject directly accept signals.
82 
83  //! Initialize and execute the octave interpreter.
84 
85  void execute (void);
86 
87  void shutdown (int);
88 
89  private:
90 
92 
94  };
95 }
96 
97 #endif
Base class for Octave interfaces that use Qt.
~interpreter_qobject(void)=default
interpreter_qobject(base_qobject &oct_qobj)
void interpreter_event(const fcn_callback &fcn)
qt_interpreter_events * qt_link(void)
void execute(void)
Initialize and execute the octave interpreter.
std::function< void(octave::interpreter &)> meth_callback
Definition: event-manager.h:47
std::function< void(void)> fcn_callback
Definition: event-manager.h:46