Documentation fixes
[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 #include <QtCore/QDir>
40
41 #include "comm.h"
42
43 #include "ui/KernelWindow.h"
44
45 #define GPATH "loggr"
46 #define IPATH "logi"
47 #define NPATH "logn"
48 #define REMOTE_PATH "REMOTE"
49 #define MAXINTERP 20
50 #define MAXINSTANCES 256 
51
52
53 #define MESG_COL        0
54 #define WARN_COL        1
55 #define NORM_COL        2
56
57 /**
58  * @file
59  */
60
61 namespace loglan {
62 namespace vlp {
63
64 /**
65  * Interpreter slot
66  */
67 class InterpEntry {
68 public:
69         /** Interpreter identifier */
70         int ID;
71         /** Defines if interpreter is remote or not */
72         bool remote;
73         /* Program name */
74         char fullname[255];
75         char shortname[255];
76         
77         /* Socket */
78         int sock;
79         QSocketNotifier *notify;
80         /* IDs of my remote INT modules */
81         int RInstances[MAXINSTANCES];
82         /* Parent interpreter info */
83         ctx_struct p_ctx;
84 };
85
86 /**
87  * Connection slot
88  */
89 class ConnectEntry {
90 public:
91         char addr[256];
92
93         ConnectEntry(char *s) {
94                 strcpy(addr, s);
95         };
96
97         ConnectEntry(const char *s) {
98                 strcpy(addr, s);
99         };
100 };
101
102
103 /**
104  * Kernel class
105  */
106 class QKernel : public QMainWindow, private Ui::KernelWindow {
107         Q_OBJECT
108 public:
109         QMenu *toolsMenu;
110         char progdir[256];
111         int NodeNumber;
112         int ConType;
113
114         QKernel(int argc, char **argv);
115
116         void WriteMessage(const char * msg);
117
118 public slots:
119         void NetMessage();
120         void IntMessage(int);
121
122 protected:
123         virtual void closeEvent (QCloseEvent * e);
124
125 private:
126         QList<InterpEntry*> Interpreters;
127         QList<ConnectEntry*> ConnectList;
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         
147         int net_sock;
148         int freeINTid;
149         QSocketNotifier *Net_Notify;
150         QDir homeDir;
151         char myargs[5][255];
152         bool info_messages;
153
154         void loadConfig(const QString &fname);
155         void loadConfig(const char *);
156
157         void RunGraphModule(char*);
158         void RunNetModule();
159         InterpEntry *findINTbySocket(int);
160         InterpEntry *findINTbyID(int);
161         InterpEntry *RunIntModule(char *ss, int r);
162         void RemoteInstance(InterpEntry*, int);
163         void CloseInstances(InterpEntry*);
164
165         /**
166          * Sets QKernel menu entries to the given status
167          * @param locked status which will be set on the menu entries.
168          */
169         void setLocked(bool locked);
170
171         QString getConfigFilePath();
172         const char * getHomeDir();
173         const char * getRemoteDir();
174
175         const char * getNetModuleSocket();
176         const char * getGraphModuleSocket();
177
178 private slots:
179         void on_actionExecute_triggered();
180         void on_actionKill_triggered();
181         void on_actionQuit_triggered();
182         
183         void on_actionMessage_triggered();
184         void on_actionConnect_triggered();
185         void on_actionDisconnect_triggered();
186         void on_actionInfo_triggered();
187
188         void on_actionEditor_triggered();
189         void on_actionHelp_triggered();
190         void on_actionOptions_triggered();
191         void on_actionInfo_messages_triggered();
192         void on_actionLock_console_triggered();
193         void on_actionUnlock_console_triggered();
194 };
195
196 }
197 }
198
199 #endif /* VLP_KERNEL_H */