COVISE Core
covise_msg.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 COVISE_MESSAGE_H
9#define COVISE_MESSAGE_H
10
11#include <string.h>
12#include <stdio.h>
13#include <iostream>
14
15#include <util/coExport.h>
16#include <util/byteswap.h>
17
18#include <net/message.h>
19#include <net/message_types.h>
20
21//#include <shm/covise_shm.h>
22
23#ifdef _WIN64
24#define __WORDSIZE 64
25#endif
26
27/*
28 $Log: $
29 * Revision 1.4 1994/03/23 18:07:03 zrf30125
30 * Modifications for multiple Shared Memory segments have been finished
31 * (not yet for Cray)
32 *
33 * Revision 1.3 93/10/11 09:22:19 zrhk0125
34 * new types DM_CONTACT_DM and APP_CONTACT_DM included
35 *
36 * Revision 1.2 93/10/08 19:18:06 zrhk0125
37 * data type sizes introduced
38* some fixed type sizes with sizeof calls replaced
39 *
40 * Revision 1.1 93/09/25 20:47:03 zrhk0125
41 * Initial revision
42 *
43 */
44
45/***********************************************************************\
46 ** **
47 ** Message classes Version: 1.1 **
48 ** **
49 ** **
50 ** Description : The basic message structure as well as ways to **
51 ** initialize messages easily are provided. **
52 ** Subclasses for special types of messages **
53 ** can be introduced. **
54 ** **
55 ** Classes : Message, ShmMessage **
56 ** **
57 ** Copyright (C) 1993 by University of Stuttgart **
58 ** Computer Center (RUS) **
59 ** Allmandring 30 **
60 ** 7000 Stuttgart 80 **
61 ** HOSTID **
62 ** **
63 ** Author : A. Wierse (RUS) **
64 ** **
65 ** History : **
66 ** 15.04.93 Ver 1.0 **
67 ** 15.04.93 Ver 1.1 new Messages and type added **
68 ** sender and send_type added **
69 ** **
70 ** **
71\***********************************************************************/
72
73namespace covise
74{
75
76class DataManagerProcess;
77class coShmPtr;
78
80{
82 VIRVO
83};
84
85typedef long data_type;
86
87class COVISEEXPORT ShmMessage : public Message // message especially for memory allocation
88{
89public: // at the datamanager
90 ShmMessage(coShmPtr *ptr);
91 // constructor with encoding into data field:
93 : Message()
94 {
95 conn = NULL;
97 int l = sizeof(data_type) + sizeof(long);
98 data = DataHandle(l);
99 *(data_type *)data.accessData() = d;
100 *(long *)(&data.accessData()[sizeof(data_type)]) = count;
101 };
102 ShmMessage(data_type *d, long *count, int no);
103 ShmMessage(char *n, int t, data_type *d, long *count, int no);
105 : Message(){};
106 // ~ShmMessage() {
107 // delete [] data;
108 // data = NULL;
109 // }; // destructor
112 data_type get_data_type() // data type of msg
113 {
114 return *(data_type *)data.data();
115 };
116 long get_count() // length of msg
117 {
118 return *(long *)(data.data() + sizeof(data_type));
119 };
121 {
123 return *(int *)(data.data());
124 else
125 return -1;
126 };
128 {
130 return *(int *)(data.data() + sizeof(data_type));
131 else
132 return -1;
133 };
134};
135
137{
138 friend class CtlMessage;
139 char *name = nullptr;
140 int type;
141 int no;
142
143public:
144 Param(const char *na, int t, int n)
145 {
146 name = new char[strlen(na) + 1];
147 strcpy(name, na);
148 type = t;
149 no = n;
150 }
151 char *getName() const
152 {
153 return name;
154 }
156 {
157 return no;
158 }
160 {
161 return type;
162 }
163 virtual ~Param()
164 {
165 delete[] name;
166 }
167};
168
170{
171 friend class CtlMessage;
172 char *list = nullptr;
173
174public:
175 ParamFloatScalar(const char *na, char *l);
176 ParamFloatScalar(const char *na, float val);
178 {
179 delete[] list;
180 }
181};
182
184{
185 friend class CtlMessage;
186 char *list = nullptr;
187
188public:
189 ParamIntScalar(const char *na, char *l);
190 ParamIntScalar(const char *na, long val);
192};
193
195{
196 friend class CtlMessage;
197 char **list = nullptr;
198
199public:
200 ParamFloatVector(const char *na, int num, char **l);
201 ParamFloatVector(const char *na, int num, float *l);
203};
204
206{
207 friend class CtlMessage;
208 char **list = nullptr;
209
210public:
211 ParamIntVector(const char *na, int num, char **l);
212 ParamIntVector(const char *na, int num, long *l);
214};
215
217{
218 friend class CtlMessage;
219 char *list = nullptr;
220
221public:
222 ParamBrowser(const char *na, char *l);
223 /*ParamBrowser(const char *na, char *file, char *wildcard) : Param(na, BROWSER, 2)
224 {
225 list = new char *[2];
226 list[0] = new char[ strlen(file)+1];
227 strcpy(list[0],file);
228 list[1] = new char[ strlen(wildcard)+1];
229 strcpy(list[1],wildcard);
230 }*/
232};
233
235{
236 friend class CtlMessage;
237 char *list;
238
239public:
240 ParamString(const char *na, char *l);
242 {
243 return (char *)strlen(list);
244 };
245 ~ParamString();
246};
247
249{
250 friend class CtlMessage;
251 char **list = nullptr;
254
255public:
256 ParamText(const char *na, char **l, int lineno, int len);
258 {
259 return line_num;
260 };
262 {
263 return length;
264 };
265 ~ParamText();
266};
267
269{
270 friend class CtlMessage;
271 char *list = nullptr;
272
273public:
274 ParamBoolean(const char *na, char *l);
275 ParamBoolean(const char *na, int val);
277};
278
280{
281 friend class CtlMessage;
282 char **list = nullptr;
283
284public:
285 ParamFloatSlider(const char *na, int num, char **l);
286 ParamFloatSlider(const char *na, float min, float max, float val);
288};
289
291{
292 friend class CtlMessage;
293 char **list;
294
295public:
296 ParamIntSlider(const char *na, int num, char **l);
297 ParamIntSlider(const char *na, long min, long max, long val);
299};
300
302{
303 friend class CtlMessage;
304 char **list = nullptr;
305
306public:
307 ParamTimer(const char *na, int num, char **l);
308 ParamTimer(const char *na, long start, long delta, long state);
309 ~ParamTimer();
310};
311
313{
314 friend class CtlMessage;
315 char **list = nullptr;
316
317public:
318 ParamPasswd(const char *na, int num, char **l);
319 ParamPasswd(const char *na, char *host, char *user, char *passwd);
320 ~ParamPasswd();
321};
322
324{
325 friend class CtlMessage;
326 char **list = nullptr;
327 int sel;
328
329public:
330 ParamChoice(const char *na, int num, int s, char **l);
331 ParamChoice(const char *na, int num, char **l, int s);
332 ~ParamChoice();
333};
334
336{
337 friend class CtlMessage;
338 char **list = nullptr;
339 int sel;
340
341public:
342 ParamColormapChoice(const char *na, int num, int s, char **l);
343 ParamColormapChoice(const char *na, int num, char **l, int s);
345};
346
348{
349 friend class CtlMessage;
350 char *list = nullptr;
351
352public:
353 ParamMaterial(const char *na, char *l);
355 {
356 return (char *)strlen(list);
357 };
358
360};
361
363{
364 friend class CtlMessage;
365 char **list = nullptr;
366
367public:
368 ParamColormap(const char *na, int num, char **l);
369
371};
372
374{
375 friend class CtlMessage;
376 char **list = nullptr;
377
378public:
379 ParamColor(const char *na, int num, char **l);
380 ParamColor(const char *na, float r, float g, float b, float a);
381 ~ParamColor();
382};
383
384// holds everything necessary to work
385// easily with messages from the controller
386// to an application module
388{
389private:
390 char *m_name;
391 char *h_name;
392 char *inst_no;
407 void init_list();
408
409public:
411 : Message()
412 {
413 sender = m->sender;
414 send_type = m->send_type;
415 type = m->type;
416 data = DataHandle(strlen(m->data.data()) + 1);
417 strcpy(data.accessData(), m->data.data());
418 conn = m->conn; // never use this
419
420 m_name = h_name = NULL;
421 inst_no = NULL;
422 object_types = port_names = object_names = save_names = release_names = NULL;
423 no_of_save_objects = no_of_release_objects = 0;
424 no_of_params_in = no_of_params_out = 0;
425 MAX_OUT_PAR = 100;
426 params_out = new Param *[MAX_OUT_PAR];
427 params_in = 0;
428 init_list();
429 }
430 ~CtlMessage();
431
432 void get_header(char **m, char **h, char **inst)
433 {
434 *m = m_name;
435 *h = h_name, *inst = inst_no;
436 };
437
438 int get_scalar_param(const char *, long *);
439 int get_scalar_param(const char *, float *);
440 int get_vector_param(const char *, int, long *);
441 int get_vector_param(const char *, int, float *);
442 int get_string_param(const char *, char **);
443 int get_text_param(const char *, char ***, int *line_num);
444 int get_boolean_param(const char *, int *);
445 int get_slider_param(const char *, long *min, long *max, long *value);
446 int get_slider_param(const char *, float *min, float *max, float *value);
447 int get_browser_param(const char *, char **);
448 int get_timer_param(const char *, long *start, long *delta, long *state);
449 int get_passwd_param(const char *, char **host, char **user, char **passwd);
450 int get_choice_param(const char *, int *);
451 int get_choice_param(const char *, char **);
452 int get_material_param(const char *, char **);
453 int get_colormapchoice_param(const char *, int *);
454 int get_colormapchoice_param(const char *, char **);
455 int get_colormap_param(const char *, float *min, float *max, int *len, colormap_type *type);
456 int get_color_param(const char *, float *r, float *g, float *b, float *a);
457
458 int set_scalar_param(const char *, long);
459 int set_scalar_param(const char *, float);
460 int set_vector_param(const char *, int num, long *);
461 int set_vector_param(const char *, int num, float *);
462 int set_string_param(const char *, char *);
463 int set_text_param(const char *, char *, int);
464 int set_boolean_param(const char *, int);
465 int set_slider_param(const char *, long min, long max, long value);
466 int set_slider_param(const char *, float min, float max, float value);
467 int set_choice_param(const char *, int, char **, int);
468 int set_browser_param(const char *, char *, char *);
469 int set_timer_param(const char *, long start, long delta, long state);
470 int set_passwd_param(const char *, char *host, char *user, char *passwd);
471
472 char *get_object_name(const char *name);
473 char *getObjectType(const char *name);
474
475 int set_save_object(const char *name);
476 int set_release_object(const char *name);
477
478 int create_finpart_message();
479 int create_finall_message();
480
481 int is_port_connected(const char *name);
482};
483
484class COVISEEXPORT RenderMessage : public Message // holds everything necessary to work
485{
486 // easily with messages from the controller
487 // to the renderer
488 char *m_name;
489 char *h_name;
490 char *inst_no;
491 void init_list();
492
493public:
497 : Message()
498 {
499 sender = m->sender;
500 send_type = m->send_type;
501 type = m->type;
502 data = m->data;
503 conn = m->conn;
504 delete m;
505 m_name = h_name = NULL;
506 inst_no = NULL;
507 no_of_objects = 0;
508 object_names = NULL;
509 init_list();
510 }
512 char *get_part(char *chdata = NULL);
513};
514}
515#endif
#define COVISEEXPORT
Definition: coExport.h:200
#define NULL
Definition: covise_list.h:22
GLdouble n
Definition: khronos-glext.h:8447
GLuint start
Definition: khronos-glext.h:6343
GLsizei const GLfloat * value
Definition: khronos-glext.h:6760
GLuint GLuint GLsizei count
Definition: khronos-glext.h:6343
GLdouble GLdouble t
Definition: khronos-glext.h:6449
GLboolean GLboolean GLboolean b
Definition: khronos-glext.h:6895
GLboolean GLboolean g
Definition: khronos-glext.h:6895
GLuint GLfloat * val
Definition: khronos-glext.h:7898
GLuint const GLchar * name
Definition: khronos-glext.h:6722
GLuint GLuint num
Definition: khronos-glext.h:10593
GLdouble GLdouble GLdouble r
Definition: khronos-glext.h:6457
GLenum GLsizei len
Definition: khronos-glext.h:7440
GLboolean GLboolean GLboolean GLboolean a
Definition: khronos-glext.h:6895
GLdouble s
Definition: khronos-glext.h:6441
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: khronos-glext.h:6354
const GLfloat * m
Definition: khronos-glext.h:12117
GLenum type
Definition: khronos-glext.h:6279
GLfloat GLfloat GLfloat GLfloat h
Definition: khronos-glext.h:8441
int min(int a, int b)
Definition: cutil_math.h:60
int max(int a, int b)
Definition: cutil_math.h:55
list of all chemical elements
Definition: coConfig.h:27
colormap_type
Definition: covise_msg.h:80
@ VIRVO
Definition: covise_msg.h:82
@ RGBAX
Definition: covise_msg.h:81
long data_type
Definition: message.h:28
double length(EDGE_VECTOR &vector)
Definition: CuttingSurfaceGPMUtil.h:70
@ COVISE_MESSAGE_MALLOC_OK
Definition: message_types.h:78
@ COVISE_MESSAGE_SHM_MALLOC
Definition: message_types.h:76
Definition: dataHandle.h:18
Definition: message.h:76
int sender
Definition: message.h:96
Definition: dmgr.h:216
Definition: covise_msg.h:88
long get_count()
Definition: covise_msg.h:116
ShmMessage()
Definition: covise_msg.h:104
int get_seq_no()
Definition: covise_msg.h:120
int get_offset()
Definition: covise_msg.h:127
data_type get_data_type()
Definition: covise_msg.h:112
int process_new_object_list(DataManagerProcess *dmgr)
ShmMessage(data_type d, long count)
Definition: covise_msg.h:92
int process_list(DataManagerProcess *dmgr)
Definition: covise_msg.h:137
int no
Definition: covise_msg.h:141
int get_type()
Definition: covise_msg.h:159
int no_of_items()
Definition: covise_msg.h:155
Param(const char *na, int t, int n)
Definition: covise_msg.h:144
char * getName() const
Definition: covise_msg.h:151
virtual ~Param()
Definition: covise_msg.h:163
int type
Definition: covise_msg.h:140
Definition: covise_msg.h:170
~ParamFloatScalar()
Definition: covise_msg.h:177
Definition: covise_msg.h:184
Definition: covise_msg.h:195
Definition: covise_msg.h:206
Definition: covise_msg.h:217
Definition: covise_msg.h:235
char * get_length()
Definition: covise_msg.h:241
char * list
Definition: covise_msg.h:237
Definition: covise_msg.h:249
int get_length()
Definition: covise_msg.h:261
int line_num
Definition: covise_msg.h:252
int length
Definition: covise_msg.h:253
int get_line_number()
Definition: covise_msg.h:257
Definition: covise_msg.h:269
Definition: covise_msg.h:280
Definition: covise_msg.h:291
char ** list
Definition: covise_msg.h:293
Definition: covise_msg.h:302
Definition: covise_msg.h:313
Definition: covise_msg.h:324
int sel
Definition: covise_msg.h:327
Definition: covise_msg.h:336
int sel
Definition: covise_msg.h:339
Definition: covise_msg.h:348
char * get_length()
Definition: covise_msg.h:354
Definition: covise_msg.h:363
Definition: covise_msg.h:374
Definition: covise_msg.h:388
int no_of_save_objects
Definition: covise_msg.h:394
int no_of_params_in
Definition: covise_msg.h:396
char ** release_names
Definition: covise_msg.h:404
Param ** params_out
Definition: covise_msg.h:406
char ** save_names
Definition: covise_msg.h:403
void get_header(char **m, char **h, char **inst)
Definition: covise_msg.h:432
int MAX_OUT_PAR
Definition: covise_msg.h:398
int no_of_params_out
Definition: covise_msg.h:397
char * m_name
Definition: covise_msg.h:390
int no_of_objects
Definition: covise_msg.h:393
char ** object_names
Definition: covise_msg.h:400
char ** object_types
Definition: covise_msg.h:401
Param ** params_in
Definition: covise_msg.h:405
char * inst_no
Definition: covise_msg.h:392
char ** port_names
Definition: covise_msg.h:399
int * port_connected
Definition: covise_msg.h:402
CtlMessage(Message *m)
Definition: covise_msg.h:410
char * h_name
Definition: covise_msg.h:391
int no_of_release_objects
Definition: covise_msg.h:395
Definition: covise_msg.h:485
int no_of_objects
Definition: covise_msg.h:494
char ** object_names
Definition: covise_msg.h:495
char * h_name
Definition: covise_msg.h:489
RenderMessage(Message *m)
Definition: covise_msg.h:496
char * m_name
Definition: covise_msg.h:488
char * inst_no
Definition: covise_msg.h:490
Definition: covise_shm.h:380