COVISE Core
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
covise_process.h
Go to the documentation of this file.
1 /* This file is part of COVISE.
2 
3  You can use it under the terms of the GNU Lesser General Public License
4  version 2.1 or later, see lgpl-2.1.txt.
5 
6  * License: LGPL 2+ */
7 
8 #ifndef EC_PROCESS_H
9 #define EC_PROCESS_H
10 
11 #include "covise.h"
12 #include <util/covise_list.h>
13 #include "covise_msg.h"
14 #include <net/covise_connect.h>
15 #ifndef NO_SIGNALS
16 #include "covise_signal.h"
17 #endif
18 
19 #ifndef _WIN32
20 #include <sys/param.h>
21 #endif
22 
23 /***********************************************************************\
24  ** **
25  ** Process classes Version: 1.5 **
26  ** **
27  ** **
28  ** Description : All classes that work as the processes own data **
29  ** and function base. Each process should make a new **
30  ** object of its appropriate class type to have **
31  ** access to the basic functionality. **
32  ** **
33  ** Classes : Process, OrdinaryProcess, ApplicationProcess, **
34  ** DataManagerProcess, UserInterfaceProcess, **
35  ** Controller, ObjectEntry **
36  ** **
37  ** Copyright (C) 1993 by University of Stuttgart **
38  ** Computer Center (RUS) **
39  ** Allmandring 30 **
40  ** 7000 Stuttgart 80 **
41  ** **
42  ** **
43  ** Author : A. Wierse (RUS) **
44  ** **
45  ** History : **
46  ** 15.04.93 Ver 1.0 **
47  ** 27.05.93 Ver 1.1 remote processstart added, **
48  ** DMEntry added, **
49  ** partial redesign **
50  ** **
51 \***********************************************************************/
52 
53 /* each process has to create a process object according to its type.
54  Process is the base class, that handles shared memory attachment.
55 
56  +-----------+
57  | Process |
58  +-----------+
59  / \
60  / \
61  +----------+ +------------+
62  | ordinary | | controller |
63  | process | | process |
64 +----------+ +------------+
65 | \ \ \
66 | \ \ \
67 | \ \ ------------------------------------
68 | \ ---------------------- \
69 | -------- \ \
70 | \ \ \
71 +-------------+ +-------------+ +---------------+ +-------------+
72 | Application | | DataManager | | UserInterface | | Transfermgr |
73 | process | | process | | process | | process |
74 +-------------+ +-------------+ +---------------+ +-------------+
75 
76 */
77 
78 #if !defined(_WIN32) && !defined(__linux__)
79 #define COVISE_Signals
80 #endif
81 
82 namespace covise
83 {
84 
85 class Connection;
86 class ConnectionList;
87 class ControllerConnection;
88 class Host;
89 class Message;
90 
91 COVISEEXPORT int execProcessWMI(const char *commandLine, const char *wd, const char *host, const char *user, const char *password);
92 
93 extern int COVISE_debug_level;
94 
95 class COVISEEXPORT Process // base class for all processes
96 {
97 protected:
98  const char *name; // name of the process
99  int id; // number which identifies each process
100  int hostid; // id of host, this process is running on
101  Host *host; // host on which it is running, initialized by IP address
102  char *covise_hostname; // official hostname sent from controller
103  sender_type send_type; // type of this process
104  ConnectionList *list_of_connections; // list of all connections
106 #ifndef _WIN32
107 #ifdef COVISE_Signals
108 #ifndef NO_SIGNALS
109 #ifdef __linux__
110 #define SignalHandler CO_SignalHandler
111 #endif
113 #endif
114 #endif
115 #endif
116 public:
117  //void add_connection(Connection *c){list_of_connections->add(c);};
118  //void remove_connection(Connection *c){list_of_connections->remove(c);};
120  {
121  return (list_of_connections);
122  };
123  static Process *this_process;
124  Process(const char *n, int i, sender_type st); // initialize
125  // initialize
126  Process(const char *n, int i, sender_type st, int port);
127  // initialize
128  Process(const char *n, int arc, char *arv[], sender_type st);
129  virtual ~Process(); // destructor
130  void init_env();
131  virtual void handle_shm_msg(Message *);
133  {
134  send_type = st;
135  };
136  Message *wait_for_msg(); // wait for a message
137  Message *check_queue();
138  Message *check_for_msg(float time = 0.0); // wait for a message
139  Message *wait_for_msg(int, Connection *); // wait for a specific message
140  // wait for specific messages
141  Message *wait_for_msg(int *, int, Connection *);
142  int get_id()
143  {
144  return id;
145  };
146  char *get_list_of_interfaces();
147  const char *getName()
148  {
149  return name;
150  };
151  const char *get_hostname(); // official COVISE controller hostname
152  Host *get_covise_host(); // COVISE_HOST environment variable based host
153  Host *get_host() // IP address based host
154  {
155  return host;
156  };
157  // int set_default_hostname(char *);
158  void covised_rexec(Host *, char *);
160  {
161  delete m;
162  };
164  {
165  return (hostid);
166  };
167 };
168 
170 {
171 protected:
173 
174 public:
175  //
176  // initialize process
177  OrdinaryProcess(const char *name, int id, sender_type st)
178  : Process(name, id, st)
179  , controller(NULL){};
180 
181  // initialize process
182  OrdinaryProcess(const char *n, int arc, char *arv[], sender_type st)
183  : Process(n, arc, arv, st)
184  , controller(NULL){};
185 
187  // delete controller;
188  }; // destructor
189  void send_ctl_msg(const Message *); // send a message to the controller
190  // build connection to the controller:
191  void send_ctl_msg(TokenBuffer); // send a Tokenbuffer to the controller
192  int get_socket_id(void (*remove_func)(int));
193  virtual void contact_controller(int, Host *)
194  {
195  abort();
196  }
197  int is_connected();
199  {
200  return controller;
201  }
202 };
203 
204 class ShmAccess;
205 
207 {
208  friend class ObjectEntry;
209  friend class DataManagerProcess;
210  access_type acc; // general access type allowed
211  access_type curr_acc; // connection to accessing process
212  Connection *conn; // access currently actually used
213 public:
215  {
216  acc = a;
217  conn = c;
218  curr_acc = c_a;
219  };
220  void print()
221  {
222  cerr << "Access: ";
223  conn->print();
224 #ifndef _WIN32
225  cerr << " = " << acc << endl;
226 #endif
227  };
228 };
229 
230 // process for the external access
232 {
233 public:
234  SimpleProcess(char *name, int arc, char *arv[]);
235  ~SimpleProcess();
236 
237 private:
238  void contact_controller(int, Host *);
239 };
240 }
241 #endif
ConnectionList * list_of_connections
Definition: covise_process.h:104
Definition: covise_host.h:17
int get_hostid()
Definition: covise_process.h:163
virtual void contact_controller(int, Host *)
Definition: covise_process.h:193
~OrdinaryProcess()
Definition: covise_process.h:186
int execProcessWMI(const char *, const char *, const char *, const char *, const char *)
Definition: covise_process.cpp:492
access_type
Definition: covise_shm.h:81
GLuint const GLchar * name
Definition: khronos-glext.h:6722
Definition: covise_connect.h:115
#define COVISEEXPORT
Definition: coExport.h:176
int COVISE_debug_level
Definition: coLog.cpp:22
Definition: covise_process.h:206
Definition: covise_process.h:231
Definition: covise_signal.h:102
GLdouble n
Definition: khronos-glext.h:8447
List< Message > * msg_queue
Definition: covise_process.h:105
OrdinaryProcess(const char *name, int id, sender_type st)
Definition: covise_process.h:177
GLenum GLuint id
Definition: khronos-glext.h:6279
int hostid
Definition: covise_process.h:100
Definition: covise_process.h:95
#define NULL
Definition: covise_list.h:22
Connection * conn
Definition: covise_process.h:212
Definition: message.h:111
ConnectionList * getConnectionList()
Definition: covise_process.h:119
const char * getName()
Definition: covise_process.h:147
const char * name
Definition: covise_process.h:98
sender_type
Definition: message_types.h:354
char * covise_hostname
Definition: covise_process.h:102
void delete_msg(Message *m)
Definition: covise_process.h:159
AccessEntry(access_type a, access_type c_a, Connection *c)
Definition: covise_process.h:214
Definition: dmgr.h:59
Definition: tokenbuffer.h:73
const GLubyte * c
Definition: khronos-glext.h:9864
GLboolean GLboolean GLboolean GLboolean a
Definition: khronos-glext.h:6895
Definition: covise_list.h:53
OrdinaryProcess(const char *n, int arc, char *arv[], sender_type st)
Definition: covise_process.h:182
access_type acc
Definition: covise_process.h:210
Definition: covise_process.h:169
ControllerConnection * controller
Definition: covise_process.h:172
Host * get_host()
Definition: covise_process.h:153
const GLfloat * m
Definition: khronos-glext.h:12117
access_type curr_acc
Definition: covise_process.h:211
Definition: covise_connect.h:289
int id
Definition: covise_process.h:99
void set_send_type(sender_type st)
Definition: covise_process.h:132
SignalHandler sig_handler
Definition: covise_process.h:112
void print()
Definition: covise_process.h:220
Definition: covise_connect.h:312
sender_type send_type
Definition: covise_process.h:103
Host * host
Definition: covise_process.h:101
ControllerConnection * getControllerConnection()
Definition: covise_process.h:198
Definition: dmgr.h:213
int get_id()
Definition: covise_process.h:142