annotate libgui/src/octave-cmd.h @ 21213:f7d1050b9b53

maint: Clean up various usages of #ifdef. * randmtzig.c: Use #ifdef rather than just #if. * EditControl.h : Use '#if ! defined' rather than '#ifndef' in guard block to match Octave style. * dialog.cc, settings-dialog.cc: Add FIXME notes about questionable use of #if mechanism. * file-editor-tab.cc, Array-b.cc, Array-ch.cc, Array-d.cc, Array-f.cc, Array-i.cc, Array-s.cc, MatrixType.h, quit.h, lo-sysdep.cc, lo-cutils.c, oct-alloc.h, oct-shlib.cc, sparse-sort.h: #define HAVE_XXX macros to 1, not just empty but defined. * octave-txt-lexer.h, octave-cmd.h, octave-preserve-stream-state.h, txt-eng.h, zfstream.h, oct-conf-features.h, oct-conf.h: Use octave_ namespace prefix on name of #define used to prevent multiple inclusion of headers. * parser.h, webinfo.h, ov-oncleanup.h, op-int.h, display-available.h, shared-fcns.h: Add #define guard to prevent multiple inclusion. * quadcc.cc: use all capitals for #define MIN_CQUAD_HEAPSIZE. * ov-intx.h: Add note that this file must not use guard #define. * eigs-base.h, randmtzig.h: Write '! defined' rather than '!defined'. * file-ops.cc, oct-sparse.h: Use parentheses around complex #if tests. * oct-syscalls.cc, oct-base64.cc, statdefs.h: Indent #ifdef blocks correctly. * oct-conf-post.in.h: Use "! defined". Define macros to 1, not just empty but defined.
author Rik <rik@octave.org>
date Sat, 06 Feb 2016 18:22:32 -0800
parents e8c3590da9ff
children fc6a9bd59094
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19773
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
1 /*
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
2
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
3 Copyright (C) 2014 Torsten
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
4
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
5 This file is part of Octave.
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
6
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
10 option) any later version.
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
11
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
15 for more details.
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
16
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
18 along with Octave; see the file COPYING. If not, see
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
19 <http://www.gnu.org/licenses/>.
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
20
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
21 */
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
22
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
23 // Author: Torsten <ttl@justmail.de>
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
24
21213
f7d1050b9b53 maint: Clean up various usages of #ifdef.
Rik <rik@octave.org>
parents: 21148
diff changeset
25 #if ! defined (octave_octave_cmd_h)
f7d1050b9b53 maint: Clean up various usages of #ifdef.
Rik <rik@octave.org>
parents: 21148
diff changeset
26 #define octave_octave_cmd_h 1
19773
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
27
21028
4a7d9c335402 GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents: 21027
diff changeset
28 #include <QSemaphore>
4a7d9c335402 GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents: 21027
diff changeset
29 #include <QMutex>
19773
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
30 #include <QString>
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
31 #include <QFileInfo>
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
32
21028
4a7d9c335402 GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents: 21027
diff changeset
33 #include "octave-qt-link.h"
4a7d9c335402 GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents: 21027
diff changeset
34
19773
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
35 class octave_cmd
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
36 {
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
37 public:
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
38
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
39 octave_cmd () { };
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
40 virtual ~octave_cmd () { };
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
41
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
42 virtual void execute () { };
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
43 };
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
44
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
45
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
46 // ---------------------------------------------------------------------
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
47 // class octave_cmd_exec
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
48
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
49 class octave_cmd_exec : public octave_cmd
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
50 {
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
51 public:
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
52
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
53 octave_cmd_exec (const QString& cmd) : octave_cmd () { _cmd = cmd; };
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
54 void execute ();
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
55
21027
8000dacaea98 GUI: no more extra command queue for debug commands
Torsten <ttl@justmail.de>
parents: 20791
diff changeset
56 protected:
19773
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
57
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
58 QString _cmd;
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
59 };
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
60
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
61
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
62 // ---------------------------------------------------------------------
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
63 // class octave_cmd_eval
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
64
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
65 class octave_cmd_eval : public octave_cmd
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
66 {
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
67 public:
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
68
21148
e8c3590da9ff update directory in gui after add-path/change-dir dialog
Torsten <ttl@justmail.de>
parents: 21028
diff changeset
69 octave_cmd_eval (const QFileInfo& info,
e8c3590da9ff update directory in gui after add-path/change-dir dialog
Torsten <ttl@justmail.de>
parents: 21028
diff changeset
70 octave_qt_link* octave_qt_link) : octave_cmd ()
e8c3590da9ff update directory in gui after add-path/change-dir dialog
Torsten <ttl@justmail.de>
parents: 21028
diff changeset
71 { _info = info;
e8c3590da9ff update directory in gui after add-path/change-dir dialog
Torsten <ttl@justmail.de>
parents: 21028
diff changeset
72 _octave_qt_link = octave_qt_link;
e8c3590da9ff update directory in gui after add-path/change-dir dialog
Torsten <ttl@justmail.de>
parents: 21028
diff changeset
73 };
e8c3590da9ff update directory in gui after add-path/change-dir dialog
Torsten <ttl@justmail.de>
parents: 21028
diff changeset
74
19773
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
75 void execute ();
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
76
21027
8000dacaea98 GUI: no more extra command queue for debug commands
Torsten <ttl@justmail.de>
parents: 20791
diff changeset
77 protected:
19773
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
78
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
79 QFileInfo _info;
21148
e8c3590da9ff update directory in gui after add-path/change-dir dialog
Torsten <ttl@justmail.de>
parents: 21028
diff changeset
80 octave_qt_link *_octave_qt_link;
19773
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
81 };
21027
8000dacaea98 GUI: no more extra command queue for debug commands
Torsten <ttl@justmail.de>
parents: 20791
diff changeset
82
8000dacaea98 GUI: no more extra command queue for debug commands
Torsten <ttl@justmail.de>
parents: 20791
diff changeset
83
8000dacaea98 GUI: no more extra command queue for debug commands
Torsten <ttl@justmail.de>
parents: 20791
diff changeset
84 // ---------------------------------------------------------------------
8000dacaea98 GUI: no more extra command queue for debug commands
Torsten <ttl@justmail.de>
parents: 20791
diff changeset
85 // class octave_cmd_debug
8000dacaea98 GUI: no more extra command queue for debug commands
Torsten <ttl@justmail.de>
parents: 20791
diff changeset
86
8000dacaea98 GUI: no more extra command queue for debug commands
Torsten <ttl@justmail.de>
parents: 20791
diff changeset
87 class octave_cmd_debug : public octave_cmd_exec
8000dacaea98 GUI: no more extra command queue for debug commands
Torsten <ttl@justmail.de>
parents: 20791
diff changeset
88 {
8000dacaea98 GUI: no more extra command queue for debug commands
Torsten <ttl@justmail.de>
parents: 20791
diff changeset
89 public:
8000dacaea98 GUI: no more extra command queue for debug commands
Torsten <ttl@justmail.de>
parents: 20791
diff changeset
90
8000dacaea98 GUI: no more extra command queue for debug commands
Torsten <ttl@justmail.de>
parents: 20791
diff changeset
91 octave_cmd_debug (const QString& cmd, bool suppress_location)
8000dacaea98 GUI: no more extra command queue for debug commands
Torsten <ttl@justmail.de>
parents: 20791
diff changeset
92 : octave_cmd_exec (cmd)
8000dacaea98 GUI: no more extra command queue for debug commands
Torsten <ttl@justmail.de>
parents: 20791
diff changeset
93 {
8000dacaea98 GUI: no more extra command queue for debug commands
Torsten <ttl@justmail.de>
parents: 20791
diff changeset
94 _suppress_dbg_location = suppress_location;
8000dacaea98 GUI: no more extra command queue for debug commands
Torsten <ttl@justmail.de>
parents: 20791
diff changeset
95 };
8000dacaea98 GUI: no more extra command queue for debug commands
Torsten <ttl@justmail.de>
parents: 20791
diff changeset
96
8000dacaea98 GUI: no more extra command queue for debug commands
Torsten <ttl@justmail.de>
parents: 20791
diff changeset
97 void execute ();
8000dacaea98 GUI: no more extra command queue for debug commands
Torsten <ttl@justmail.de>
parents: 20791
diff changeset
98
8000dacaea98 GUI: no more extra command queue for debug commands
Torsten <ttl@justmail.de>
parents: 20791
diff changeset
99 protected:
8000dacaea98 GUI: no more extra command queue for debug commands
Torsten <ttl@justmail.de>
parents: 20791
diff changeset
100
8000dacaea98 GUI: no more extra command queue for debug commands
Torsten <ttl@justmail.de>
parents: 20791
diff changeset
101 bool _suppress_dbg_location;
8000dacaea98 GUI: no more extra command queue for debug commands
Torsten <ttl@justmail.de>
parents: 20791
diff changeset
102 };
21028
4a7d9c335402 GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents: 21027
diff changeset
103
4a7d9c335402 GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents: 21027
diff changeset
104
4a7d9c335402 GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents: 21027
diff changeset
105 /**
4a7d9c335402 GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents: 21027
diff changeset
106 * @class octave_command_queue
4a7d9c335402 GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents: 21027
diff changeset
107 *
4a7d9c335402 GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents: 21027
diff changeset
108 * Queuing commands from the GUI for the worker thread
4a7d9c335402 GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents: 21027
diff changeset
109 */
4a7d9c335402 GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents: 21027
diff changeset
110 // ---------------------------------------------------------------------
4a7d9c335402 GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents: 21027
diff changeset
111 // class octave_command_queue: queue of octave commands
4a7d9c335402 GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents: 21027
diff changeset
112
4a7d9c335402 GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents: 21027
diff changeset
113 class octave_command_queue : QObject
4a7d9c335402 GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents: 21027
diff changeset
114 {
4a7d9c335402 GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents: 21027
diff changeset
115 Q_OBJECT;
4a7d9c335402 GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents: 21027
diff changeset
116
4a7d9c335402 GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents: 21027
diff changeset
117 public:
4a7d9c335402 GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents: 21027
diff changeset
118
4a7d9c335402 GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents: 21027
diff changeset
119 octave_command_queue (void) : QObject (),
4a7d9c335402 GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents: 21027
diff changeset
120 _queue (QList<octave_cmd *> ()),
4a7d9c335402 GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents: 21027
diff changeset
121 _processing (1),
4a7d9c335402 GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents: 21027
diff changeset
122 _queue_mutex () { };
4a7d9c335402 GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents: 21027
diff changeset
123 ~octave_command_queue (void) { };
4a7d9c335402 GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents: 21027
diff changeset
124
4a7d9c335402 GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents: 21027
diff changeset
125 /**
4a7d9c335402 GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents: 21027
diff changeset
126 * Adds a new octave command to the command queue.
4a7d9c335402 GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents: 21027
diff changeset
127 * @param cmd The octave command to be queued
4a7d9c335402 GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents: 21027
diff changeset
128 */
4a7d9c335402 GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents: 21027
diff changeset
129 void add_cmd (octave_cmd *cmd);
4a7d9c335402 GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents: 21027
diff changeset
130 /**
4a7d9c335402 GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents: 21027
diff changeset
131 * Callback routine for executing the command by the worker thread
4a7d9c335402 GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents: 21027
diff changeset
132 */
4a7d9c335402 GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents: 21027
diff changeset
133 void execute_command_callback (void);
4a7d9c335402 GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents: 21027
diff changeset
134
4a7d9c335402 GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents: 21027
diff changeset
135 private:
4a7d9c335402 GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents: 21027
diff changeset
136
4a7d9c335402 GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents: 21027
diff changeset
137 QList<octave_cmd *> _queue;
4a7d9c335402 GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents: 21027
diff changeset
138 QSemaphore _processing;
4a7d9c335402 GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents: 21027
diff changeset
139 QMutex _queue_mutex;
4a7d9c335402 GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents: 21027
diff changeset
140 };
4a7d9c335402 GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents: 21027
diff changeset
141
19773
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff changeset
142 #endif