root/bdm/uibuilder.cpp @ 260

Revision 260, 1.8 kB (checked in by smidl, 15 years ago)

working UI example

Line 
1#include "uibuilder.h"
2
3namespace bdm{
4       
5UImap __uimap__;
6
7bdmroot* UIexternal::build(Setting &S) const{
8        Config C;
9        bdmroot* tmp;
10        try{
11                C.readFile((const char*)S["filename"]);
12        } catch (...){
13                it_error("File " + string((const char*)S["filename"]) + " not found or broken");
14        }
15        try {   
16                Setting& remS=C.lookup((const char*)S["path"]);
17                UIbuild(remS,tmp);
18        }
19        catch (...) { it_error("External field " + string(S.getPath()) + " not valid");
20        }
21        return tmp;
22};
23UIREGISTER(UIexternal);
24
25bdmroot* UIinternal::build(Setting &S) const{
26        bdmroot* tmp;
27        try {   
28                Setting* Stmp = &S;
29                do {Stmp=&(Stmp->getParent());} while (!Stmp->isRoot());
30                Setting& intS=Stmp->lookup((const char*)S["path"]);
31                UIbuild(intS,tmp);
32        }
33        catch (...) { it_error("Internal field " + string(S.getPath()) + " not valid");
34        }
35        return tmp;
36};
37UIREGISTER(UIinternal);
38
39        void UI_DBG ( Setting &S, const string &spc ) {
40                const char *Name=S.getName();
41                if ( Name!=NULL ) {cout << spc << std::string ( Name );};
42                Setting::Type T=S.getType();
43                switch ( T ) {
44                        case Setting::TypeArray:
45                                cout << endl;
46                                for ( int i=0;i<S.getLength();i++ ) {UI_DBG ( S[i], spc+" " );};
47                                break;
48                        case Setting::TypeList:
49                                cout << endl;
50                                for ( int i=0;i<S.getLength();i++ ) {UI_DBG ( S[i], spc+" " );};
51                                break;
52                        case Setting::TypeGroup:
53                                cout << endl;
54                                for ( int i=0;i<S.getLength();i++ ) {UI_DBG ( S[i], spc+" " );}
55                                break;
56                        case Setting::TypeInt:
57                                cout << " = ";
58                                cout << int ( S ) <<endl;
59                                break;
60                        case Setting::TypeFloat:
61                                cout << " = ";
62                                cout << double ( S ) <<endl;
63                                break;
64                        case Setting::TypeString:
65                                cout << " = ";
66                                cout << ( const char* ) ( S ) <<endl;
67                                break;
68                        case Setting::TypeBoolean:
69                                cout << " = ";
70                                cout << bool ( S ) <<endl;
71                                break;
72                                default: {cout << "?";};
73                }
74        }
75
76}
77//UIexternal* UIexternal_instance =new UIexternal();
Note: See TracBrowser for help on using the browser.