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