source: trunk/FACT++/dim_v19r15/dim/dis.hxx@ 10305

Last change on this file since 10305 was 10183, checked in by tbretz, 14 years ago
New import.
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 autoStartOn();
70 void autoStartOff();
71 int isAutoStart();
72 void addServiceId(int id);
73 int *getServiceIdList();
74private:
75 char *itsNode;
76 int itsPort;
77 long itsDnsId;
78 char *itsName;
79 int autoStart;
80 int *itsServiceIdList;
81 int itsServiceIdListSize;
82 int itsNServiceIds;
83// int itsNServices;
84};
85
86class DllExp DimServer : public DimServiceHandler, public DimCommandHandler,
87 public DimClientExitHandler, public DimExitHandler, public DimErrorHandler
88{
89public:
90 static char *clientName;
91 static char *itsName;
92 static char *dimDnsNode;
93 static int autoStart;
94 static DimClientExitHandler *itsClientExit;
95 static DimExitHandler *itsExit;
96 static DimErrorHandler *itsSrvError;
97// static int itsNServices;
98 DimServer();
99 virtual ~DimServer();
100 static void start(const char *name);
101 static void start(DimServerDns *dns, const char *name);
102 static void start();
103 static void start(DimServerDns *dns);
104 static void stop();
105 static void stop(DimServerDns *dns);
106 static void autoStartOn();
107 static void autoStartOff();
108 // Get Current Client Identifier
109 static int getClientId();
110 // Get Current Client Name
111 static char *getClientName();
112 static void setClientExitHandler(int clientId);
113 static void clearClientExitHandler(int clientId);
114 static void addClientExitHandler(DimClientExitHandler *handler);
115 void addClientExitHandler();
116 static void addExitHandler(DimExitHandler *handler);
117 static void addErrorHandler(DimErrorHandler *handler);
118 static int setDnsNode(const char *node);
119 static int setDnsNode(const char *node, int port);
120 static long addDns(const char *node, int port);
121 static void stopDns(long dnsid);
122 static char *getDnsNode();
123 static int getDnsPort();
124 static void setWriteTimeout(int secs);
125 static int getWriteTimeout();
126 void addExitHandler();
127 void addErrorHandler();
128 virtual void clientExitHandler() {};
129 virtual void exitHandler(int /* code */) {};
130 virtual void errorHandler(int /* severity */, int /* code */, char* /* msg */) {};
131// static char *getClientServices();
132// static char *getClientServices(int clientId);
133 static char **getClientServices();
134
135 virtual void serviceHandler() {};
136 virtual void commandHandler() {};
137};
138
139class DllExp DimService : public DimServiceHandler {
140
141public :
142 DimServiceHandler *itsServiceHandler;
143
144 // The object contains the value to be published. Service to be updated with an argument of same type;
145 DimService();
146
147 DimService(const char *name, int &value);
148 DimService(const char *name, float &value);
149 DimService(const char *name, double &value);
150 DimService(const char *name, longlong &value);
151 DimService(const char *name, short &value);
152 DimService(const char *name, char *string);
153
154 DimService(const char *name, char *format, void *structure, int size);
155
156 DimService(const char *name, char *format, DimServiceHandler *handler);
157
158 DimService(const char *name, const char *format, void *structure, int size);
159
160 DimService(const char *name, const char *format, DimServiceHandler *handler);
161
162 DimService(DimServerDns *dns, const char *name, int &value);
163 DimService(DimServerDns *dns, const char *name, float &value);
164 DimService(DimServerDns *dns, const char *name, double &value);
165 DimService(DimServerDns *dns, const char *name, longlong &value);
166 DimService(DimServerDns *dns, const char *name, short &value);
167 DimService(DimServerDns *dns, const char *name, char *string);
168
169 DimService(DimServerDns *dns, const char *name, char *format, void *structure, int size);
170
171 DimService(DimServerDns *dns, const char *name, char *format, DimServiceHandler *handler);
172
173 DimService(DimServerDns *dns, const char *name, const char *format, void *structure, int size);
174
175 DimService(DimServerDns *dns, const char *name, const char *format, DimServiceHandler *handler);
176
177 virtual ~DimService();
178
179 // Update methods
180 int updateService();
181 // Update the value as well...
182 int updateService( int &value );
183 int updateService( float &value );
184 int updateService( double &value ) ;
185 int updateService( longlong &value );
186 int updateService( short &value );
187 int updateService( char *string );
188
189 int updateService( void *structure, int size );
190
191 // Selective Update methods
192 int selectiveUpdateService(int *cids);
193 // Update the value as well...
194 int selectiveUpdateService( int &value, int *cids);
195 int selectiveUpdateService( float &value, int *cids );
196 int selectiveUpdateService( double &value, int *cids );
197 int selectiveUpdateService( longlong &value, int *cids );
198 int selectiveUpdateService( short &value, int *cids );
199 int selectiveUpdateService( char *string, int *cids );
200
201 int selectiveUpdateService( void *structure, int size, int *cids );
202
203 void setQuality(int quality);
204 void setTimestamp(int secs, int millisecs);
205
206 void *itsData;
207 int itsDataSize;
208 int itsSize;
209 DisTYPE itsType;
210 void setData(void *data, int size);
211 void setData(int &data);
212 void setData(float &data);
213 void setData(double &data);
214 void setData(longlong &data);
215 void setData(short &data);
216 void setData(char *data);
217
218 virtual void serviceHandler() {};
219 // Accessors
220 char *getName();
221 int getTimeout(int clientId);
222 int getNClients();
223
224private :
225 char *itsName;
226 int itsId;
227 int itsTagId;
228 void declareIt(char *name, char *format, DimServiceHandler *handler, DimServerDns *dns);
229 void storeIt(void *data, int size);
230 DimServerDns *itsDns;
231};
232
233class DllExp CmndInfo : public SLLItem {
234 friend class DimCommand;
235 void *itsData;
236 int itsDataSize;
237 int secs, millisecs;
238public:
239 CmndInfo(void *data, int datasize, int tsecs, int tmillisecs);
240 ~CmndInfo();
241};
242
243class DllExp DimCommand : public DimCommandHandler {
244
245public :
246 DimCommandHandler *itsCommandHandler;
247
248 DimCommand(const char *name, char *format);
249
250 DimCommand(const char *name, char *format, DimCommandHandler *handler);
251
252 DimCommand(DimServerDns *dns, const char *name, char *format);
253
254 DimCommand(DimServerDns *dns, const char *name, char *format, DimCommandHandler *handler);
255
256 DimCommand(const char *name, const char *format);
257
258 DimCommand(const char *name, const char *format, DimCommandHandler *handler);
259
260 DimCommand(DimServerDns *dns, const char *name, const char *format);
261
262 DimCommand(DimServerDns *dns, const char *name, const char *format, DimCommandHandler *handler);
263
264 int getNext();
265 int hasNext();
266 void *itsData;
267 int itsSize;
268 void *getData();
269 int getInt();
270 float getFloat();
271 double getDouble();
272 longlong getLonglong();
273 short getShort();
274 char *getString();
275 int getSize();
276 char *getFormat();
277 int getTimestamp();
278 int getTimestampMillisecs();
279
280 virtual void commandHandler();
281
282 // Accessors
283 char *getName();
284 virtual ~DimCommand();
285
286private :
287 char *itsName;
288 int itsId;
289 int itsTagId;
290 char *itsFormat;
291 void declareIt(char *name, char *format, DimCommandHandler *handler, DimServerDns *dns);
292 CmndInfo *currCmnd;
293 SLList itsCmndList;
294 DimServerDns *itsDns;
295public:
296 int secs, millisecs;
297};
298
299class DllExp DimRpc
300{
301public :
302
303 // The object contains the value to be published. Service to be updated with an argument of same type;
304 DimRpc();
305
306 DimRpc(const char *name, const char *formatin, const char *formatout);
307
308 DimRpc(DimServerDns *dns, const char *name, const char *formatin, const char *formatout);
309
310 // Desctructor
311 virtual ~DimRpc();
312
313 void *itsDataIn;
314 int itsSizeIn;
315 void *getData();
316 int getInt();
317 float getFloat();
318 double getDouble();
319 longlong getLonglong();
320 short getShort();
321 char *getString();
322 int getSize();
323
324 void *itsDataOut;
325 int itsDataOutSize;
326 int itsSizeOut;
327
328 void setData(void *data, int size);
329 void setData(int &data);
330 void setData(float &data);
331 void setData(double &data);
332 void setData(longlong &data);
333 void setData(short &data);
334 void setData(char *data);
335
336 virtual void rpcHandler() = 0;
337 // Accessors
338 char *getName();
339 int itsIdIn;
340 int itsIdOut;
341private :
342 int itsTagId;
343 char *itsName;
344 char *itsNameIn;
345 char *itsNameOut;
346 void declareIt(char *name, char *formatin, char *formatout, DimServerDns *dns);
347 void storeIt(void *data, int size);
348 void timerHandler();
349 DimServerDns *itsDns;
350public:
351 int itsKilled;
352 int itsTimeout;
353};
354
355
356#endif
357
Note: See TracBrowser for help on using the repository browser.