comparison gui/src/OctaveLink.h @ 13501:86d6c3b90ad7

Added new gui files.
author Jacob Dawid <jacob.dawid@googlemail.com>
date Sun, 17 Jul 2011 17:45:05 +0200
parents
children 13e3d60aff2d
comparison
equal deleted inserted replaced
13500:40bd465b6c79 13501:86d6c3b90ad7
1 /*
2 *
3 * Copyright (C) 2007, 2008, 2009 John P. Swensen
4 *
5 * Quint - A graphical user interface for Octave
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>
78 #include <QVector>
79 #include <QSemaphore>
80 #include <QObject>
81
82 typedef symbol_table::symbol_record SymbolRecord;
83 typedef octave_value OctaveValue;
84
85 /**
86 * \class OctaveLink
87 * Manages a link to an octave instance.
88 */
89 class OctaveLink : QObject
90 {
91 Q_OBJECT
92 public:
93 static OctaveLink *instance() { return &m_singleton; }
94 static int readlineEventHook(void);
95 static QString octaveValueAsQString(OctaveValue octaveValue);
96
97 /**
98 * Returns a copy of the current symbol table buffer.
99 * \return Copy of the current symbol table buffer.
100 */
101 QList<SymbolRecord> currentSymbolTable();
102
103 /**
104 * Returns a copy of the current history buffer.
105 * \return Copy of the current history buffer.
106 */
107 string_vector currentHistory();
108
109 void processOctaveServerData();
110
111 /**
112 * Updates the current symbol table with new data
113 * from octave.
114 */
115 void fetchSymbolTable();
116
117 /**
118 * Updates the current history buffer with new data
119 * from octave.
120 */
121 void fetchHistory();
122
123 signals:
124 void symbolTableChanged();
125 void historyChanged();
126
127 private:
128 OctaveLink();
129 ~OctaveLink();
130
131 /** Variable related member variables. */
132 QSemaphore *m_symbolTableSemaphore;
133 QList<SymbolRecord> m_symbolTableBuffer;
134
135 /** History related member variables. */
136 QSemaphore *m_historySemaphore;
137 string_vector m_historyBuffer;
138 int m_previousHistoryLength;
139
140 static OctaveLink m_singleton;
141 };
142 #endif // OCTAVELINK_H
143