VLP-28 Moved kernel class declarations to the header file. Code refactor.
[vlp.git] / src / kernel / kernel.h
diff --git a/src/kernel/kernel.h b/src/kernel/kernel.h
new file mode 100644 (file)
index 0000000..168777c
--- /dev/null
@@ -0,0 +1,192 @@
+/**************************************************************
+
+  Copyright (C) 1997  Oskar Swida
+
+ 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 2
+ 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, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+
+
+
+ NOTE: This software is using the free software license of 
+       the QT library v.1.30 from Troll Tech AS.
+       See the file LICENSE.QT.
+
+  To contact the author, write:
+     e-mail: swida@aragorn.pb.bialystok.pl
+
+************************************************************/
+
+#ifndef VLP_KERNEL_H
+#define VLP_KERNEL_H
+
+#include <QtGui/QMainWindow>
+#include <QtGui/QListWidget>
+#include <QtGui/QTextEdit>
+#include <QtCore/QSocketNotifier>
+
+#include "comm.h"
+
+#define GPATH "loggr"
+#define IPATH "logi"
+#define NPATH "logn"
+#define REMOTE_PATH "REMOTE"
+#define MAXINTERP 20
+#define MAXINSTANCES 256 
+
+
+#define MESG_COL       0
+#define WARN_COL       1
+#define NORM_COL       2
+
+
+/**
+ * Interpreter slot
+ */
+class InterpEntry {
+public:
+       /** Interpreter identifier */
+       int ID;
+       /** Defines if interpreter is remote or not */
+       bool remote;
+       /* Program name */
+       char fullname[255];
+       char shortname[255];
+       
+       /* Socket */
+       int sock;
+       QSocketNotifier *notify;
+       /* IDs of my remote INT modules */
+       int RInstances[MAXINSTANCES];
+       /* Parent interpreter info */
+       ctx_struct p_ctx;
+};
+
+/**
+ * Connection slot
+ */
+class ConnectEntry {
+public:
+       char addr[256];
+       
+       ConnectEntry(char *s) {
+               strcpy(addr, s);
+       };
+};
+
+
+/**
+ * Kernel class
+ */
+class QKernel : public QMainWindow {
+       Q_OBJECT
+public:
+       QTextEdit *desktop;
+       QMenuBar *bar;
+       QMenu *programMenu;
+       QMenu *machineMenu;
+       QMenu *toolsMenu;
+       char progdir[256];
+       int NodeNumber;
+       int ConType;
+
+       QKernel();
+
+       virtual void resizeEvent(QResizeEvent *ev);
+
+       void WriteMessage(char* msg);
+       void InitMessage();
+
+public slots:
+       void n_impl();
+       void Run_Prog();
+       void Edit();
+       void Help();
+       void SetOptions();
+       void AddAddress();
+       void DelAddress();
+       void LockConsole();
+       void UnlockConsole();
+       void MessageToNode();
+       void QuitProc();
+       void NetMessage();
+       void IntMessage(int);
+       void KillInterpreter();
+       void Disconnect();
+       void SetMessages();
+       void Connect();
+       void Info();
+
+protected:
+       virtual void closeEvent (QCloseEvent * e);
+
+private:
+       QList<InterpEntry*> Interpreters;
+       QList<ConnectEntry*> ConnectList;
+       QListWidget *connections;
+       
+       /**
+        * number of working interpreters
+        * @attention Currently not in use
+        */
+       int Tasks;
+       
+       /**
+        * number of connected VLPs
+        */
+       int ActiveConnections;
+       /**
+        * Indicates state of the Kernel Program. Is it locked or not.
+        */
+       bool LOCKED;
+       bool synchro;
+       bool wait_for_info;
+       char LockPasswd[25];
+       QAction * toolsEditorAction;
+       QAction * toolsOptionsAction;
+       QAction * toolsInfoAction;
+       QAction * programExecuteAction;
+       QAction * programKillAction;
+       QAction * machineMessageAction;
+       QAction * machineConnectAction;
+       QAction * machineDisconnectAction;
+       QAction * machineInfoAction;
+       QAction * toolsLockAction;
+       QAction * toolsUnlockAction;
+       QAction * quitAction;
+       
+       int net_sock;
+       int freeINTid;
+       QSocketNotifier *Net_Notify;
+       char HomeDir[255];
+       bool info_messages;
+
+       void LoadConfig(char *);
+       void RunGraphModule(char*);
+       void RunNetModule();
+       InterpEntry *findINTbySocket(int);
+       InterpEntry *findINTbyID(int);
+       InterpEntry *RunIntModule(char *ss, int r);
+       void RemoteInstance(InterpEntry*, int);
+       void CloseInstances(InterpEntry*);
+
+       /**
+        * Sets QKernel menu entries to the given status
+        * @param locked status which will be set on the menu entries.
+        */
+       void setLocked(bool locked);
+};
+
+#endif /* VLP_KERNEL_H */