Mercurial > hg > octave-lyh
annotate gui/src/OctaveLink.h @ 13541:b48ac9ad8de0
Highly improved separation of model and view classes.
author | Jacob Dawid <jacob.dawid@googlemail.com> |
---|---|
date | Tue, 26 Jul 2011 23:04:52 +0200 |
parents | 09d9cb7c3014 |
children |
rev | line source |
---|---|
13501 | 1 /* |
2 * | |
3 * Copyright (C) 2007, 2008, 2009 John P. Swensen | |
4 * | |
13504
13e3d60aff2d
Replaced Quint with OctaveGUI.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13501
diff
changeset
|
5 * OctaveGUI - A graphical user interface for Octave |
13501 | 6 * Copyright (C) 2011 Jacob Dawid |
7 * jacob.dawid@googlemail.com | |
8 * This file is as a part of OctaveDE. | |
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 the | |
12 * Free Software Foundation; either version 2, or (at your option) any | |
13 * later version. | |
14 * | |
15 * Octave is distributed in the hope that it will be useful, but WITHOUT | |
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
17 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
18 * 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, write to the Free | |
22 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | |
23 * 02110-1301, USA. | |
24 * | |
25 * */ | |
26 | |
27 #ifndef OCTAVELINK_H | |
28 #define OCTAVELINK_H | |
29 | |
30 // Octave includes | |
31 #undef PACKAGE_BUGREPORT | |
32 #undef PACKAGE_NAME | |
33 #undef PACKAGE_STRING | |
34 #undef PACKAGE_TARNAME | |
35 #undef PACKAGE_VERSION | |
36 #undef PACKAGE_URL | |
37 #include <octave/config.h> | |
38 #include "octave/cmd-edit.h" | |
39 #include "octave/error.h" | |
40 #include "octave/file-io.h" | |
41 #include "octave/input.h" | |
42 #include "octave/lex.h" | |
43 #include "octave/load-path.h" | |
44 #include "octave/octave.h" | |
45 #include "octave/oct-hist.h" | |
46 #include "octave/oct-map.h" | |
47 #include "octave/oct-obj.h" | |
48 #include "octave/ops.h" | |
49 #include "octave/ov.h" | |
50 #include "octave/ov-usr-fcn.h" | |
51 #include "octave/symtab.h" | |
52 #include "octave/pt.h" | |
53 #include "octave/pt-eval.h" | |
54 #include "octave/config.h" | |
55 #include "octave/Range.h" | |
56 #include "octave/toplev.h" | |
57 #include "octave/procstream.h" | |
58 #include "octave/sighandlers.h" | |
59 #include "octave/debug.h" | |
60 #include "octave/sysdep.h" | |
61 #include "octave/ov.h" | |
62 #include "octave/unwind-prot.h" | |
63 #include "octave/utils.h" | |
64 #include "octave/variables.h" | |
65 | |
66 // Standard includes | |
67 #include <iostream> | |
68 #include <string> | |
69 #include <vector> | |
70 #include <readline/readline.h> | |
71 | |
72 // Qt includes | |
73 #include <QMutexLocker> | |
74 #include <QMutex> | |
75 #include <QFileInfo> | |
76 #include <QList> | |
77 #include <QString> | |
13517
86adc9c4ec4b
History deactivated.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13513
diff
changeset
|
78 #include <QStringList> |
13501 | 79 #include <QVector> |
80 #include <QSemaphore> | |
81 #include <QObject> | |
13518
bace956a3724
Put history model part into OctaveLink.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13517
diff
changeset
|
82 #include <QStringListModel> |
13501 | 83 |
13541
b48ac9ad8de0
Highly improved separation of model and view classes.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13522
diff
changeset
|
84 #include "OctaveCallbackThread.h" |
b48ac9ad8de0
Highly improved separation of model and view classes.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13522
diff
changeset
|
85 #include "OctaveMainThread.h" |
b48ac9ad8de0
Highly improved separation of model and view classes.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13522
diff
changeset
|
86 |
13517
86adc9c4ec4b
History deactivated.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13513
diff
changeset
|
87 typedef symbol_table::symbol_record SymbolRecord; |
86adc9c4ec4b
History deactivated.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13513
diff
changeset
|
88 typedef octave_value OctaveValue; |
13501 | 89 |
90 /** | |
91 * \class OctaveLink | |
92 * Manages a link to an octave instance. | |
93 */ | |
13541
b48ac9ad8de0
Highly improved separation of model and view classes.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13522
diff
changeset
|
94 class OctaveLink:public QObject |
13501 | 95 { |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
96 Q_OBJECT |
13501 | 97 public: |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
98 static OctaveLink * |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
99 instance () |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
100 { |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
101 return &m_singleton; |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
102 } |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
103 static QString |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
104 octaveValueAsQString (OctaveValue octaveValue); |
13501 | 105 |
13541
b48ac9ad8de0
Highly improved separation of model and view classes.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13522
diff
changeset
|
106 void launchOctave (); |
b48ac9ad8de0
Highly improved separation of model and view classes.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13522
diff
changeset
|
107 void terminateOctave (); |
b48ac9ad8de0
Highly improved separation of model and view classes.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13522
diff
changeset
|
108 |
13517
86adc9c4ec4b
History deactivated.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13513
diff
changeset
|
109 /** |
86adc9c4ec4b
History deactivated.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13513
diff
changeset
|
110 * Returns a copy of the current symbol table buffer. |
86adc9c4ec4b
History deactivated.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13513
diff
changeset
|
111 * \return Copy of the current symbol table buffer. |
86adc9c4ec4b
History deactivated.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13513
diff
changeset
|
112 */ |
13521
16b33b7ef1b3
Raised update interval to 500ms.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13520
diff
changeset
|
113 QList < SymbolRecord > copyCurrentSymbolTable (); |
13501 | 114 |
13518
bace956a3724
Put history model part into OctaveLink.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13517
diff
changeset
|
115 void |
bace956a3724
Put history model part into OctaveLink.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13517
diff
changeset
|
116 updateHistoryModel (); |
bace956a3724
Put history model part into OctaveLink.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13517
diff
changeset
|
117 |
bace956a3724
Put history model part into OctaveLink.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13517
diff
changeset
|
118 QStringListModel * |
bace956a3724
Put history model part into OctaveLink.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13517
diff
changeset
|
119 historyModel (); |
13501 | 120 |
13517
86adc9c4ec4b
History deactivated.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13513
diff
changeset
|
121 /** |
86adc9c4ec4b
History deactivated.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13513
diff
changeset
|
122 * Updates the current symbol table with new data |
86adc9c4ec4b
History deactivated.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13513
diff
changeset
|
123 * from octave. |
86adc9c4ec4b
History deactivated.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13513
diff
changeset
|
124 */ |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
125 void |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
126 fetchSymbolTable (); |
13501 | 127 |
128 signals: | |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
129 void |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
130 symbolTableChanged (); |
13501 | 131 |
132 private: | |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
133 OctaveLink (); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
134 ~OctaveLink (); |
13501 | 135 |
13517
86adc9c4ec4b
History deactivated.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13513
diff
changeset
|
136 /** Variable related member variables. */ |
13513
e19c454ed485
Added version script for Octave GUI.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13506
diff
changeset
|
137 QSemaphore * m_symbolTableSemaphore; |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
138 QList < SymbolRecord > m_symbolTableBuffer; |
13501 | 139 |
13517
86adc9c4ec4b
History deactivated.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13513
diff
changeset
|
140 /** History related member variables. */ |
13518
bace956a3724
Put history model part into OctaveLink.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13517
diff
changeset
|
141 QStringListModel *m_historyModel; |
13519
35ecb6063c7b
Made the view connect with the history model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13518
diff
changeset
|
142 |
13541
b48ac9ad8de0
Highly improved separation of model and view classes.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13522
diff
changeset
|
143 // Threads for running octave and managing the data interaction. |
b48ac9ad8de0
Highly improved separation of model and view classes.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13522
diff
changeset
|
144 OctaveMainThread *m_octaveMainThread; |
b48ac9ad8de0
Highly improved separation of model and view classes.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13522
diff
changeset
|
145 OctaveCallbackThread *m_octaveCallbackThread; |
b48ac9ad8de0
Highly improved separation of model and view classes.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13522
diff
changeset
|
146 |
13513
e19c454ed485
Added version script for Octave GUI.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13506
diff
changeset
|
147 static OctaveLink m_singleton; |
13501 | 148 }; |
149 #endif // OCTAVELINK_H |