source: trunk/FACT++/dim_v19r20/dim/dis.hxx@ 10897

Last change on this file since 10897 was 10614, checked in by tbretz, 14 years ago
New release V19 r20
File size: 9.6 KB
Line 
1#ifndef __DISHHDEFS
2#define __DISHHDEFS
3#include <assert.h>
4#include <stdlib.h>
5#include <string.h>
6#ifndef WIN32
7#include <unistd.h>
8#endif
9#ifdef __VMS
10#include <starlet.h>
11#endif
12#include "dim_core.hxx"
13#include "dim.hxx"
14/*
15#define DimSHORT "S"
16#define DimINT "I"
17#define DimLONG "L"
18#define DimFLOAT "F"
19#define DimDOUBLE "D"
20#define DimSTRING "C"
21#define DimXLONG "X"
22*/
23enum DisTYPE {
24 DisPOINTER, DisSHORT, DisINT, DisFLOAT, DisDOUBLE, DisSTRING, DisXLONG, DisCOMMAND
25};
26
27class DimService;
28class DimCommand;
29
30class DllExp DimServiceHandler{
31public:
32 DimService *itsService;
33 DimService *getService() { return itsService; } ;
34 virtual void serviceHandler() = 0;
35 virtual ~DimServiceHandler() {};
36};
37
38class DllExp DimCommandHandler{
39public:
40 DimCommand *itsCommand;
41 DimCommand *getCommand() { return itsCommand; } ;
42 virtual void commandHandler() = 0;
43 virtual ~DimCommandHandler() {};
44};
45
46class DllExp DimClientExitHandler{
47public:
48 virtual void clientExitHandler() = 0;
49 virtual ~DimClientExitHandler() {};
50};
51
52class DllExp DimExitHandler{
53public:
54 virtual void exitHandler(int code) = 0;
55 virtual ~DimExitHandler() {};
56};
57
58class DllExp DimServerDns
59{
60public:
61 DimServerDns(const char *node);
62 DimServerDns(const char *node, int port);
63 DimServerDns(const char *node, int port, char *name);
64 ~DimServerDns();
65 void init(const char *node, int port);
66 long getDnsId();
67 void setName(const char *name);
68 char *getName();
69 void clearName();
70 void autoStartOn();
71 void autoStartOff();
72 int isAutoStart();
73 void addServiceId(int id);
74 int *getServiceIdList();
75private:
76 char *itsNode;
77 int itsPort;
78 long itsDnsId;
79 char *itsName;
80 int autoStart;
81 int *itsServiceIdList;
82 int itsServiceIdListSize;
83 int itsNServiceIds;
84// int itsNServices;
85};
86
87class DllExp DimServer : public DimServiceHandler, public DimCommandHandler,
88 public DimClientExitHandler, public DimExitHandler, public DimErrorHandler
89{
90public:
91 static char *clientName;
92 static char *itsName;
93 static char *dimDnsNode;
94 static int autoStart;
95 static DimClientExitHandler *itsClientExit;
96 static DimExitHandler *itsExit;
97 static DimErrorHandler *itsSrvError;
98// static int itsNServices;
99 DimServer();
100 virtual ~DimServer();
101 static void start(const char *name);
102 static void start(DimServerDns *dns, const char *name);
103 static void start();
104 static void start(DimServerDns *dns);
105 static void stop();
106 static void stop(DimServerDns *dns);
107 static void autoStartOn();
108 static void autoStartOff();
109 // Get Current Client Identifier
110 static int getClientId();
111 // Get Current Client Name
112 static char *getClientName();
113 static void setClientExitHandler(int clientId);
114 static void clearClientExitHandler(int clientId);
115 static void addClientExitHandler(DimClientExitHandler *handler);
116 void addClientExitHandler();
117 static void addExitHandler(DimExitHandler *handler);
118 static void addErrorHandler(DimErrorHandler *handler);
119 static int setDnsNode(const char *node);
120 static int setDnsNode(const char *node, int port);
121 static long addDns(const char *node, int port);
122 static void stopDns(long dnsid);
123 static char *getDnsNode();
124 static int getDnsPort();
125 static void setWriteTimeout(int secs);
126 static int getWriteTimeout();
127 void addExitHandler();
128 void addErrorHandler();
129 virtual void clientExitHandler() {};
130 virtual void exitHandler(int /* code */) {};
131 virtual void errorHandler(int /* severity */, int /* code */, char* /* msg */) {};
132// static char *getClientServices();
133// static char *getClientServices(int clientId);
134 static char **getClientServices();
135
136 virtual void serviceHandler() {};
137 virtual void commandHandler() {};
138};
139
140class DllExp DimService : public DimServiceHandler {
141
142public :
143 DimServiceHandler *itsServiceHandler;
144
145 // The object contains the value to be published. Service to be updated with an argument of same type;
146 DimService();
147
148 DimService(const char *name, int &value);
149 DimService(const char *name, float &value);
150 DimService(const char *name, double &value);
151 DimService(const char *name, longlong &value);
152 DimService(const char *name, short &value);
153 DimService(const char *name, char *string);
154
155 DimService(const char *name, char *format, void *structure, int size);
156
157 DimService(const char *name, char *format, DimServiceHandler *handler);
158
159 DimService(const char *name, const char *format, void *structure, int size);
160
161 DimService(const char *name, const char *format, DimServiceHandler *handler);
162
163 DimService(DimServerDns *dns, const char *name, int &value);
164 DimService(DimServerDns *dns, const char *name, float &value);
165 DimService(DimServerDns *dns, const char *name, double &value);
166 DimService(DimServerDns *dns, const char *name, longlong &value);
167 DimService(DimServerDns *dns, const char *name, short &value);
168 DimService(DimServerDns *dns, const char *name, char *string);
169
170 DimService(DimServerDns *dns, const char *name, char *format, void *structure, int size);
171
172 DimService(DimServerDns *dns, const char *name, char *format, DimServiceHandler *handler);
173
174 DimService(DimServerDns *dns, const char *name, const char *format, void *structure, int size);
175
176 DimService(DimServerDns *dns, const char *name, const char *format, DimServiceHandler *handler);
177
178 virtual ~DimService();
179
180 // Update methods
181 int updateService();
182 // Update the value as well...
183 int updateService( int &value );
184 int updateService( float &value );
185 int updateService( double &value ) ;
186 int updateService( longlong &value );
187 int updateService( short &value );
188 int updateService( char *string );
189
190 int updateService( void *structure, int size );
191
192 // Selective Update methods
193 int selectiveUpdateService(int *cids);
194 // Update the value as well...
195 int selectiveUpdateService( int &value, int *cids);
196 int selectiveUpdateService( float &value, int *cids );
197 int selectiveUpdateService( double &value, int *cids );
198 int selectiveUpdateService( longlong &value, int *cids );
199 int selectiveUpdateService( short &value, int *cids );
200 int selectiveUpdateService( char *string, int *cids );
201
202 int selectiveUpdateService( void *structure, int size, int *cids );
203
204 void setQuality(int quality);
205 void setTimestamp(int secs, int millisecs);
206
207 void *itsData;
208 int itsDataSize;
209 int itsSize;
210 DisTYPE itsType;
211 void setData(void *data, int size);
212 void setData(int &data);
213 void setData(float &data);
214 void setData(double &data);
215 void setData(longlong &data);
216 void setData(short &data);
217 void setData(char *data);
218
219 virtual void serviceHandler() {};
220 // Accessors
221 char *getName();
222 int getTimeout(int clientId);
223 int getNClients();
224
225private :
226 char *itsName;
227 int itsId;
228 int itsTagId;
229 void declareIt(char *name, char *format, DimServiceHandler *handler, DimServerDns *dns);
230 void storeIt(void *data, int size);
231 DimServerDns *itsDns;
232};
233
234class DllExp CmndInfo : public SLLItem {
235 friend class DimCommand;
236 void *itsData;
237 int itsDataSize;
238 int secs, millisecs;
239public:
240 CmndInfo(void *data, int datasize, int tsecs, int tmillisecs);
241 ~CmndInfo();
242};
243
244class DllExp DimCommand : public DimCommandHandler {
245
246public :
247 DimCommandHandler *itsCommandHandler;
248
249 DimCommand(const char *name, char *format);
250
251 DimCommand(const char *name, char *format, DimCommandHandler *handler);
252
253 DimCommand(DimServerDns *dns, const char *name, char *format);
254
255 DimCommand(DimServerDns *dns, const char *name, char *format, DimCommandHandler *handler);
256
257 DimCommand(const char *name, const char *format);
258
259 DimCommand(const char *name, const char *format, DimCommandHandler *handler);
260
261 DimCommand(DimServerDns *dns, const char *name, const char *format);
262
263 DimCommand(DimServerDns *dns, const char *name, const char *format, DimCommandHandler *handler);
264
265 int getNext();
266 int hasNext();
267 void *itsData;
268 int itsSize;
269 void *getData();
270 int getInt();
271 float getFloat();
272 double getDouble();
273 longlong getLonglong();
274 short getShort();
275 char *getString();
276 int getSize();
277 char *getFormat();
278 int getTimestamp();
279 int getTimestampMillisecs();
280
281 virtual void commandHandler();
282
283 // Accessors
284 char *getName();
285 virtual ~DimCommand();
286
287private :
288 char *itsName;
289 int itsId;
290 int itsTagId;
291 char *itsFormat;
292 void declareIt(char *name, char *format, DimCommandHandler *handler, DimServerDns *dns);
293 CmndInfo *currCmnd;
294 SLList itsCmndList;
295 DimServerDns *itsDns;
296public:
297 int secs, millisecs;
298};
299
300class DllExp DimRpc
301{
302public :
303
304 // The object contains the value to be published. Service to be updated with an argument of same type;
305 DimRpc();
306
307 DimRpc(const char *name, const char *formatin, const char *formatout);
308
309 DimRpc(DimServerDns *dns, const char *name, const char *formatin, const char *formatout);
310
311 // Desctructor
312 virtual ~DimRpc();
313
314 void *itsDataIn;
315 int itsSizeIn;
316 void *getData();
317 int getInt();
318 float getFloat();
319 double getDouble();
320 longlong getLonglong();
321 short getShort();
322 char *getString();
323 int getSize();
324
325 void *itsDataOut;
326 int itsDataOutSize;
327 int itsSizeOut;
328
329 void setData(void *data, int size);
330 void setData(int &data);
331 void setData(float &data);
332 void setData(double &data);
333 void setData(longlong &data);
334 void setData(short &data);
335 void setData(char *data);
336
337 virtual void rpcHandler() = 0;
338 // Accessors
339 char *getName();
340 int itsIdIn;
341 int itsIdOut;
342private :
343 int itsTagId;
344 char *itsName;
345 char *itsNameIn;
346 char *itsNameOut;
347 void declareIt(char *name, char *formatin, char *formatout, DimServerDns *dns);
348 void storeIt(void *data, int size);
349 void timerHandler();
350 DimServerDns *itsDns;
351public:
352 int itsKilled;
353 int itsTimeout;
354};
355
356
357#endif
358
Note: See TracBrowser for help on using the repository browser.