root/tests/UI/UIbuilder_test.cpp @ 278

Revision 278, 1.2 kB (checked in by smidl, 15 years ago)

props

  • Property svn:eol-style set to native
Line 
1#include <uibuilder.h>
2
3using namespace libconfig;
4using namespace std;
5using namespace bdm;
6
7class 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};
14class cls2: public cls{
15        public:
16        cls2(int a0, string S0):cls(a0,S0){};
17        void print(){cout << a << " or "<< S << endl;}
18};
19
20class 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
32class 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
44UIREGISTER(UItest);
45UIREGISTER(UItest2);
46//UItest* UItest_instance = new UItest();
47//UItest2* UItest2_instance = new UItest2();
48
49int main(){
50UIFile UI("UIbuilder_test.cfg");
51
52cls* Cls;
53UIbuild(UI.lookup("test"),Cls);
54cls* Cls2;
55UIbuild(UI.lookup("test2"),Cls2);
56cls* Cls3;
57UIbuild(UI.lookup("test3"),Cls3);
58
59Cls->print();
60Cls2->print();
61Cls3->print(); 
62
63delete Cls;
64delete Cls2;
65delete Cls3;
66}
Note: See TracBrowser for help on using the browser.