root/bdm/uibuilder.cpp @ 278

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

props

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