COVISE Core
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
CoviseAppModule.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 // basic ApplicationModule - class for COVISE
9 // by Lars Frenzel
10 //
11 // history: 01/16/1998 started working
12 // 11/18/1998 added multiprocessing support for __sgi
13 //
14 
15 #if !defined(__COVISE_APP_MODULE_H)
16 #define __COVISE_APP_MODULE_H
17 
18 #include <covise/covise.h>
19 #include "ApplInterface.h"
20 
21 #if defined(__sgi)
22 #include <ulocks.h>
23 #endif
24 
25 namespace covise
26 {
27 
29 {
30 private:
31  // callbacks
32  static void computeCallback(void *, void *);
33  void nonstaticComputeCallback();
34 
35  // doing all the work
36  void preHandleObjects(const coDistributedObject **obj_in);
37 
38  // names of ports (NULL for none / unused)
39  char **inport_names;
40  char **outport_names;
43 
44  // should we copy set-attributes or not ?
47 
48  // is Multiprocessing supported by the module ?
52 
53  // should we compute timesteps/multiblock
56 
57 protected:
58  // get a coDistributedObject by giving the port-name
59  const coDistributedObject *getUnknown(char *name, int &errflag);
60 
61 public:
62  // basic stuff
64  virtual ~CoviseAppModule();
65 
66  // handling attributes
68  {
69  copy_attributes_flag = val;
70  return;
71  };
72  void setCopySetAttributesFlag(int val) //sl:
73  {
74  or_copy_addAttributes_flag = val;
75  return;
76  }
77  void copyAttributes(const coDistributedObject *, coDistributedObject *);
78 
79  // setting the port-names
80  void setPortNames(const char **, const char **);
81 
82  // setting up the callback-functions
83  void setCallbacks();
84 
85  // set, if the module is multiprocessing-aware
87  {
88  multiprocessing_flag = val;
89  };
91  {
92  pre_multiprocessing_flag = val;
93  };
94 
95  // set what type of data to compute
97  {
98  compute_timesteps = val;
99  return;
100  };
102  {
103  compute_multiblock = val;
104  return;
105  };
106 
107  // we may require information about the current level
108  int getLevel()
109  {
110  return (current_level);
111  };
112 
113  // required for multiprocessing
114  void lockNewObjects();
115  void unlockNewObjects();
116 #if defined(__sgi)
117  barrier_t *thisGroupsBarrier;
118  ulock_t *thisGroupsMutex;
119 #endif
120 
121  // virtual stuff - may be provided by programmer
122  virtual void preCompute(const coDistributedObject **){};
123  virtual coDistributedObject **compute(const coDistributedObject **, char **)
124  {
125  return NULL;
126  };
128 
129  // doing all the work (has to be public in order for multiprocessing to work)
130  void handleObjects(const coDistributedObject **obj_in, char **obj_out_names,
131  coDistributedObject ***obj_set_out = NULL, int set_id = 0, int num_proc_wait = 1);
132 };
133 
134 #if defined(__sgi)
135 
136 struct CoviseAppModuleInfo
137 {
138  // SMP stuff
139  barrier_t *barrier;
140  int first, max, step;
141  int num;
142 
143  // the module
144  CoviseAppModule *mod;
145 
146  // and the parameters
147  coDistributedObject ***obj_in;
148  char ***obj_out_names;
149  coDistributedObject ***obj_set_out;
150 };
151 
152 void scMultiProcCoviseAppModule(void *p, size_t qwery = 0);
153 #endif
154 }
155 #endif // __COVISE_APP_MODULE_H
int current_level
Definition: CoviseAppModule.h:50
void setComputeTimesteps(int val)
Definition: CoviseAppModule.h:96
int compute_timesteps
Definition: CoviseAppModule.h:54
bool multiprocessing_flag
Definition: CoviseAppModule.h:49
int or_copy_addAttributes_flag
Definition: CoviseAppModule.h:46
virtual coDistributedObject ** compute(const coDistributedObject **, char **)
Definition: CoviseAppModule.h:123
GLuint GLfloat * val
Definition: khronos-glext.h:7898
Definition: CoviseAppModule.h:28
#define NULL
Definition: covise_list.h:22
void setCopyAttributes(int val)
Definition: CoviseAppModule.h:67
int getLevel()
Definition: CoviseAppModule.h:108
bool pre_multiprocessing_flag
Definition: CoviseAppModule.h:51
int num_outports
Definition: CoviseAppModule.h:42
char ** inport_names
Definition: CoviseAppModule.h:39
void setPreMultiprocessing(bool val)
Definition: CoviseAppModule.h:90
char ** outport_names
Definition: CoviseAppModule.h:40
int num_inports
Definition: CoviseAppModule.h:41
int compute_multiblock
Definition: CoviseAppModule.h:55
virtual void postCompute(const coDistributedObject **, coDistributedObject **)
Definition: CoviseAppModule.h:127
const GLint * first
Definition: khronos-glext.h:6529
GLuint GLuint num
Definition: khronos-glext.h:10593
GLfloat GLfloat p
Definition: khronos-glext.h:9861
void setMultiprocessing(bool val)
Definition: CoviseAppModule.h:86
int max(int a, int b)
Definition: cutil_math.h:55
#define APPLEXPORT
Definition: coExport.h:57
void setCopySetAttributesFlag(int val)
Definition: CoviseAppModule.h:72
Definition: coDistributedObject.h:294
GLuint const GLchar * name
Definition: khronos-glext.h:6722
virtual void preCompute(const coDistributedObject **)
Definition: CoviseAppModule.h:122
void setComputeMultiblock(int val)
Definition: CoviseAppModule.h:101
int copy_attributes_flag
Definition: CoviseAppModule.h:45