COVISE Core
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
ApplInterface.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 _APPL_INTERFACE_H
9 #define _APPL_INTERFACE_H
10 
11 /**************************************************************************\
12  ** (C)1994 RUS **
13  ** **
14  ** Description: Interface class for application modules to the COVISE **
15  ** software environment **
16  ** **
17  ** **
18  ** **
19  ** **
20  ** Author: **
21  ** **
22  ** Dirk Rantzau **
23  ** Computer Center University of Stuttgart **
24  ** Allmandring 30 **
25  ** 70550 Stuttgart **
26  ** **
27  ** Date: 18.05.94 V1.0 **
28  ** 25.6.97 V1.1 Harald Nebel, added GENERIC-stuff **
29 \**************************************************************************/
30 
31 #include "CoviseBase.h"
32 
33 #include <covise/covise_msg.h>
34 
35 #define COMPAT452
36 
37 namespace covise
38 {
39 
40 //=====================================================================
41 // Covise callbacks
42 //=====================================================================
43 typedef void FeedbackCallback(void *userData, int len, const char *data);
44 
45 //=====================================================================
46 //
47 //=====================================================================
49 {
50 private:
51  // Communication Data
52  static CtlMessage *msg;
53  static char *reply_port_name;
54 
55  static char *modkey;
56 
57  static int renderMode_;
58 
59  static int pipeline_state_once;
60 
61  // private member funcs
62  static void doParam(Message *m);
63  static void doPortReply(Message *m);
64  static void doPipelineFinish();
65 
66  static void generic(Message *applMsg);
67 
68  static void doStartWithoutFinish(Message *m);
69  static void doStart(Message *m);
70  static void doAddObject();
71  static void doGeneric(Message *m);
72  static void doSync(Message *m);
73  static int doQuit();
74 
75  //
76  // callback stuff
77  //
79  static void *feedbackUserData;
80 
82  static void *startUserData;
83  static void *startCallbackData;
84 
86  static void *addObjectUserData;
87  static void *addObjectCallbackData;
88 
90  static void *genericUserData;
91  static void *genericCallbackData;
92  static char *genericMessageData;
93 
95  static void *syncUserData;
96  static void *syncCallbackData;
97 
99  static void *portReplyUserData;
100  static void *portReplyCallbackData;
102  static void *afterFinishUserData;
107 
108  static char *objNameToAdd_;
109  static char *objNameToDelete_;
110 
111 public:
113  static void set_module_description(const char *desc);
114  static const char *get_module_description();
115 
117  static void add_port(enum appl_port_type type, const char *name,
118  const char *datatype, const char *description);
119 
121  static void set_port_default(const char *name, const char *defVal);
122 
124  static void set_port_dependency(const char *port, char *depPort);
125 
127  static void set_port_required(const char *name, int isReqired);
128 
129  static char *get_description_message();
130 
131 
133  static int is_port_connected(const char *name)
134  {
135  return msg ? msg->is_port_connected(name) : 0;
136  }
137 
138  static char *getObjNameToAdd()
139  {
140  return objNameToAdd_;
141  };
142  static char *getObjNameToDelete()
143  {
144  return objNameToDelete_;
145  };
146 
147 /* old stuff: not supported any further
148  static void add_port(enum appl_port_type, char *,char *, char *);
149  static void set_port_description(char *, char *);
150  static void set_port_datatype(char *, char *);
151  static void set_port_required(char *, int);
152  static void add_port(enum appl_port_type type, const char *name);
153  */
154 
155 //
156 // Callback and control
157 //
158 #ifdef COVISE_USE_X11
159  static void init(int argc, char *argv[], XtAppContext appContext);
160 #else
161  static void init(int argc, char *argv[]);
162 #endif
163  static void sendFinishedMsg(void *msg);
164  static int check_and_handle_event(float time = 0.0);
165  static void do_one_event();
166  static void ReceiveOneMsg();
167  static int deleteConnection();
168  static void main_loop();
169  static void progress_main_loop();
170  static void set_start_callback(CoviseCallback *f, void *userData);
171  static void set_add_object_callback(CoviseCallback *f, void *userData);
172 
173  static void set_feedback_callback(FeedbackCallback *f, void *userData);
174 
175  static void set_generic_callback(CoviseCallback *f, void *userData);
176  static void set_sync_callback(CoviseCallback *f, void *userData);
177 
178  static void set_port_callback(CoviseCallback *f, void *userData);
179  static void set_after_finish_callback(CoviseCallback *f, void *userData);
180  static void set_pipeline_finish_callback(CoviseCallback *f, void *userData);
181  static void remove_start_callback();
182  static void remove_feedback_callback();
183 
184  static void remove_generic_callback();
185  static void remove_sync_callback();
186 
187  static void remove_after_finish_callback();
188  static void remove_pipeline_finish_callback();
189 
190  static char *get_reply_port_name()
191  {
192  return reply_port_name;
193  }
194  //
195  // Object name handling
196  //
197  static char *get_object_name(const char *name)
198  {
199  return msg ? msg->get_object_name(name) : NULL;
200  }
201 
202  static char *getObjectType(const char *name)
203  {
204  return msg ? msg->getObjectType(name) : NULL;
205  }
206 
207  //
208  // Parameter setting, retrieving and updating
209  //
210  static int get_scalar_param(const char *name, long *val)
211  {
212  return msg ? msg->get_scalar_param(name, val) : 0;
213  }
214 
215  static int get_scalar_param(const char *name, float *val)
216  {
217  return msg ? msg->get_scalar_param(name, val) : 0;
218  }
219 
220  static int get_vector_param(const char *name, int pos, long *list)
221  {
222  return msg ? msg->get_vector_param(name, pos, list) : 0;
223  }
224 
225  static int get_vector_param(const char *name, int pos, float *list)
226  {
227  return msg ? msg->get_vector_param(name, pos, list) : 0;
228  }
229 
230  static int get_string_param(const char *name, char **string)
231  {
232  return msg ? msg->get_string_param(name, string) : 0;
233  }
234 
235  static int get_browser_param(const char *name, char **file)
236  {
237  return msg ? msg->get_browser_param(name, file) : 0;
238  }
239 
240  static int get_boolean_param(const char *name, int *b)
241  {
242  return msg ? msg->get_boolean_param(name, b) : 0;
243  }
244 
245  static int get_slider_param(const char *name, long *min, long *max, long *val)
246  {
247  return msg ? msg->get_slider_param(name, min, max, val) : 0;
248  }
249 
250  static int get_slider_param(const char *name, float *min, float *max, float *val)
251  {
252  return msg ? msg->get_slider_param(name, min, max, val) : 0;
253  }
254 
255  static int get_text_param(const char *name, char ***text, int *linenum)
256  {
257  return msg ? msg->get_text_param(name, text, linenum) : 0;
258  }
259 
260  static int get_timer_param(const char *name, long *start, long *delta, long *state)
261  {
262  return msg ? msg->get_timer_param(name, start, delta, state) : 0;
263  }
264 
265  static int get_passwd_param(const char *name, char **host, char **user,
266  char **passwd)
267  {
268  return msg ? msg->get_passwd_param(name, host, user, passwd) : 0;
269  }
270 
271  static int get_choice_param(const char *name, int *pos)
272  {
273  return msg ? msg->get_choice_param(name, pos) : 0;
274  }
275 
276  static int get_choice_param(const char *name, char **string)
277  {
278  return msg ? msg->get_choice_param(name, string) : 0;
279  }
280 
281  static int get_material_param(const char *name, char **string)
282  {
283  return msg ? msg->get_material_param(name, string) : 0;
284  }
285 
286  static int get_colormapchoice_param(const char *name, int *pos)
287  {
288  return msg ? msg->get_colormapchoice_param(name, pos) : 0;
289  }
290 
291  static int get_colormapchoice_param(const char *name, char **string)
292  {
293  return msg ? msg->get_colormapchoice_param(name, string) : 0;
294  }
295 
296  static int get_colormap_param(const char *name, float *min, float *max, int *len, colormap_type *type)
297  {
298  return msg ? msg->get_colormap_param(name, min, max, len, type) : 0;
299  }
300 
301  static int get_color_param(const char *name, float *r, float *g, float *b, float *a)
302  {
303  return msg ? msg->get_color_param(name, r, g, b, a) : 0;
304  }
305 
306  static int set_scalar_param(const char *name, long val)
307  {
308  return msg ? msg->set_scalar_param(name, val) : 0;
309  }
310 
311  static int set_scalar_param(const char *name, float val)
312  {
313  return msg ? msg->set_scalar_param(name, val) : 0;
314  }
315 
316  static int set_vector_param(const char *name, int num, long *list)
317  {
318  return msg ? msg->set_vector_param(name, num, list) : 0;
319  }
320 
321  static int set_vector_param(const char *name, int num, float *list)
322  {
323  return msg ? msg->set_vector_param(name, num, list) : 0;
324  }
325 
326  static int set_string_param(const char *name, char *string)
327  {
328  return msg ? msg->set_string_param(name, string) : 0;
329  }
330 
331  static int set_boolean_param(const char *name, int val)
332  {
333  return msg ? msg->set_boolean_param(name, val) : 0;
334  }
335 
336  static int set_slider_param(const char *name, long min, long max, long val)
337  {
338  return msg ? msg->set_slider_param(name, min, max, val) : 0;
339  }
340 
341  static int set_slider_param(const char *name, float min, float max, float val)
342  {
343  return msg ? msg->set_slider_param(name, min, max, val) : 0;
344  }
345 
346  static int set_choice_param(const char *name, int len, char **list, int pos)
347  {
348  return msg ? msg->set_choice_param(name, len, list, pos) : 0;
349  }
350 
351  static int set_browser_param(const char *name, char *file, char *wildcard)
352  {
353  return msg ? msg->set_browser_param(name, file, wildcard) : 0;
354  }
355 
356  static int set_text_param(const char *name, char *text, int linenum)
357  {
358  return msg ? msg->set_text_param(name, text, linenum) : 0;
359  }
360 
361  static int set_timer_param(const char *name, int start, int delta, int state)
362  {
363  return msg ? msg->set_timer_param(name, start, delta, state) : 0;
364  }
365 
366  static int set_passwd_param(const char *name, char *host, char *user, char *passwd)
367  {
368  return msg ? msg->set_passwd_param(name, host, user, passwd) : 0;
369  }
370 
371  static int set_save_object(char *name)
372  {
373  return msg ? msg->set_save_object(name) : 0;
374  }
375 
376  static int set_release_object(char *name)
377  {
378  return msg ? msg->set_release_object(name) : 0;
379  }
380 
381  static void cancel_param(const char *name);
382  static void reopen_param(const char *name);
383 
384  //
385  // Messages to COVISE environment
386  //
387  static int send_generic_message(const char *keyword, const char *string);
388  static int send_genericinit_message(const char *mkey, const char *keyword, const char *string);
389  static char *get_generic_message();
390 
391  static void send_stop_pipeline();
392  static int send_ctl_message(covise_msg_type type, const char *msg_string);
393  static void sendFinishedMsg();
394 
395  //
396  // The callback functions called in callXXX has to be
397  // implemented by the user
398  //
399  static void callFeedbackCallback(Message *);
400  static void callStartCallback(void);
401 
402  static void callAddObjectCallback(void);
403 
404  static void callGenericCallback(void);
405  static void callSyncCallback(void);
406 
407  static void callPortReplyCallback(void);
408  static void callAfterFinishCallback(void);
409  static void callPipelineFinishCallback(void);
410  //
411  // Partitioned object support
412  //
413  static void partobjects_initialized(void);
414 
415  // Add Interactor for feedback
416  static void addInteractor(coDistributedObject *obj, const char *name, const char *value);
417 };
418 }
419 #endif
static char * get_object_name(const char *name)
Definition: ApplInterface.h:197
static int set_release_object(char *name)
Definition: ApplInterface.h:376
static void * pipelineFinishCallbackData
Definition: ApplInterface.h:106
static int set_passwd_param(const char *name, char *host, char *user, char *passwd)
Definition: ApplInterface.h:366
static int set_browser_param(const char *name, char *file, char *wildcard)
Definition: ApplInterface.h:351
static char * genericMessageData
Definition: ApplInterface.h:92
static int is_port_connected(const char *name)
check whether port is connected - use in compute() CB only
Definition: ApplInterface.h:133
static char * getObjNameToDelete()
Definition: ApplInterface.h:142
GLuint GLuint num
Definition: khronos-glext.h:10593
static int get_choice_param(const char *name, char **string)
Definition: ApplInterface.h:276
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: khronos-glext.h:6354
static int get_colormap_param(const char *name, float *min, float *max, int *len, colormap_type *type)
Definition: ApplInterface.h:296
Definition: covise_msg.h:387
GLboolean GLboolean GLboolean GLboolean a
Definition: khronos-glext.h:6895
static char * reply_port_name
Definition: ApplInterface.h:53
static int get_color_param(const char *name, float *r, float *g, float *b, float *a)
Definition: ApplInterface.h:301
static char * objNameToAdd_
Definition: ApplInterface.h:108
static CoviseCallback * addObjectCallbackFunc
Definition: ApplInterface.h:85
static char * get_reply_port_name()
Definition: ApplInterface.h:190
static CoviseCallback * syncCallbackFunc
Definition: ApplInterface.h:94
static int set_string_param(const char *name, char *string)
Definition: ApplInterface.h:326
static void * portReplyCallbackData
Definition: ApplInterface.h:100
static void * addObjectUserData
Definition: ApplInterface.h:86
GLdouble GLdouble GLdouble r
Definition: khronos-glext.h:6457
static int get_colormapchoice_param(const char *name, char **string)
Definition: ApplInterface.h:291
static int get_scalar_param(const char *name, long *val)
Definition: ApplInterface.h:210
GLfloat f
Definition: khronos-glext.h:8258
static int set_vector_param(const char *name, int num, long *list)
Definition: ApplInterface.h:316
GLuint const GLchar * name
Definition: khronos-glext.h:6722
static int get_timer_param(const char *name, long *start, long *delta, long *state)
Definition: ApplInterface.h:260
static char * getObjectType(const char *name)
Definition: ApplInterface.h:202
static int set_vector_param(const char *name, int num, float *list)
Definition: ApplInterface.h:321
static int set_scalar_param(const char *name, float val)
Definition: ApplInterface.h:311
static FeedbackCallback * feedbackCallbackFunc
Definition: ApplInterface.h:78
int max(int a, int b)
Definition: cutil_math.h:55
static int get_scalar_param(const char *name, float *val)
Definition: ApplInterface.h:215
static void * startUserData
Definition: ApplInterface.h:82
static void * portReplyUserData
Definition: ApplInterface.h:99
static int get_choice_param(const char *name, int *pos)
Definition: ApplInterface.h:271
static int get_slider_param(const char *name, long *min, long *max, long *val)
Definition: ApplInterface.h:245
static int get_vector_param(const char *name, int pos, long *list)
Definition: ApplInterface.h:220
static CoviseCallback * genericCallbackFunc
Definition: ApplInterface.h:89
static char * objNameToDelete_
Definition: ApplInterface.h:109
static void * addObjectCallbackData
Definition: ApplInterface.h:87
static CtlMessage * msg
Definition: ApplInterface.h:52
colormap_type
Definition: covise_msg.h:79
static int get_slider_param(const char *name, float *min, float *max, float *val)
Definition: ApplInterface.h:250
static int set_boolean_param(const char *name, int val)
Definition: ApplInterface.h:331
const GLfloat * m
Definition: khronos-glext.h:12117
GLboolean GLboolean g
Definition: khronos-glext.h:6895
covise_msg_type
Definition: message_types.h:64
static CoviseCallback * portReplyCallbackFunc
Definition: ApplInterface.h:98
static char * getObjNameToAdd()
Definition: ApplInterface.h:138
static int set_scalar_param(const char *name, long val)
Definition: ApplInterface.h:306
static CoviseCallback * startCallbackFunc
Definition: ApplInterface.h:81
static CoviseCallback * pipelineFinishCallbackFunc
Definition: ApplInterface.h:104
void FeedbackCallback(void *userData, int len, const char *data)
Definition: ApplInterface.h:43
static CoviseCallback * afterFinishCallbackFunc
Definition: ApplInterface.h:101
appl_port_type
Definition: CoviseBase.h:42
static void * syncUserData
Definition: ApplInterface.h:95
static void * afterFinishCallbackData
Definition: ApplInterface.h:103
void CoviseCallback(void *userData, void *callbackData)
Definition: CoviseBase.h:60
#define APPLEXPORT
Definition: coExport.h:57
GLsizei const GLfloat * value
Definition: khronos-glext.h:6760
static int get_boolean_param(const char *name, int *b)
Definition: ApplInterface.h:240
static int pipeline_state_once
Definition: ApplInterface.h:59
GLuint GLfloat * val
Definition: khronos-glext.h:7898
static int get_colormapchoice_param(const char *name, int *pos)
Definition: ApplInterface.h:286
static int get_text_param(const char *name, char ***text, int *linenum)
Definition: ApplInterface.h:255
static int set_save_object(char *name)
Definition: ApplInterface.h:371
static void * startCallbackData
Definition: ApplInterface.h:83
int min(int a, int b)
Definition: cutil_math.h:60
static int set_slider_param(const char *name, long min, long max, long val)
Definition: ApplInterface.h:336
static int set_text_param(const char *name, char *text, int linenum)
Definition: ApplInterface.h:356
static int set_timer_param(const char *name, int start, int delta, int state)
Definition: ApplInterface.h:361
static int set_slider_param(const char *name, float min, float max, float val)
Definition: ApplInterface.h:341
static int get_passwd_param(const char *name, char **host, char **user, char **passwd)
Definition: ApplInterface.h:265
static int get_material_param(const char *name, char **string)
Definition: ApplInterface.h:281
GLenum GLsizei len
Definition: khronos-glext.h:7440
static void * genericUserData
Definition: ApplInterface.h:90
GLboolean GLboolean GLboolean b
Definition: khronos-glext.h:6895
GLsizei GLsizei GLuint * obj
Definition: khronos-glext.h:6733
static void * pipelineFinishUserData
Definition: ApplInterface.h:105
static char * modkey
Definition: ApplInterface.h:55
static int set_choice_param(const char *name, int len, char **list, int pos)
Definition: ApplInterface.h:346
Definition: ApplInterface.h:48
static int get_vector_param(const char *name, int pos, float *list)
Definition: ApplInterface.h:225
static int get_string_param(const char *name, char **string)
Definition: ApplInterface.h:230
static void * genericCallbackData
Definition: ApplInterface.h:91
GLuint start
Definition: khronos-glext.h:6343
static void * feedbackUserData
Definition: ApplInterface.h:79
static void * syncCallbackData
Definition: ApplInterface.h:96
GLenum type
Definition: khronos-glext.h:6279
Definition: coDistributedObject.h:295
Definition: CoviseBase.h:63
#define NULL
Definition: covise_list.h:22
static void * afterFinishUserData
Definition: ApplInterface.h:102
static int get_browser_param(const char *name, char **file)
Definition: ApplInterface.h:235
static int renderMode_
Definition: ApplInterface.h:57
Definition: message.h:111