Revision 278, 1.2 kB
(checked in by smidl, 16 years ago)
|
props
|
-
Property svn:eol-style set to
native
|
Line | |
---|
1 | #include <uibuilder.h> |
---|
2 | |
---|
3 | using namespace libconfig; |
---|
4 | using namespace std; |
---|
5 | using namespace bdm; |
---|
6 | |
---|
7 | class cls :public bdmroot{ |
---|
8 | public: |
---|
9 | int a; |
---|
10 | string S; |
---|
11 | cls(int a0, string S0):a(a0),S(S0){}; |
---|
12 | virtual void print(){cout << a << " and "<< S << endl;} |
---|
13 | }; |
---|
14 | class cls2: public cls{ |
---|
15 | public: |
---|
16 | cls2(int a0, string S0):cls(a0,S0){}; |
---|
17 | void print(){cout << a << " or "<< S << endl;} |
---|
18 | }; |
---|
19 | |
---|
20 | class UItest : public UIbuilder{ |
---|
21 | public: |
---|
22 | UItest():UIbuilder("test"){} |
---|
23 | bdmroot* build(Setting &S) const{ |
---|
24 | int a=S["a"]; |
---|
25 | string St; |
---|
26 | S.lookupValue("S",St); |
---|
27 | cls* tmp = new cls(a,St); |
---|
28 | return tmp; |
---|
29 | } |
---|
30 | }; |
---|
31 | |
---|
32 | class UItest2 : public UIbuilder{ |
---|
33 | public: |
---|
34 | UItest2():UIbuilder("test2"){} |
---|
35 | bdmroot* build(Setting &S) const{ |
---|
36 | int a=S["a"]; |
---|
37 | string St; |
---|
38 | S.lookupValue("S",St); |
---|
39 | return new cls2(a,St); |
---|
40 | } |
---|
41 | int no(){return 2;} |
---|
42 | }; |
---|
43 | |
---|
44 | UIREGISTER(UItest); |
---|
45 | UIREGISTER(UItest2); |
---|
46 | //UItest* UItest_instance = new UItest(); |
---|
47 | //UItest2* UItest2_instance = new UItest2(); |
---|
48 | |
---|
49 | int main(){ |
---|
50 | UIFile UI("UIbuilder_test.cfg"); |
---|
51 | |
---|
52 | cls* Cls; |
---|
53 | UIbuild(UI.lookup("test"),Cls); |
---|
54 | cls* Cls2; |
---|
55 | UIbuild(UI.lookup("test2"),Cls2); |
---|
56 | cls* Cls3; |
---|
57 | UIbuild(UI.lookup("test3"),Cls3); |
---|
58 | |
---|
59 | Cls->print(); |
---|
60 | Cls2->print(); |
---|
61 | Cls3->print(); |
---|
62 | |
---|
63 | delete Cls; |
---|
64 | delete Cls2; |
---|
65 | delete Cls3; |
---|
66 | } |
---|