[249] | 1 | #include <uibuilder.h> |
---|
[244] | 2 | |
---|
| 3 | using namespace libconfig; |
---|
| 4 | using namespace std; |
---|
[254] | 5 | using namespace bdm; |
---|
[244] | 6 | |
---|
[256] | 7 | class cls :public bdmroot{ |
---|
[244] | 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"){} |
---|
[256] | 23 | void build(Setting &S, bdmroot* &ret) const{ |
---|
[244] | 24 | try{ |
---|
| 25 | int a=S["a"]; |
---|
| 26 | string St; |
---|
| 27 | S.lookupValue("S",St); |
---|
| 28 | cls* tmp = new cls(a,St); |
---|
[256] | 29 | ret=tmp; |
---|
[244] | 30 | } |
---|
| 31 | catch (...){ |
---|
| 32 | it_error(string(S.getPath()) + " is not a valid test UI"); |
---|
| 33 | } |
---|
| 34 | } |
---|
| 35 | }; |
---|
| 36 | |
---|
| 37 | class UItest2 : public UIbuilder{ |
---|
| 38 | public: |
---|
| 39 | UItest2():UIbuilder("test2"){} |
---|
[256] | 40 | void build(Setting &S, bdmroot* &ret) const{ |
---|
[244] | 41 | try{ |
---|
| 42 | int a=S["a"]; |
---|
| 43 | string St; |
---|
| 44 | S.lookupValue("S",St); |
---|
| 45 | cls* tmp = new cls2(a,St); |
---|
[256] | 46 | ret=tmp; |
---|
[244] | 47 | } |
---|
| 48 | catch (...){ |
---|
| 49 | it_error(string(S.getPath()) + " is not a valid test UI"); |
---|
| 50 | } |
---|
| 51 | } |
---|
| 52 | int no(){return 2;} |
---|
| 53 | }; |
---|
| 54 | |
---|
| 55 | UIREGISTER(UItest); |
---|
| 56 | UIREGISTER(UItest2); |
---|
| 57 | //UItest* UItest_instance = new UItest(); |
---|
| 58 | //UItest2* UItest2_instance = new UItest2(); |
---|
| 59 | |
---|
| 60 | int main(){ |
---|
[246] | 61 | UIFile UI("UIbuilder_test.cfg"); |
---|
[244] | 62 | |
---|
| 63 | cls* Cls; |
---|
[256] | 64 | UIbuild(UI.lookup("test"),Cls); |
---|
[244] | 65 | cls* Cls2; |
---|
[256] | 66 | UIbuild(UI.lookup("test2"),Cls2); |
---|
[246] | 67 | cls* Cls3; |
---|
[256] | 68 | UIbuild(UI.lookup("test3"),Cls3); |
---|
[244] | 69 | |
---|
| 70 | Cls->print(); |
---|
| 71 | Cls2->print(); |
---|
[256] | 72 | Cls3->print(); |
---|
| 73 | |
---|
| 74 | delete Cls; |
---|
| 75 | delete Cls2; |
---|
| 76 | delete Cls3; |
---|
[244] | 77 | } |
---|