source: branches/fscctrl_safety_limits/dim/src/examples/Markus.cxx

Last change on this file was 11071, checked in by tbretz, 13 years ago
Replaced v19r21 by a version extracted with 'unzip -a' to get proper unix text format.
File size: 1.1 KB
Line 
1#include <iostream>
2#include <dic.hxx>
3using namespace std;
4
5class DnsInfo;
6
7class FloatInfo : public virtual DimInfoHandler
8{
9 DimInfo *fInfo;
10 float no_link, *data;
11 DnsInfo *m_dns;
12
13protected:
14 friend class DnsInfo;
15 void addHandler()
16 {
17 if(!fInfo)
18 fInfo = new DimInfo("SIMPLE_SERVICE", (void *)&no_link,
19 sizeof(no_link), this);
20 }
21 void removeHandler()
22 {
23 if(fInfo)
24 {
25 delete fInfo;
26 fInfo = 0;
27 }
28 }
29public :
30 FloatInfo()
31 {
32 fInfo = 0;
33 no_link = -1;
34 };
35 void initialize();
36 void infoHandler()
37 {
38 data = (float *)getInfo()->getData();
39 cout << "Received : " << *data << endl;
40 }
41};
42
43class DnsInfo : public DimInfo
44{
45
46 char *data;
47 FloatInfo &fInfo;
48
49 void infoHandler()
50 {
51 data = getString();
52 cout << "Received : " << data << endl;
53 if(data[0] == '+')
54 {
55 fInfo.addHandler();
56 }
57 else if (data[0] == '-')
58 {
59 fInfo.removeHandler();
60 }
61 }
62public :
63 DnsInfo(FloatInfo &f) : DimInfo("DIS_DNS/SERVER_LIST","DEAD"),
64 fInfo(f) {}
65 virtual ~DnsInfo() {}
66};
67
68void FloatInfo::initialize()
69{
70 m_dns = new DnsInfo(*this);
71}
72
73main()
74{
75 FloatInfo *fInfo;
76
77 fInfo = new FloatInfo();
78 fInfo->initialize();
79
80 while(1)
81 pause();
82}
Note: See TracBrowser for help on using the repository browser.