GNU Octave  4.2.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
octave-cmd.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2014-2017 Torsten
4 
5 This file is part of Octave.
6 
7 Octave is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 // Author: Torsten <ttl@justmail.de>
24 
25 #if ! defined (octave_octave_cmd_h)
26 #define octave_octave_cmd_h 1
27 
28 #include <QSemaphore>
29 #include <QMutex>
30 #include <QString>
31 #include <QFileInfo>
32 
33 #include "octave-qt-link.h"
34 
36 {
37 public:
38 
39  octave_cmd () { };
40  virtual ~octave_cmd () { };
41 
42  virtual void execute () { };
43 };
44 
45 // ---------------------------------------------------------------------
46 // class octave_cmd_exec
47 
49 {
50 public:
51 
52  octave_cmd_exec (const QString& cmd) : octave_cmd () { _cmd = cmd; };
53  void execute ();
54 
55 protected:
56 
57  QString _cmd;
58 };
59 
60 // ---------------------------------------------------------------------
61 // class octave_cmd_eval
62 
64 {
65 public:
66 
67  octave_cmd_eval (const QFileInfo& info) : octave_cmd () { _info = info; };
68  void execute ();
69 
70 protected:
71 
72  QFileInfo _info;
73 };
74 
75 // ---------------------------------------------------------------------
76 // class octave_cmd_debug
77 
79 {
80 public:
81 
82  octave_cmd_debug (const QString& cmd, bool suppress_location)
83  : octave_cmd_exec (cmd)
84  {
85  _suppress_dbg_location = suppress_location;
86  };
87 
88  void execute ();
89 
90 protected:
91 
93 };
94 
95 /**
96  * @class octave_command_queue
97  *
98  * Queuing commands from the GUI for the worker thread
99  */
100 // ---------------------------------------------------------------------
101 // class octave_command_queue: queue of octave commands
102 
104 {
105  Q_OBJECT;
106 
107 public:
108 
110  _queue (QList<octave_cmd *> ()),
111  _processing (1),
112  _queue_mutex () { };
114 
115  /**
116  * Adds a new octave command to the command queue.
117  * @param cmd The octave command to be queued
118  */
119  void add_cmd (octave_cmd *cmd);
120  /**
121  * Callback routine for executing the command by the worker thread
122  */
123  void execute_command_callback (void);
124 
125 private:
126 
128  QSemaphore _processing;
129  QMutex _queue_mutex;
130 };
131 
132 #endif
virtual ~octave_cmd()
Definition: octave-cmd.h:40
void execute_command_callback(void)
Callback routine for executing the command by the worker thread.
Definition: octave-cmd.cc:128
octave_cmd_exec(const QString &cmd)
Definition: octave-cmd.h:52
Queuing commands from the GUI for the worker thread.
Definition: octave-cmd.h:103
octave_cmd_eval(const QFileInfo &info)
Definition: octave-cmd.h:67
virtual void execute()
Definition: octave-cmd.h:42
QFileInfo _info
Definition: octave-cmd.h:72
QSemaphore _processing
Definition: octave-cmd.h:128
octave_cmd_debug(const QString &cmd, bool suppress_location)
Definition: octave-cmd.h:82
void add_cmd(octave_cmd *cmd)
Adds a new octave command to the command queue.
Definition: octave-cmd.cc:115
QString _cmd
Definition: octave-cmd.h:57
QList< octave_cmd * > _queue
Definition: octave-cmd.h:127
bool _suppress_dbg_location
Definition: octave-cmd.h:92