FACT++  1.0
dis.hxx
Go to the documentation of this file.
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 */
23 enum DisTYPE {
25 };
26 
27 class DimService;
28 class DimCommand;
29 
31 public:
33  DimService *getService() { return itsService; } ;
34  virtual void serviceHandler() = 0;
35  virtual ~DimServiceHandler() {};
36 };
37 
39 public:
41  DimCommand *getCommand() { return itsCommand; } ;
42  virtual void commandHandler() = 0;
43  virtual ~DimCommandHandler() {};
44 };
45 
47 public:
48  virtual void clientExitHandler() = 0;
49  virtual ~DimClientExitHandler() {};
50 };
51 
53 public:
54  virtual void exitHandler(int code) = 0;
55  virtual ~DimExitHandler() {};
56 };
57 
59 {
60 public:
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  dim_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();
75 private:
76  char *itsNode;
77  int itsPort;
79  char *itsName;
80  int autoStart;
84 // int itsNServices;
85 };
86 
89 {
90 public:
91  static char *clientName;
92  static char *itsName;
93  static char *dimDnsNode;
94  static int autoStart;
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 dim_long addDns(const char *node, int port);
122  static void stopDns(dim_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  static int inCallback();
139 };
140 
142 
143 public :
145 
146  // The object contains the value to be published. Service to be updated with an argument of same type;
147  DimService();
148 
149  DimService(const char *name, int &value);
150  DimService(const char *name, float &value);
151  DimService(const char *name, double &value);
152  DimService(const char *name, longlong &value);
153  DimService(const char *name, short &value);
154  DimService(const char *name, char *string);
155 
156  DimService(const char *name, char *format, void *structure, int size);
157 
158  DimService(const char *name, char *format, DimServiceHandler *handler);
159 
160  DimService(const char *name, const char *format, void *structure, int size);
161 
162  DimService(const char *name, const char *format, DimServiceHandler *handler);
163 
164  DimService(DimServerDns *dns, const char *name, int &value);
165  DimService(DimServerDns *dns, const char *name, float &value);
166  DimService(DimServerDns *dns, const char *name, double &value);
167  DimService(DimServerDns *dns, const char *name, longlong &value);
168  DimService(DimServerDns *dns, const char *name, short &value);
169  DimService(DimServerDns *dns, const char *name, char *string);
170 
171  DimService(DimServerDns *dns, const char *name, char *format, void *structure, int size);
172 
173  DimService(DimServerDns *dns, const char *name, char *format, DimServiceHandler *handler);
174 
175  DimService(DimServerDns *dns, const char *name, const char *format, void *structure, int size);
176 
177  DimService(DimServerDns *dns, const char *name, const char *format, DimServiceHandler *handler);
178 
179  virtual ~DimService();
180 
181  // Update methods
182  int updateService();
183  // Update the value as well...
184  int updateService( int &value );
185  int updateService( float &value );
186  int updateService( double &value ) ;
187  int updateService( longlong &value );
188  int updateService( short &value );
189  int updateService( char *string );
190 
191  int updateService( void *structure, int size );
192 
193  // Selective Update methods
194  int selectiveUpdateService(int *cids);
195  // Update the value as well...
196  int selectiveUpdateService( int &value, int *cids);
197  int selectiveUpdateService( float &value, int *cids );
198  int selectiveUpdateService( double &value, int *cids );
199  int selectiveUpdateService( longlong &value, int *cids );
200  int selectiveUpdateService( short &value, int *cids );
201  int selectiveUpdateService( char *string, int *cids );
202 
203  int selectiveUpdateService( void *structure, int size, int *cids );
204 
205  void setQuality(int quality);
206  void setTimestamp(int secs, int millisecs);
207 
208  void *itsData;
210  int itsSize;
212  void setData(void *data, int size);
213  void setData(int &data);
214  void setData(float &data);
215  void setData(double &data);
216  void setData(longlong &data);
217  void setData(short &data);
218  void setData(char *data);
219 
220  virtual void serviceHandler() {};
221  // Accessors
222  char *getName();
223  int getTimeout(int clientId);
224  int getNClients();
225 
226 private :
227  char *itsName;
228  int itsId;
229  int itsTagId;
230  void declareIt(char *name, char *format, DimServiceHandler *handler, DimServerDns *dns);
231  void storeIt(void *data, int size);
233 };
234 
235 class DllExp CmndInfo : public SLLItem {
236  friend class DimCommand;
237  void *itsData;
240 public:
241  CmndInfo(void *data, int datasize, int tsecs, int tmillisecs);
242  ~CmndInfo();
243 };
244 
246 
247 public :
249 
250  DimCommand(const char *name, char *format);
251 
252  DimCommand(const char *name, char *format, DimCommandHandler *handler);
253 
254  DimCommand(DimServerDns *dns, const char *name, char *format);
255 
256  DimCommand(DimServerDns *dns, const char *name, char *format, DimCommandHandler *handler);
257 
258  DimCommand(const char *name, const char *format);
259 
260  DimCommand(const char *name, const char *format, DimCommandHandler *handler);
261 
262  DimCommand(DimServerDns *dns, const char *name, const char *format);
263 
264  DimCommand(DimServerDns *dns, const char *name, const char *format, DimCommandHandler *handler);
265 
266  int getNext();
267  int hasNext();
268  void *itsData;
269  int itsSize;
270  void *getData();
271  int getInt();
272  float getFloat();
273  double getDouble();
274  longlong getLonglong();
275  short getShort();
276  char *getString();
277  int getSize();
278  char *getFormat();
279  int getTimestamp();
280  int getTimestampMillisecs();
281 
282  virtual void commandHandler();
283 
284  // Accessors
285  char *getName();
286  virtual ~DimCommand();
287 
288 private :
289  char *itsName;
290  int itsId;
291  int itsTagId;
292  char *itsFormat;
293  void declareIt(char *name, char *format, DimCommandHandler *handler, DimServerDns *dns);
297 public:
298  int secs, millisecs;
299 };
300 
302 {
303 public :
304 
305  // The object contains the value to be published. Service to be updated with an argument of same type;
306  DimRpc();
307 
308  DimRpc(const char *name, const char *formatin, const char *formatout);
309 
310  DimRpc(DimServerDns *dns, const char *name, const char *formatin, const char *formatout);
311 
312  // Desctructor
313  virtual ~DimRpc();
314 
315  void *itsDataIn;
317  void *getData();
318  int getInt();
319  float getFloat();
320  double getDouble();
321  longlong getLonglong();
322  short getShort();
323  char *getString();
324  int getSize();
325 
326  void *itsDataOut;
329 
330  void setData(void *data, int size);
331  void setData(int &data);
332  void setData(float &data);
333  void setData(double &data);
334  void setData(longlong &data);
335  void setData(short &data);
336  void setData(char *data);
337 
338  virtual void rpcHandler() = 0;
339  // Accessors
340  char *getName();
341  int itsIdIn;
342  int itsIdOut;
343 private :
344  int itsTagId;
345  char *itsName;
346  char *itsNameIn;
347  char *itsNameOut;
348  void declareIt(char *name, char *formatin, char *formatout, DimServerDns *dns);
349  void storeIt(void *data, int size);
350  void timerHandler();
352 public:
355 };
356 
357 
358 #endif
359 
int start(int initState)
Definition: feeserver.c:1740
SLList itsCmndList
Definition: dis.hxx:295
int itsNServiceIds
Definition: dis.hxx:83
Definition: dns.c:26
Definition: dis.hxx:301
Definition: dis.hxx:24
virtual void serviceHandler()
Definition: dis.hxx:220
int autoStart
Definition: dis.hxx:80
virtual void commandHandler()=0
void init(S &s)
Definition: ByteOrder.h:19
char * itsFormat
Definition: dis.hxx:292
Definition: dis.hxx:24
int itsTagId
Definition: dis.hxx:344
static DimClientExitHandler * itsClientExit
Definition: dis.hxx:95
DisTYPE itsType
Definition: dis.hxx:211
char * itsName
Definition: dis.hxx:345
virtual ~DimClientExitHandler()
Definition: dis.hxx:49
char * itsName
Definition: dis.hxx:227
int itsSizeIn
Definition: dis.hxx:316
int itsTimeout
Definition: dis.hxx:354
int itsPort
Definition: dis.hxx:77
int itsTagId
Definition: dis.hxx:229
static char * dimDnsNode
Definition: dis.hxx:93
char * itsNode
Definition: dis.hxx:76
void * itsData
Definition: dis.hxx:268
virtual void errorHandler(int, int, char *)
Definition: dis.hxx:131
dim_long itsDnsId
Definition: dis.hxx:78
int itsDataSize
Definition: dis.hxx:238
int itsSizeOut
Definition: dis.hxx:328
static DimExitHandler * itsExit
Definition: dis.hxx:96
char * itsName
Definition: dis.hxx:79
static char * clientName
Definition: dis.hxx:91
DimCommand * getCommand()
Definition: dis.hxx:41
virtual ~DimCommandHandler()
Definition: dis.hxx:43
int itsIdOut
Definition: dis.hxx:342
int itsServiceIdListSize
Definition: dis.hxx:82
#define DllExp
Definition: dim_common.h:93
int itsIdIn
Definition: dis.hxx:341
char * itsNameOut
Definition: dis.hxx:347
char * itsName
Definition: dis.hxx:289
int * itsServiceIdList
Definition: dis.hxx:81
virtual void commandHandler()
Definition: dis.hxx:137
static int autoStart
Definition: dis.hxx:94
int itsTagId
Definition: dis.hxx:291
DimCommand * itsCommand
Definition: dis.hxx:40
long dim_long
Definition: dim_common.h:57
DimCommandHandler * itsCommandHandler
Definition: dis.hxx:248
DimServerDns * itsDns
Definition: dis.hxx:296
CmndInfo * currCmnd
Definition: dis.hxx:294
int secs
Definition: dis.hxx:239
Definition: dis.hxx:24
virtual void exitHandler(int)
Definition: dis.hxx:130
char * itsNameIn
Definition: dis.hxx:346
static DimErrorHandler * itsSrvError
Definition: dis.hxx:97
virtual ~DimServiceHandler()
Definition: dis.hxx:35
virtual void clientExitHandler()
Definition: dis.hxx:129
DimService * itsService
Definition: dis.hxx:32
int size
Definition: db_dim_server.c:17
void * itsDataOut
Definition: dis.hxx:326
float data[4 *1440]
DimServiceHandler * itsServiceHandler
Definition: dis.hxx:144
int64_t longlong
Definition: dim_common.h:56
DisTYPE
Definition: dis.hxx:23
virtual void serviceHandler()
Definition: dis.hxx:136
virtual ~DimExitHandler()
Definition: dis.hxx:55
static void handler(int conn_id, char *packet, int size, int status)
Definition: webServer.c:635
int itsDataSize
Definition: dis.hxx:209
int secs
Definition: dis.hxx:298
Definition: dis.hxx:24
static char * itsName
Definition: dis.hxx:92
int itsSize
Definition: dis.hxx:210
DimService * getService()
Definition: dis.hxx:33
void * itsDataIn
Definition: dis.hxx:315
int itsId
Definition: dis.hxx:228
void * itsData
Definition: dis.hxx:208
dnsid
Definition: README_v19.txt:372
int itsId
Definition: dis.hxx:290
DimServerDns * itsDns
Definition: dis.hxx:351
int itsDataOutSize
Definition: dis.hxx:327
DimServerDns * itsDns
Definition: dis.hxx:232
int millisecs
Definition: dis.hxx:298
int itsSize
Definition: dis.hxx:269
void * itsData
Definition: dis.hxx:237
int itsKilled
Definition: dis.hxx:353