Mercurial > hg > octave-lyh
annotate gui/src/octave-adapter/octave-link.h @ 14713:565ddd85565e gui
Added comments for the octave-adapter module.
* octave-adapter/octave-link.h: Added comments.
* octave-adapter/octave-main-thread.h: Added comments.
* octave-adapter/symbol-information.h: Added comments.
author | Jacob Dawid <jacob.dawid@googlemail.com> |
---|---|
date | Sat, 02 Jun 2012 13:57:51 +0200 |
parents | 5cb54cca8a06 |
children | 4ff6c21c18c4 |
rev | line source |
---|---|
13674
c0e66d6e3dc8
Updated license headers and moved to AGPLv3.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13595
diff
changeset
|
1 /* OctaveGUI - A graphical user interface for Octave |
c0e66d6e3dc8
Updated license headers and moved to AGPLv3.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13595
diff
changeset
|
2 * Copyright (C) 2011 John P. Swensen, Jacob Dawid (jacob.dawid@googlemail.com) |
13501 | 3 * |
13674
c0e66d6e3dc8
Updated license headers and moved to AGPLv3.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13595
diff
changeset
|
4 * This program is free software: you can redistribute it and/or modify |
14290
faece6b2ab90
Corrected license headers in all files to GPL.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13683
diff
changeset
|
5 * it under the terms of the GNU General Public License as |
13674
c0e66d6e3dc8
Updated license headers and moved to AGPLv3.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13595
diff
changeset
|
6 * published by the Free Software Foundation, either version 3 of the |
c0e66d6e3dc8
Updated license headers and moved to AGPLv3.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13595
diff
changeset
|
7 * License, or (at your option) any later version. |
13501 | 8 * |
13674
c0e66d6e3dc8
Updated license headers and moved to AGPLv3.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13595
diff
changeset
|
9 * This program is distributed in the hope that it will be useful, |
c0e66d6e3dc8
Updated license headers and moved to AGPLv3.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13595
diff
changeset
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
c0e66d6e3dc8
Updated license headers and moved to AGPLv3.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13595
diff
changeset
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14290
faece6b2ab90
Corrected license headers in all files to GPL.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13683
diff
changeset
|
12 * GNU General Public License for more details. |
13501 | 13 * |
14290
faece6b2ab90
Corrected license headers in all files to GPL.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13683
diff
changeset
|
14 * You should have received a copy of the GNU General Public License |
13674
c0e66d6e3dc8
Updated license headers and moved to AGPLv3.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13595
diff
changeset
|
15 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
c0e66d6e3dc8
Updated license headers and moved to AGPLv3.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13595
diff
changeset
|
16 */ |
13501 | 17 |
18 #ifndef OCTAVELINK_H | |
19 #define OCTAVELINK_H | |
20 | |
21 // Octave includes | |
22 #undef PACKAGE_BUGREPORT | |
23 #undef PACKAGE_NAME | |
24 #undef PACKAGE_STRING | |
25 #undef PACKAGE_TARNAME | |
26 #undef PACKAGE_VERSION | |
27 #undef PACKAGE_URL | |
13595
56eb9348ff02
Added missing include flags.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13543
diff
changeset
|
28 #include "octave/config.h" |
13501 | 29 #include "octave/cmd-edit.h" |
30 #include "octave/error.h" | |
31 #include "octave/file-io.h" | |
32 #include "octave/input.h" | |
33 #include "octave/lex.h" | |
34 #include "octave/load-path.h" | |
35 #include "octave/octave.h" | |
36 #include "octave/oct-hist.h" | |
37 #include "octave/oct-map.h" | |
38 #include "octave/oct-obj.h" | |
39 #include "octave/ops.h" | |
40 #include "octave/ov.h" | |
41 #include "octave/ov-usr-fcn.h" | |
42 #include "octave/symtab.h" | |
43 #include "octave/pt.h" | |
44 #include "octave/pt-eval.h" | |
45 #include "octave/config.h" | |
46 #include "octave/Range.h" | |
47 #include "octave/toplev.h" | |
48 #include "octave/procstream.h" | |
49 #include "octave/sighandlers.h" | |
50 #include "octave/debug.h" | |
51 #include "octave/sysdep.h" | |
52 #include "octave/ov.h" | |
53 #include "octave/unwind-prot.h" | |
54 #include "octave/utils.h" | |
55 #include "octave/variables.h" | |
56 | |
57 // Standard includes | |
58 #include <iostream> | |
59 #include <string> | |
60 #include <vector> | |
61 #include <readline/readline.h> | |
62 | |
63 // Qt includes | |
64 #include <QMutexLocker> | |
65 #include <QMutex> | |
66 #include <QFileInfo> | |
67 #include <QList> | |
68 #include <QString> | |
13517
86adc9c4ec4b
History deactivated.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13513
diff
changeset
|
69 #include <QStringList> |
13501 | 70 #include <QVector> |
71 #include <QSemaphore> | |
72 #include <QObject> | |
13518
bace956a3724
Put history model part into OctaveLink.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13517
diff
changeset
|
73 #include <QStringListModel> |
14671
f346343654a4
Settings readline event hook and fixed race condition.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14668
diff
changeset
|
74 #include <QTimer> |
13501 | 75 |
14707
674740c44c09
Changed various files to matche file naming conventions.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14703
diff
changeset
|
76 #include "workspace-model.h" |
674740c44c09
Changed various files to matche file naming conventions.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14703
diff
changeset
|
77 #include "octave-main-thread.h" |
674740c44c09
Changed various files to matche file naming conventions.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14703
diff
changeset
|
78 #include "symbol-information.h" |
13541
b48ac9ad8de0
Highly improved separation of model and view classes.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13522
diff
changeset
|
79 |
13501 | 80 /** |
81 * \class OctaveLink | |
14713
565ddd85565e
Added comments for the octave-adapter module.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
82 * \brief Provides threadsafe access to octave. |
565ddd85565e
Added comments for the octave-adapter module.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
83 * \author Jacob Dawid |
565ddd85565e
Added comments for the octave-adapter module.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
84 * This class is a wrapper around octave and provides threadsafety by |
565ddd85565e
Added comments for the octave-adapter module.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
85 * buffering access operations to octave and executing them in the readline |
565ddd85565e
Added comments for the octave-adapter module.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
86 * even hook, which lives in the octave thread. |
13501 | 87 */ |
14713
565ddd85565e
Added comments for the octave-adapter module.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
88 class octave_link : public QObject |
13501 | 89 { |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
90 Q_OBJECT |
13501 | 91 public: |
14713
565ddd85565e
Added comments for the octave-adapter module.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
92 /** Provides a way to access the unique octave_link object. */ |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
93 static octave_link * |
14713
565ddd85565e
Added comments for the octave-adapter module.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
94 instance () { return &_singleton; } |
565ddd85565e
Added comments for the octave-adapter module.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
95 |
565ddd85565e
Added comments for the octave-adapter module.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
96 /** Starts octave. */ |
565ddd85565e
Added comments for the octave-adapter module.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
97 void launch_octave (); |
13501 | 98 |
14713
565ddd85565e
Added comments for the octave-adapter module.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
99 /** Attempts to close octave. */ |
14712
5cb54cca8a06
Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14709
diff
changeset
|
100 void terminate_octave (); |
14713
565ddd85565e
Added comments for the octave-adapter module.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
101 |
565ddd85565e
Added comments for the octave-adapter module.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
102 /** Returns the current history model. */ |
14712
5cb54cca8a06
Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14709
diff
changeset
|
103 QStringListModel *get_history_model (); |
14713
565ddd85565e
Added comments for the octave-adapter module.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
104 |
565ddd85565e
Added comments for the octave-adapter module.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
105 /** Returns the current workspace model. */ |
14712
5cb54cca8a06
Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14709
diff
changeset
|
106 workspace_model *get_workspace_model (); |
13501 | 107 |
14713
565ddd85565e
Added comments for the octave-adapter module.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
108 /** Triggers an update of the history model. */ |
14712
5cb54cca8a06
Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14709
diff
changeset
|
109 void trigger_update_history_model (); |
14713
565ddd85565e
Added comments for the octave-adapter module.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
110 |
565ddd85565e
Added comments for the octave-adapter module.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
111 /** Updates the current working directory. */ |
14712
5cb54cca8a06
Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14709
diff
changeset
|
112 void update_current_working_directory (); |
14698
79c9a6d06590
Wrote SymbolInformation struct and refactored code that updates the symbol table.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14671
diff
changeset
|
113 |
14713
565ddd85565e
Added comments for the octave-adapter module.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
114 /** Acquires the symbol information. You need to acquire that before |
565ddd85565e
Added comments for the octave-adapter module.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
115 * actually accessing it. Make sure that you release it properly in order |
565ddd85565e
Added comments for the octave-adapter module.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
116 * to avoid deadlocks. */ |
14712
5cb54cca8a06
Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14709
diff
changeset
|
117 void acquire_symbol_information (); |
14713
565ddd85565e
Added comments for the octave-adapter module.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
118 |
565ddd85565e
Added comments for the octave-adapter module.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
119 /** Releases access to the symbol information. */ |
14712
5cb54cca8a06
Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14709
diff
changeset
|
120 void release_symbol_information (); |
14713
565ddd85565e
Added comments for the octave-adapter module.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
121 |
565ddd85565e
Added comments for the octave-adapter module.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
122 /** Update symbol information from octave's symboltable. */ |
14712
5cb54cca8a06
Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14709
diff
changeset
|
123 void build_symbol_information (); |
14713
565ddd85565e
Added comments for the octave-adapter module.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
124 |
565ddd85565e
Added comments for the octave-adapter module.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
125 /** Provides acces to the current symbol information. |
565ddd85565e
Added comments for the octave-adapter module.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
126 * WARNING: Always acquire the symbol information before actually |
565ddd85565e
Added comments for the octave-adapter module.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
127 * using it and make sure you release it properly afterwards. |
565ddd85565e
Added comments for the octave-adapter module.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
128 */ |
14712
5cb54cca8a06
Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14709
diff
changeset
|
129 const QList <symbol_information>& get_symbol_information () const; |
13501 | 130 |
14700
7623bece76df
Implemented logic for current directory bar.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14698
diff
changeset
|
131 signals: |
14713
565ddd85565e
Added comments for the octave-adapter module.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
132 /** Emitted, whenever the working directory of octave changed. */ |
14712
5cb54cca8a06
Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14709
diff
changeset
|
133 void working_directory_changed (QString directory); |
14700
7623bece76df
Implemented logic for current directory bar.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14698
diff
changeset
|
134 |
13501 | 135 private: |
14713
565ddd85565e
Added comments for the octave-adapter module.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
136 /** Singleton. */ |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
137 octave_link (); |
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
138 ~octave_link (); |
13501 | 139 |
14713
565ddd85565e
Added comments for the octave-adapter module.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
140 /** Stores the current history_model. */ |
14712
5cb54cca8a06
Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14709
diff
changeset
|
141 QStringListModel *_history_model; |
14713
565ddd85565e
Added comments for the octave-adapter module.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
142 |
565ddd85565e
Added comments for the octave-adapter module.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
143 /** Stores the current workspace model. */ |
14712
5cb54cca8a06
Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14709
diff
changeset
|
144 workspace_model *_workspace_model; |
13519
35ecb6063c7b
Made the view connect with the history model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13518
diff
changeset
|
145 |
14713
565ddd85565e
Added comments for the octave-adapter module.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
146 /** Thread running octave_main. */ |
14712
5cb54cca8a06
Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14709
diff
changeset
|
147 octave_main_thread *_octave_main_thread; |
14713
565ddd85565e
Added comments for the octave-adapter module.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
148 |
565ddd85565e
Added comments for the octave-adapter module.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
149 /** Timer for periodically updating the workspace model from the current |
565ddd85565e
Added comments for the octave-adapter module.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
150 * symbol information. */ |
14712
5cb54cca8a06
Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14709
diff
changeset
|
151 QTimer _update_workspace_model_timer; |
13541
b48ac9ad8de0
Highly improved separation of model and view classes.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13522
diff
changeset
|
152 |
14713
565ddd85565e
Added comments for the octave-adapter module.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
153 /** Semaphore to lock access to the symbol information. */ |
14712
5cb54cca8a06
Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14709
diff
changeset
|
154 QSemaphore *_symbol_information_semaphore; |
14713
565ddd85565e
Added comments for the octave-adapter module.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
155 |
565ddd85565e
Added comments for the octave-adapter module.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
156 /** Stores the current symbol information. */ |
14712
5cb54cca8a06
Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14709
diff
changeset
|
157 QList <symbol_information> _symbol_information; |
14698
79c9a6d06590
Wrote SymbolInformation struct and refactored code that updates the symbol table.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14671
diff
changeset
|
158 |
14713
565ddd85565e
Added comments for the octave-adapter module.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
159 /** Stores the last known current working directory of octave. */ |
14712
5cb54cca8a06
Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14709
diff
changeset
|
160 QString _current_working_directory; |
14713
565ddd85565e
Added comments for the octave-adapter module.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
161 |
565ddd85565e
Added comments for the octave-adapter module.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
162 /** Unique instance. Singelton! */ |
14712
5cb54cca8a06
Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14709
diff
changeset
|
163 static octave_link _singleton; |
13501 | 164 }; |
165 #endif // OCTAVELINK_H |