#include using namespace libconfig; using namespace std; using namespace bdm; class cls { public: int a; string S; cls(int a0, string S0):a(a0),S(S0){}; virtual void print(){cout << a << " and "<< S << endl;} }; class cls2: public cls{ public: cls2(int a0, string S0):cls(a0,S0){}; void print(){cout << a << " or "<< S << endl;} }; class UItest : public UIbuilder{ public: UItest():UIbuilder("test"){} void build(Setting &S, void** ret) const{ try{ int a=S["a"]; string St; S.lookupValue("S",St); cls* tmp = new cls(a,St); *ret=tmp; } catch (...){ it_error(string(S.getPath()) + " is not a valid test UI"); } } }; class UItest2 : public UIbuilder{ public: UItest2():UIbuilder("test2"){} void build(Setting &S, void** ret) const{ try{ int a=S["a"]; string St; S.lookupValue("S",St); cls* tmp = new cls2(a,St); *ret=tmp; } catch (...){ it_error(string(S.getPath()) + " is not a valid test UI"); } } int no(){return 2;} }; UIREGISTER(UItest); UIREGISTER(UItest2); //UItest* UItest_instance = new UItest(); //UItest2* UItest2_instance = new UItest2(); int main(){ UIFile UI("UIbuilder_test.cfg"); cls* Cls; UIbuild(UI.lookup("test"),&Cls); cls* Cls2; UIbuild(UI.lookup("test2"),&Cls2); cls* Cls3; UIbuild(UI.lookup("test3"),&Cls3); Cls->print(); Cls2->print(); Cls3->print(); return 0; }