Move layout code into separate ui file. Compile layout using uic
[vlp.git] / src / kernel / kernel.h
1 /**************************************************************
2
3   Copyright (C) 1997  Oskar Swida
4
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU General Public License
7  as published by the Free Software Foundation; either version 2
8  of the License, or (at your option) any later version.
9
10  This program is distributed in the hope that it will be useful, 
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  GNU General Public License for more details.
14
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the Free Software
17  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18
19
20
21
22  NOTE: This software is using the free software license of 
23        the QT library v.1.30 from Troll Tech AS.
24        See the file LICENSE.QT.
25
26  
27   To contact the author, write:
28      e-mail: swida@aragorn.pb.bialystok.pl
29
30 ************************************************************/
31
32 #ifndef VLP_KERNEL_H
33 #define VLP_KERNEL_H
34
35 #include <QtGui/QMainWindow>
36 #include <QtGui/QListWidget>
37 #include <QtGui/QTextEdit>
38 #include <QtCore/QSocketNotifier>
39
40 #include "comm.h"
41
42 #include "kernelwindow.h"
43
44 #define GPATH "loggr"
45 #define IPATH "logi"
46 #define NPATH "logn"
47 #define REMOTE_PATH "REMOTE"
48 #define MAXINTERP 20
49 #define MAXINSTANCES 256 
50
51
52 #define MESG_COL        0
53 #define WARN_COL        1
54 #define NORM_COL        2
55
56
57 /**
58  * Interpreter slot
59  */
60 class InterpEntry {
61 public:
62         /** Interpreter identifier */
63         int ID;
64         /** Defines if interpreter is remote or not */
65         bool remote;
66         /* Program name */
67         char fullname[255];
68         char shortname[255];
69         
70         /* Socket */
71         int sock;
72         QSocketNotifier *notify;
73         /* IDs of my remote INT modules */
74         int RInstances[MAXINSTANCES];
75         /* Parent interpreter info */
76         ctx_struct p_ctx;
77 };
78
79 /**
80  * Connection slot
81  */
82 class ConnectEntry {
83 public:
84         char addr[256];
85         
86         ConnectEntry(char *s) {
87                 strcpy(addr, s);
88         };
89 };
90
91
92 /**
93  * Kernel class
94  */
95 class QKernel : public QMainWindow, private Ui::KernelWindow {
96         Q_OBJECT
97 public:
98         QTextEdit *desktop;
99         QMenuBar *bar;
100         QMenu *programMenu;
101         QMenu *machineMenu;
102         QMenu *toolsMenu;
103         char progdir[256];
104         int NodeNumber;
105         int ConType;
106
107         QKernel();
108
109         virtual void resizeEvent(QResizeEvent *ev);
110
111         void WriteMessage(char* msg);
112         void InitMessage();
113
114 public slots:
115         void n_impl();
116         void AddAddress();
117         void DelAddress();
118         void NetMessage();
119         void IntMessage(int);
120
121 protected:
122         virtual void closeEvent (QCloseEvent * e);
123
124 private:
125         QList<InterpEntry*> Interpreters;
126         QList<ConnectEntry*> ConnectList;
127         QListWidget *connections;
128         
129         /**
130          * number of working interpreters
131          * @attention Currently not in use
132          */
133         int Tasks;
134         
135         /**
136          * number of connected VLPs
137          */
138         int ActiveConnections;
139         /**
140          * Indicates state of the Kernel Program. Is it locked or not.
141          */
142         bool LOCKED;
143         bool synchro;
144         bool wait_for_info;
145         char LockPasswd[25];
146         QAction * quitAction;
147         
148         int net_sock;
149         int freeINTid;
150         QSocketNotifier *Net_Notify;
151         char HomeDir[255];
152         bool info_messages;
153
154         void LoadConfig(char *);
155         void RunGraphModule(char*);
156         void RunNetModule();
157         InterpEntry *findINTbySocket(int);
158         InterpEntry *findINTbyID(int);
159         InterpEntry *RunIntModule(char *ss, int r);
160         void RemoteInstance(InterpEntry*, int);
161         void CloseInstances(InterpEntry*);
162
163         /**
164          * Sets QKernel menu entries to the given status
165          * @param locked status which will be set on the menu entries.
166          */
167         void setLocked(bool locked);
168
169 private slots:
170         void on_actionExecute_triggered();
171         void on_actionKill_triggered();
172         void on_actionQuit_triggered();
173         
174         void on_actionMessage_triggered();
175         void on_actionConnect_triggered();
176         void on_actionDisconnect_triggered();
177         void on_actionInfo_triggered();
178
179         void on_actionEditor_triggered();
180         void on_actionHelp_triggered();
181         void on_actionOptions_triggered();
182         void on_actionInfo_messages_triggered();
183         void on_actionLock_console_triggered();
184         void on_actionUnlock_console_triggered();
185 };
186
187 #endif /* VLP_KERNEL_H */