root/bdm/uibuilder.cpp @ 281

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

new version of mpf_test for TR2245

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