Mercurial > octave-nkf
changeset 13543:8d529f8103dc
Separated backend files to folder.
author | Jacob Dawid <jacob.dawid@googlemail.com> |
---|---|
date | Tue, 26 Jul 2011 23:15:38 +0200 |
parents | 5b168bbd6044 |
children | 81eef7babeb5 |
files | gui/octave-gui.pro gui/src/OctaveCallbackThread.cpp gui/src/OctaveCallbackThread.h gui/src/OctaveLink.cpp gui/src/OctaveLink.h gui/src/OctaveMainThread.cpp gui/src/OctaveMainThread.h gui/src/backend/OctaveCallbackThread.cpp gui/src/backend/OctaveCallbackThread.h gui/src/backend/OctaveLink.cpp gui/src/backend/OctaveLink.h gui/src/backend/OctaveMainThread.cpp gui/src/backend/OctaveMainThread.h |
diffstat | 13 files changed, 462 insertions(+), 390 deletions(-) [+] |
line wrap: on
line diff
--- a/gui/octave-gui.pro Tue Jul 26 23:05:37 2011 +0200 +++ b/gui/octave-gui.pro Tue Jul 26 23:15:38 2011 +0200 @@ -34,7 +34,7 @@ } # Includepaths and libraries to link against: -INCLUDEPATH += src src/terminal src/qirc +INCLUDEPATH += src src/terminal src/qirc src/backend INCFLAGS += $$system(mkoctfile -p INCFLAGS) mac { INCFLAGS += -I/opt/local-native/include @@ -71,7 +71,6 @@ src/terminal/ShellCommand.cpp \ src/terminal/QTerminalWidget.cpp \ src/MainWindow.cpp \ - src/OctaveLink.cpp \ src/terminal/ProcessInfo.cpp \ src/OctaveTerminal.cpp \ src/VariablesDockWidget.cpp \ @@ -87,8 +86,9 @@ src/OctaveGUI.cpp \ src/ResourceManager.cpp \ src/CommandLineParser.cpp \ - src/OctaveMainThread.cpp \ - src/OctaveCallbackThread.cpp + src/backend/OctaveCallbackThread.cpp \ + src/backend/OctaveLink.cpp \ + src/backend/OctaveMainThread.cpp HEADERS += \ src/terminal/TerminalCharacterDecoder.h \ @@ -117,7 +117,6 @@ src/terminal/ShellCommand.h \ src/terminal/QTerminalWidget.h \ src/MainWindow.h \ - src/OctaveLink.h \ src/terminal/ProcessInfo.h \ src/OctaveTerminal.h \ src/VariablesDockWidget.h \ @@ -133,8 +132,9 @@ src/SettingsDialog.h \ src/ResourceManager.h \ src/CommandLineParser.h \ - src/OctaveMainThread.h \ - src/OctaveCallbackThread.h + src/backend/OctaveCallbackThread.h \ + src/backend/OctaveLink.h \ + src/backend/OctaveMainThread.h FORMS += \ src/SettingsDialog.ui
--- a/gui/src/OctaveCallbackThread.cpp Tue Jul 26 23:05:37 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,17 +0,0 @@ -#include "OctaveCallbackThread.h" -#include "MainWindow.h" - -OctaveCallbackThread::OctaveCallbackThread (QObject * parent):QThread (parent) -{ -} - -void -OctaveCallbackThread::run () -{ - while (1) - { - OctaveLink::instance ()->fetchSymbolTable (); - OctaveLink::instance ()->updateHistoryModel (); - usleep (500000); - } -}
--- a/gui/src/OctaveCallbackThread.h Tue Jul 26 23:05:37 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,16 +0,0 @@ -#ifndef OCTAVECALLBACKTHREAD_H -#define OCTAVECALLBACKTHREAD_H - -#include <QThread> - -class OctaveCallbackThread:public QThread -{ - Q_OBJECT -public: - OctaveCallbackThread (QObject * parent); -protected: - void run (); - -}; - -#endif // OCTAVECALLBACKTHREAD_H
--- a/gui/src/OctaveLink.cpp Tue Jul 26 23:05:37 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,166 +0,0 @@ -/* - -Copyright (C) 2007,2008,2009 John P. Swensen -Copyright (C) 2010, 2011 Jacob Dawid - -Octave is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -Octave is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with Octave; see the file COPYING. If not, write to the Free -Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301, USA. - -*/ - -#include "OctaveLink.h" - -OctaveLink OctaveLink::m_singleton; - -OctaveLink::OctaveLink ():QObject () -{ - m_symbolTableSemaphore = new QSemaphore (1); - m_historyModel = new QStringListModel (this); -} - -OctaveLink::~OctaveLink () -{ -} - -QString -OctaveLink::octaveValueAsQString (OctaveValue octaveValue) -{ - // Convert single qouted string. - if (octaveValue.is_sq_string ()) - { - return QString ("\'%1\'").arg (octaveValue.string_value ().c_str ()); - - // Convert double qouted string. - } - else if (octaveValue.is_dq_string ()) - { - return QString ("\"%1\"").arg (octaveValue.string_value ().c_str ()); - - // Convert real scalar. - } - else if (octaveValue.is_real_scalar ()) - { - return QString ("%1").arg (octaveValue.scalar_value ()); - - // Convert complex scalar. - } - else if (octaveValue.is_complex_scalar ()) - { - return QString ("%1 + %2i").arg (octaveValue.scalar_value ()). - arg (octaveValue.complex_value ().imag ()); - - // Convert range. - } - else if (octaveValue.is_range ()) - { - return QString ("%1 : %2 : %3").arg (octaveValue.range_value (). - base ()).arg (octaveValue. - range_value (). - inc ()). - arg (octaveValue.range_value ().limit ()); - - // Convert real matrix. - } - else if (octaveValue.is_real_matrix ()) - { - // TODO: Convert real matrix into a string. - return QString ("{matrix}"); - - // Convert complex matrix. - } - else if (octaveValue.is_complex_matrix ()) - { - // TODO: Convert complex matrix into a string. - return QString ("{complex matrix}"); - - // If everything else does not fit, we could not recognize the type. - } - else - { - return QString ("<Type not recognized>"); - } -} - -void -OctaveLink::launchOctave () -{ - m_octaveMainThread = new OctaveMainThread (this); - m_octaveMainThread->start (); - - m_octaveCallbackThread = new OctaveCallbackThread (this); - connect (m_octaveMainThread, SIGNAL(ready()), m_octaveCallbackThread, SLOT(start())); -} - -void -OctaveLink::terminateOctave () -{ - m_octaveCallbackThread->terminate (); - m_octaveCallbackThread->wait (); - - m_octaveMainThread->terminate (); - m_octaveMainThread->wait(); -} - -void -OctaveLink::fetchSymbolTable () -{ - m_symbolTableSemaphore->acquire (); - m_symbolTableBuffer.clear (); - std::list < SymbolRecord > allVariables = symbol_table::all_variables (); - std::list < SymbolRecord >::iterator iterator; - for (iterator = allVariables.begin (); iterator != allVariables.end (); - iterator++) - m_symbolTableBuffer.append (iterator->dup ()); - m_symbolTableSemaphore->release (); - emit symbolTableChanged (); -} - -QList < SymbolRecord > OctaveLink::copyCurrentSymbolTable () -{ - QList < SymbolRecord > m_symbolTableCopy; - - // Generate a deep copy of the current symbol table. - m_symbolTableSemaphore->acquire (); - foreach (SymbolRecord symbolRecord, m_symbolTableBuffer) - m_symbolTableCopy.append (symbolRecord.dup ()); - m_symbolTableSemaphore->release (); - - return m_symbolTableCopy; -} - - -void -OctaveLink::updateHistoryModel () -{ - // Determine the client's (our) history length and the one of the server. - int clientHistoryLength = m_historyModel->rowCount (); - int serverHistoryLength = command_history::length (); - - // If were behind the server, iterate through all new entries and add them to our history. - if (clientHistoryLength < serverHistoryLength) - { - for (int i = clientHistoryLength; i < serverHistoryLength; i++) - { - m_historyModel->insertRow (0); - m_historyModel->setData (m_historyModel->index (0), QString (command_history::get_entry (i).c_str ())); - } - } -} - -QStringListModel * -OctaveLink::historyModel () -{ - return m_historyModel; -}
--- a/gui/src/OctaveLink.h Tue Jul 26 23:05:37 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,149 +0,0 @@ -/* - * - * Copyright (C) 2007, 2008, 2009 John P. Swensen - * - * OctaveGUI - A graphical user interface for Octave - * Copyright (C) 2011 Jacob Dawid - * jacob.dawid@googlemail.com - * This file is as a part of OctaveDE. - * - * Octave is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. - * - * Octave is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * along with Octave; see the file COPYING. If not, write to the Free - * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - * - * */ - -#ifndef OCTAVELINK_H -#define OCTAVELINK_H - -// Octave includes -#undef PACKAGE_BUGREPORT -#undef PACKAGE_NAME -#undef PACKAGE_STRING -#undef PACKAGE_TARNAME -#undef PACKAGE_VERSION -#undef PACKAGE_URL -#include <octave/config.h> -#include "octave/cmd-edit.h" -#include "octave/error.h" -#include "octave/file-io.h" -#include "octave/input.h" -#include "octave/lex.h" -#include "octave/load-path.h" -#include "octave/octave.h" -#include "octave/oct-hist.h" -#include "octave/oct-map.h" -#include "octave/oct-obj.h" -#include "octave/ops.h" -#include "octave/ov.h" -#include "octave/ov-usr-fcn.h" -#include "octave/symtab.h" -#include "octave/pt.h" -#include "octave/pt-eval.h" -#include "octave/config.h" -#include "octave/Range.h" -#include "octave/toplev.h" -#include "octave/procstream.h" -#include "octave/sighandlers.h" -#include "octave/debug.h" -#include "octave/sysdep.h" -#include "octave/ov.h" -#include "octave/unwind-prot.h" -#include "octave/utils.h" -#include "octave/variables.h" - -// Standard includes -#include <iostream> -#include <string> -#include <vector> -#include <readline/readline.h> - -// Qt includes -#include <QMutexLocker> -#include <QMutex> -#include <QFileInfo> -#include <QList> -#include <QString> -#include <QStringList> -#include <QVector> -#include <QSemaphore> -#include <QObject> -#include <QStringListModel> - -#include "OctaveCallbackThread.h" -#include "OctaveMainThread.h" - -typedef symbol_table::symbol_record SymbolRecord; -typedef octave_value OctaveValue; - -/** - * \class OctaveLink - * Manages a link to an octave instance. - */ -class OctaveLink:public QObject -{ - Q_OBJECT -public: - static OctaveLink * - instance () - { - return &m_singleton; - } - static QString - octaveValueAsQString (OctaveValue octaveValue); - - void launchOctave (); - void terminateOctave (); - - /** - * Returns a copy of the current symbol table buffer. - * \return Copy of the current symbol table buffer. - */ - QList < SymbolRecord > copyCurrentSymbolTable (); - - void - updateHistoryModel (); - - QStringListModel * - historyModel (); - - /** - * Updates the current symbol table with new data - * from octave. - */ - void - fetchSymbolTable (); - -signals: - void - symbolTableChanged (); - -private: - OctaveLink (); - ~OctaveLink (); - - /** Variable related member variables. */ - QSemaphore * m_symbolTableSemaphore; - QList < SymbolRecord > m_symbolTableBuffer; - - /** History related member variables. */ - QStringListModel *m_historyModel; - - // Threads for running octave and managing the data interaction. - OctaveMainThread *m_octaveMainThread; - OctaveCallbackThread *m_octaveCallbackThread; - - static OctaveLink m_singleton; -}; -#endif // OCTAVELINK_H
--- a/gui/src/OctaveMainThread.cpp Tue Jul 26 23:05:37 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,17 +0,0 @@ -#include "OctaveMainThread.h" -#include "OctaveLink.h" - -OctaveMainThread::OctaveMainThread (QObject * parent):QThread (parent) -{ -} - -void -OctaveMainThread::run () -{ - int argc = 3; - const char *argv[] = { "octave", "--interactive", "--line-editing" }; - octave_main (argc, (char **) argv, 1); - emit ready(); - main_loop (); - clean_up_and_exit (0); -}
--- a/gui/src/OctaveMainThread.h Tue Jul 26 23:05:37 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,18 +0,0 @@ -#ifndef OCTAVEMAINTHREAD_H -#define OCTAVEMAINTHREAD_H - -#include <QThread> -class OctaveMainThread:public QThread -{ - Q_OBJECT -public: - OctaveMainThread (QObject * parent); - -signals: - void ready(); - -protected: - void run (); -}; - -#endif // OCTAVEMAINTHREAD_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/backend/OctaveCallbackThread.cpp Tue Jul 26 23:15:38 2011 +0200 @@ -0,0 +1,35 @@ +/* OctaveGUI - A graphical user interface for Octave + * Copyright (C) 2011 Jacob Dawid + * jacob.dawid@googlemail.com + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "OctaveCallbackThread.h" +#include "MainWindow.h" + +OctaveCallbackThread::OctaveCallbackThread (QObject * parent):QThread (parent) +{ +} + +void +OctaveCallbackThread::run () +{ + while (1) + { + OctaveLink::instance ()->fetchSymbolTable (); + OctaveLink::instance ()->updateHistoryModel (); + usleep (500000); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/backend/OctaveCallbackThread.h Tue Jul 26 23:15:38 2011 +0200 @@ -0,0 +1,34 @@ +/* OctaveGUI - A graphical user interface for Octave + * Copyright (C) 2011 Jacob Dawid + * jacob.dawid@googlemail.com + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef OCTAVECALLBACKTHREAD_H +#define OCTAVECALLBACKTHREAD_H + +#include <QThread> + +class OctaveCallbackThread:public QThread +{ + Q_OBJECT +public: + OctaveCallbackThread (QObject * parent); +protected: + void run (); + +}; + +#endif // OCTAVECALLBACKTHREAD_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/backend/OctaveLink.cpp Tue Jul 26 23:15:38 2011 +0200 @@ -0,0 +1,166 @@ +/* + +Copyright (C) 2007,2008,2009 John P. Swensen +Copyright (C) 2010, 2011 Jacob Dawid + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, write to the Free +Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301, USA. + +*/ + +#include "OctaveLink.h" + +OctaveLink OctaveLink::m_singleton; + +OctaveLink::OctaveLink ():QObject () +{ + m_symbolTableSemaphore = new QSemaphore (1); + m_historyModel = new QStringListModel (this); +} + +OctaveLink::~OctaveLink () +{ +} + +QString +OctaveLink::octaveValueAsQString (OctaveValue octaveValue) +{ + // Convert single qouted string. + if (octaveValue.is_sq_string ()) + { + return QString ("\'%1\'").arg (octaveValue.string_value ().c_str ()); + + // Convert double qouted string. + } + else if (octaveValue.is_dq_string ()) + { + return QString ("\"%1\"").arg (octaveValue.string_value ().c_str ()); + + // Convert real scalar. + } + else if (octaveValue.is_real_scalar ()) + { + return QString ("%1").arg (octaveValue.scalar_value ()); + + // Convert complex scalar. + } + else if (octaveValue.is_complex_scalar ()) + { + return QString ("%1 + %2i").arg (octaveValue.scalar_value ()). + arg (octaveValue.complex_value ().imag ()); + + // Convert range. + } + else if (octaveValue.is_range ()) + { + return QString ("%1 : %2 : %3").arg (octaveValue.range_value (). + base ()).arg (octaveValue. + range_value (). + inc ()). + arg (octaveValue.range_value ().limit ()); + + // Convert real matrix. + } + else if (octaveValue.is_real_matrix ()) + { + // TODO: Convert real matrix into a string. + return QString ("{matrix}"); + + // Convert complex matrix. + } + else if (octaveValue.is_complex_matrix ()) + { + // TODO: Convert complex matrix into a string. + return QString ("{complex matrix}"); + + // If everything else does not fit, we could not recognize the type. + } + else + { + return QString ("<Type not recognized>"); + } +} + +void +OctaveLink::launchOctave () +{ + m_octaveMainThread = new OctaveMainThread (this); + m_octaveMainThread->start (); + + m_octaveCallbackThread = new OctaveCallbackThread (this); + connect (m_octaveMainThread, SIGNAL(ready()), m_octaveCallbackThread, SLOT(start())); +} + +void +OctaveLink::terminateOctave () +{ + m_octaveCallbackThread->terminate (); + m_octaveCallbackThread->wait (); + + m_octaveMainThread->terminate (); + m_octaveMainThread->wait(); +} + +void +OctaveLink::fetchSymbolTable () +{ + m_symbolTableSemaphore->acquire (); + m_symbolTableBuffer.clear (); + std::list < SymbolRecord > allVariables = symbol_table::all_variables (); + std::list < SymbolRecord >::iterator iterator; + for (iterator = allVariables.begin (); iterator != allVariables.end (); + iterator++) + m_symbolTableBuffer.append (iterator->dup ()); + m_symbolTableSemaphore->release (); + emit symbolTableChanged (); +} + +QList < SymbolRecord > OctaveLink::copyCurrentSymbolTable () +{ + QList < SymbolRecord > m_symbolTableCopy; + + // Generate a deep copy of the current symbol table. + m_symbolTableSemaphore->acquire (); + foreach (SymbolRecord symbolRecord, m_symbolTableBuffer) + m_symbolTableCopy.append (symbolRecord.dup ()); + m_symbolTableSemaphore->release (); + + return m_symbolTableCopy; +} + + +void +OctaveLink::updateHistoryModel () +{ + // Determine the client's (our) history length and the one of the server. + int clientHistoryLength = m_historyModel->rowCount (); + int serverHistoryLength = command_history::length (); + + // If were behind the server, iterate through all new entries and add them to our history. + if (clientHistoryLength < serverHistoryLength) + { + for (int i = clientHistoryLength; i < serverHistoryLength; i++) + { + m_historyModel->insertRow (0); + m_historyModel->setData (m_historyModel->index (0), QString (command_history::get_entry (i).c_str ())); + } + } +} + +QStringListModel * +OctaveLink::historyModel () +{ + return m_historyModel; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/backend/OctaveLink.h Tue Jul 26 23:15:38 2011 +0200 @@ -0,0 +1,149 @@ +/* + * + * Copyright (C) 2007, 2008, 2009 John P. Swensen + * + * OctaveGUI - A graphical user interface for Octave + * Copyright (C) 2011 Jacob Dawid + * jacob.dawid@googlemail.com + * This file is as a part of OctaveDE. + * + * Octave is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * Octave is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * along with Octave; see the file COPYING. If not, write to the Free + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + * + * */ + +#ifndef OCTAVELINK_H +#define OCTAVELINK_H + +// Octave includes +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION +#undef PACKAGE_URL +#include <octave/config.h> +#include "octave/cmd-edit.h" +#include "octave/error.h" +#include "octave/file-io.h" +#include "octave/input.h" +#include "octave/lex.h" +#include "octave/load-path.h" +#include "octave/octave.h" +#include "octave/oct-hist.h" +#include "octave/oct-map.h" +#include "octave/oct-obj.h" +#include "octave/ops.h" +#include "octave/ov.h" +#include "octave/ov-usr-fcn.h" +#include "octave/symtab.h" +#include "octave/pt.h" +#include "octave/pt-eval.h" +#include "octave/config.h" +#include "octave/Range.h" +#include "octave/toplev.h" +#include "octave/procstream.h" +#include "octave/sighandlers.h" +#include "octave/debug.h" +#include "octave/sysdep.h" +#include "octave/ov.h" +#include "octave/unwind-prot.h" +#include "octave/utils.h" +#include "octave/variables.h" + +// Standard includes +#include <iostream> +#include <string> +#include <vector> +#include <readline/readline.h> + +// Qt includes +#include <QMutexLocker> +#include <QMutex> +#include <QFileInfo> +#include <QList> +#include <QString> +#include <QStringList> +#include <QVector> +#include <QSemaphore> +#include <QObject> +#include <QStringListModel> + +#include "OctaveCallbackThread.h" +#include "OctaveMainThread.h" + +typedef symbol_table::symbol_record SymbolRecord; +typedef octave_value OctaveValue; + +/** + * \class OctaveLink + * Manages a link to an octave instance. + */ +class OctaveLink:public QObject +{ + Q_OBJECT +public: + static OctaveLink * + instance () + { + return &m_singleton; + } + static QString + octaveValueAsQString (OctaveValue octaveValue); + + void launchOctave (); + void terminateOctave (); + + /** + * Returns a copy of the current symbol table buffer. + * \return Copy of the current symbol table buffer. + */ + QList < SymbolRecord > copyCurrentSymbolTable (); + + void + updateHistoryModel (); + + QStringListModel * + historyModel (); + + /** + * Updates the current symbol table with new data + * from octave. + */ + void + fetchSymbolTable (); + +signals: + void + symbolTableChanged (); + +private: + OctaveLink (); + ~OctaveLink (); + + /** Variable related member variables. */ + QSemaphore * m_symbolTableSemaphore; + QList < SymbolRecord > m_symbolTableBuffer; + + /** History related member variables. */ + QStringListModel *m_historyModel; + + // Threads for running octave and managing the data interaction. + OctaveMainThread *m_octaveMainThread; + OctaveCallbackThread *m_octaveCallbackThread; + + static OctaveLink m_singleton; +}; +#endif // OCTAVELINK_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/backend/OctaveMainThread.cpp Tue Jul 26 23:15:38 2011 +0200 @@ -0,0 +1,35 @@ +/* OctaveGUI - A graphical user interface for Octave + * Copyright (C) 2011 Jacob Dawid + * jacob.dawid@googlemail.com + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "OctaveMainThread.h" +#include "OctaveLink.h" + +OctaveMainThread::OctaveMainThread (QObject * parent):QThread (parent) +{ +} + +void +OctaveMainThread::run () +{ + int argc = 3; + const char *argv[] = { "octave", "--interactive", "--line-editing" }; + octave_main (argc, (char **) argv, 1); + emit ready(); + main_loop (); + clean_up_and_exit (0); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/backend/OctaveMainThread.h Tue Jul 26 23:15:38 2011 +0200 @@ -0,0 +1,36 @@ +/* OctaveGUI - A graphical user interface for Octave + * Copyright (C) 2011 Jacob Dawid + * jacob.dawid@googlemail.com + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef OCTAVEMAINTHREAD_H +#define OCTAVEMAINTHREAD_H + +#include <QThread> +class OctaveMainThread:public QThread +{ + Q_OBJECT +public: + OctaveMainThread (QObject * parent); + +signals: + void ready(); + +protected: + void run (); +}; + +#endif // OCTAVEMAINTHREAD_H