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 
132  static int is_port_connected(const char *name)
133  {
134  return msg ? msg->is_port_connected(name) : 0;
135  }
136 
137  static char *getObjNameToAdd()
138  {
139  return objNameToAdd_;
140  };
141  static char *getObjNameToDelete()
142  {
143  return objNameToDelete_;
144  };
145 
146 /* old stuff: not supported any further
147  static void add_port(enum appl_port_type, char *,char *, char *);
148  static void set_port_description(char *, char *);
149  static void set_port_datatype(char *, char *);
150  static void set_port_required(char *, int);
151  static void add_port(enum appl_port_type type, const char *name);
152  */
153 
154 //
155 // Callback and control
156 //
157 #ifdef USE_X11
158  static void init(int argc, char *argv[], XtAppContext appContext);
159 #else
160  static void init(int argc, char *argv[]);
161 #endif
162  static void sendFinishedMsg(void *msg);
163  static int check_and_handle_event(float time = 0.0);
164  static void do_one_event();
165  static void ReceiveOneMsg();
166  static int deleteConnection();
167  static void main_loop();
168  static void progress_main_loop();
169  static void set_start_callback(CoviseCallback *f, void *userData);
170  static void set_add_object_callback(CoviseCallback *f, void *userData);
171 
172  static void set_feedback_callback(FeedbackCallback *f, void *userData);
173 
174  static void set_generic_callback(CoviseCallback *f, void *userData);
175  static void set_sync_callback(CoviseCallback *f, void *userData);
176 
177  static void set_port_callback(CoviseCallback *f, void *userData);
178  static void set_after_finish_callback(CoviseCallback *f, void *userData);
179  static void set_pipeline_finish_callback(CoviseCallback *f, void *userData);
180  static void remove_start_callback();
181  static void remove_feedback_callback();
182 
183  static void remove_generic_callback();
184  static void remove_sync_callback();
185 
186  static void remove_after_finish_callback();
187  static void remove_pipeline_finish_callback();
188 
189  static char *get_reply_port_name()
190  {
191  return reply_port_name;
192  }
193  //
194  // Object name handling
195  //
196  static char *get_object_name(const char *name)
197  {
198  return msg ? msg->get_object_name(name) : NULL;
199  }
200 
201  static char *getObjectType(const char *name)
202  {
203  return msg ? msg->getObjectType(name) : NULL;
204  }
205 
206  //
207  // Parameter setting, retrieving and updating
208  //
209  static int get_scalar_param(const char *name, long *val)
210  {
211  return msg ? msg->get_scalar_param(name, val) : 0;
212  }
213 
214  static int get_scalar_param(const char *name, float *val)
215  {
216  return msg ? msg->get_scalar_param(name, val) : 0;
217  }
218 
219  static int get_vector_param(const char *name, int pos, long *list)
220  {
221  return msg ? msg->get_vector_param(name, pos, list) : 0;
222  }
223 
224  static int get_vector_param(const char *name, int pos, float *list)
225  {
226  return msg ? msg->get_vector_param(name, pos, list) : 0;
227  }
228 
229  static int get_string_param(const char *name, char **string)
230  {
231  return msg ? msg->get_string_param(name, string) : 0;
232  }
233 
234  static int get_browser_param(const char *name, char **file)
235  {
236  return msg ? msg->get_browser_param(name, file) : 0;
237  }
238 
239  static int get_boolean_param(const char *name, int *b)
240  {
241  return msg ? msg->get_boolean_param(name, b) : 0;
242  }
243 
244  static int get_slider_param(const char *name, long *min, long *max, long *val)
245  {
246  return msg ? msg->get_slider_param(name, min, max, val) : 0;
247  }
248 
249  static int get_slider_param(const char *name, float *min, float *max, float *val)
250  {
251  return msg ? msg->get_slider_param(name, min, max, val) : 0;
252  }
253 
254  static int get_text_param(const char *name, char ***text, int *linenum)
255  {
256  return msg ? msg->get_text_param(name, text, linenum) : 0;
257  }
258 
259  static int get_timer_param(const char *name, long *start, long *delta, long *state)
260  {
261  return msg ? msg->get_timer_param(name, start, delta, state) : 0;
262  }
263 
264  static int get_passwd_param(const char *name, char **host, char **user,
265  char **passwd)
266  {
267  return msg ? msg->get_passwd_param(name, host, user, passwd) : 0;
268  }
269 
270  static int get_choice_param(const char *name, int *pos)
271  {
272  return msg ? msg->get_choice_param(name, pos) : 0;
273  }
274 
275  static int get_choice_param(const char *name, char **string)
276  {
277  return msg ? msg->get_choice_param(name, string) : 0;
278  }
279 
280  static int get_material_param(const char *name, char **string)
281  {
282  return msg ? msg->get_material_param(name, string) : 0;
283  }
284 
285  static int get_colormapchoice_param(const char *name, int *pos)
286  {
287  return msg ? msg->get_colormapchoice_param(name, pos) : 0;
288  }
289 
290  static int get_colormapchoice_param(const char *name, char **string)
291  {
292  return msg ? msg->get_colormapchoice_param(name, string) : 0;
293  }
294 
295  static int get_colormap_param(const char *name, float *min, float *max, int *len, colormap_type *type)
296  {
297  return msg ? msg->get_colormap_param(name, min, max, len, type) : 0;
298  }
299 
300  static int get_color_param(const char *name, float *r, float *g, float *b, float *a)
301  {
302  return msg ? msg->get_color_param(name, r, g, b, a) : 0;
303  }
304 
305  static int set_scalar_param(const char *name, long val)
306  {
307  return msg ? msg->set_scalar_param(name, val) : 0;
308  }
309 
310  static int set_scalar_param(const char *name, float val)
311  {
312  return msg ? msg->set_scalar_param(name, val) : 0;
313  }
314 
315  static int set_vector_param(const char *name, int num, long *list)
316  {
317  return msg ? msg->set_vector_param(name, num, list) : 0;
318  }
319 
320  static int set_vector_param(const char *name, int num, float *list)
321  {
322  return msg ? msg->set_vector_param(name, num, list) : 0;
323  }
324 
325  static int set_string_param(const char *name, char *string)
326  {
327  return msg ? msg->set_string_param(name, string) : 0;
328  }
329 
330  static int set_boolean_param(const char *name, int val)
331  {
332  return msg ? msg->set_boolean_param(name, val) : 0;
333  }
334 
335  static int set_slider_param(const char *name, long min, long max, long val)
336  {
337  return msg ? msg->set_slider_param(name, min, max, val) : 0;
338  }
339 
340  static int set_slider_param(const char *name, float min, float max, float val)
341  {
342  return msg ? msg->set_slider_param(name, min, max, val) : 0;
343  }
344 
345  static int set_choice_param(const char *name, int len, char **list, int pos)
346  {
347  return msg ? msg->set_choice_param(name, len, list, pos) : 0;
348  }
349 
350  static int set_browser_param(const char *name, char *file, char *wildcard)
351  {
352  return msg ? msg->set_browser_param(name, file, wildcard) : 0;
353  }
354 
355  static int set_text_param(const char *name, char *text, int linenum)
356  {
357  return msg ? msg->set_text_param(name, text, linenum) : 0;
358  }
359 
360  static int set_timer_param(const char *name, int start, int delta, int state)
361  {
362  return msg ? msg->set_timer_param(name, start, delta, state) : 0;
363  }
364 
365  static int set_passwd_param(const char *name, char *host, char *user, char *passwd)
366  {
367  return msg ? msg->set_passwd_param(name, host, user, passwd) : 0;
368  }
369 
370  static int set_save_object(char *name)
371  {
372  return msg ? msg->set_save_object(name) : 0;
373  }
374 
375  static int set_release_object(char *name)
376  {
377  return msg ? msg->set_release_object(name) : 0;
378  }
379 
380  static void cancel_param(const char *name);
381  static void reopen_param(const char *name);
382 
383  //
384  // Messages to COVISE environment
385  //
386  static int send_generic_message(const char *keyword, const char *string);
387  static int send_genericinit_message(const char *mkey, const char *keyword, const char *string);
388  static char *get_generic_message();
389 
390  static void send_stop_pipeline();
391  static int send_ctl_message(covise_msg_type type, const char *msg_string);
392  static void sendFinishedMsg();
393 
394  //
395  // The callback functions called in callXXX has to be
396  // implemented by the user
397  //
398  static void callFeedbackCallback(Message *);
399  static void callStartCallback(void);
400 
401  static void callAddObjectCallback(void);
402 
403  static void callGenericCallback(void);
404  static void callSyncCallback(void);
405 
406  static void callPortReplyCallback(void);
407  static void callAfterFinishCallback(void);
408  static void callPipelineFinishCallback(void);
409  //
410  // Partitioned object support
411  //
412  static void partobjects_initialized(void);
413 
414  // Add Interactor for feedback
415  static void addInteractor(coDistributedObject *obj, const char *name, const char *value);
416 };
417 }
418 #endif
static int get_scalar_param(const char *name, long *val)
Definition: ApplInterface.h:209
static int get_vector_param(const char *name, int pos, long *list)
Definition: ApplInterface.h:219
static int pipeline_state_once
Definition: ApplInterface.h:59
GLenum GLsizei len
Definition: khronos-glext.h:7440
static int set_string_param(const char *name, char *string)
Definition: ApplInterface.h:325
appl_port_type
Definition: CoviseBase.h:42
GLsizei GLsizei GLuint * obj
Definition: khronos-glext.h:6733
static int get_boolean_param(const char *name, int *b)
Definition: ApplInterface.h:239
static char * genericMessageData
Definition: ApplInterface.h:92
static int set_passwd_param(const char *name, char *host, char *user, char *passwd)
Definition: ApplInterface.h:365
static int set_release_object(char *name)
Definition: ApplInterface.h:375
static char * get_object_name(const char *name)
Definition: ApplInterface.h:196
static void * syncCallbackData
Definition: ApplInterface.h:96
static CoviseCallback * portReplyCallbackFunc
Definition: ApplInterface.h:98
static int set_browser_param(const char *name, char *file, char *wildcard)
Definition: ApplInterface.h:350
static char * getObjectType(const char *name)
Definition: ApplInterface.h:201
static int set_vector_param(const char *name, int num, long *list)
Definition: ApplInterface.h:315
GLuint const GLchar * name
Definition: khronos-glext.h:6722
static void * pipelineFinishUserData
Definition: ApplInterface.h:105
static CtlMessage * msg
Definition: ApplInterface.h:52
static int get_color_param(const char *name, float *r, float *g, float *b, float *a)
Definition: ApplInterface.h:300
static CoviseCallback * afterFinishCallbackFunc
Definition: ApplInterface.h:101
static void * syncUserData
Definition: ApplInterface.h:95
static void * afterFinishCallbackData
Definition: ApplInterface.h:103
colormap_type
Definition: covise_msg.h:79
static int is_port_connected(const char *name)
check whether port is connected - use in compute() CB only
Definition: ApplInterface.h:132
GLboolean GLboolean GLboolean b
Definition: khronos-glext.h:6895
static int set_slider_param(const char *name, long min, long max, long val)
Definition: ApplInterface.h:335
static int set_vector_param(const char *name, int num, float *list)
Definition: ApplInterface.h:320
static void * portReplyUserData
Definition: ApplInterface.h:99
static void * genericUserData
Definition: ApplInterface.h:90
static int get_slider_param(const char *name, long *min, long *max, long *val)
Definition: ApplInterface.h:244
static void * addObjectUserData
Definition: ApplInterface.h:86
static int get_material_param(const char *name, char **string)
Definition: ApplInterface.h:280
#define NULL
Definition: covise_list.h:22
static CoviseCallback * addObjectCallbackFunc
Definition: ApplInterface.h:85
static char * objNameToAdd_
Definition: ApplInterface.h:108
Definition: message.h:111
static char * getObjNameToAdd()
Definition: ApplInterface.h:137
void CoviseCallback(void *userData, void *callbackData)
Definition: CoviseBase.h:60
static void * pipelineFinishCallbackData
Definition: ApplInterface.h:106
static int get_browser_param(const char *name, char **file)
Definition: ApplInterface.h:234
static char * modkey
Definition: ApplInterface.h:55
static CoviseCallback * genericCallbackFunc
Definition: ApplInterface.h:89
static int set_scalar_param(const char *name, long val)
Definition: ApplInterface.h:305
static void * addObjectCallbackData
Definition: ApplInterface.h:87
static int get_string_param(const char *name, char **string)
Definition: ApplInterface.h:229
static void * genericCallbackData
Definition: ApplInterface.h:91
static FeedbackCallback * feedbackCallbackFunc
Definition: ApplInterface.h:78
GLuint GLfloat * val
Definition: khronos-glext.h:7898
static int set_boolean_param(const char *name, int val)
Definition: ApplInterface.h:330
static int get_choice_param(const char *name, char **string)
Definition: ApplInterface.h:275
static CoviseCallback * startCallbackFunc
Definition: ApplInterface.h:81
GLdouble GLdouble GLdouble r
Definition: khronos-glext.h:6457
Definition: CoviseBase.h:63
static void * feedbackUserData
Definition: ApplInterface.h:79
static int get_vector_param(const char *name, int pos, float *list)
Definition: ApplInterface.h:224
static int get_timer_param(const char *name, long *start, long *delta, long *state)
Definition: ApplInterface.h:259
static char * get_reply_port_name()
Definition: ApplInterface.h:189
static int get_colormapchoice_param(const char *name, int *pos)
Definition: ApplInterface.h:285
static int get_text_param(const char *name, char ***text, int *linenum)
Definition: ApplInterface.h:254
GLboolean GLboolean GLboolean GLboolean a
Definition: khronos-glext.h:6895
static int set_scalar_param(const char *name, float val)
Definition: ApplInterface.h:310
static int renderMode_
Definition: ApplInterface.h:57
static int get_colormapchoice_param(const char *name, char **string)
Definition: ApplInterface.h:290
GLuint start
Definition: khronos-glext.h:6343
static int set_save_object(char *name)
Definition: ApplInterface.h:370
static CoviseCallback * syncCallbackFunc
Definition: ApplInterface.h:94
GLenum type
Definition: khronos-glext.h:6279
static char * objNameToDelete_
Definition: ApplInterface.h:109
static int set_choice_param(const char *name, int len, char **list, int pos)
Definition: ApplInterface.h:345
static CoviseCallback * pipelineFinishCallbackFunc
Definition: ApplInterface.h:104
covise_msg_type
Definition: message_types.h:64
static void * portReplyCallbackData
Definition: ApplInterface.h:100
static int set_timer_param(const char *name, int start, int delta, int state)
Definition: ApplInterface.h:360
const GLfloat * m
Definition: khronos-glext.h:12117
static int get_slider_param(const char *name, float *min, float *max, float *val)
Definition: ApplInterface.h:249
static int set_text_param(const char *name, char *text, int linenum)
Definition: ApplInterface.h:355
GLboolean GLboolean g
Definition: khronos-glext.h:6895
static int get_scalar_param(const char *name, float *val)
Definition: ApplInterface.h:214
void FeedbackCallback(void *userData, int len, const char *data)
Definition: ApplInterface.h:43
static int get_colormap_param(const char *name, float *min, float *max, int *len, colormap_type *type)
Definition: ApplInterface.h:295
static void * startUserData
Definition: ApplInterface.h:82
Definition: coDistributedObject.h:295
static void * startCallbackData
Definition: ApplInterface.h:83
static char * reply_port_name
Definition: ApplInterface.h:53
Definition: covise_msg.h:745
GLsizei const GLfloat * value
Definition: khronos-glext.h:6760
Definition: ApplInterface.h:48
GLuint GLuint num
Definition: khronos-glext.h:10593
GLfloat f
Definition: khronos-glext.h:8258
static char * getObjNameToDelete()
Definition: ApplInterface.h:141
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: khronos-glext.h:6354
static int get_passwd_param(const char *name, char **host, char **user, char **passwd)
Definition: ApplInterface.h:264
static int get_choice_param(const char *name, int *pos)
Definition: ApplInterface.h:270
static void * afterFinishUserData
Definition: ApplInterface.h:102
int min(int a, int b)
Definition: cutil_math.h:60
int max(int a, int b)
Definition: cutil_math.h:55
static int set_slider_param(const char *name, float min, float max, float val)
Definition: ApplInterface.h:340
#define APPLEXPORT
Definition: coExport.h:57