Changeset 345 for bdm/user_info.cpp

Show
Ignore:
Timestamp:
05/20/09 23:15:05 (15 years ago)
Author:
mido
Message:

dodelano user_info, castecne predelano podle stabni kultury, zbyva otestovat a udelat dokumentaci

Files:
1 moved

Legend:

Unmodified
Added
Removed
  • bdm/user_info.cpp

    r344 r345  
    1111// 
    1212 
    13 #include "uibuilder.h" 
     13#include "user_info.h" 
    1414 
    1515namespace bdm { 
    1616 
    17 UI::StringToUIMap::MappedString2UI& UI::StringToUIMap::privateMap() 
     17UI::Class_To_UI::Class_To_UI_Map& UI::Class_To_UI::private_map() 
    1818{ 
    19         static MappedString2UI var; 
     19        static Class_To_UI_Map var; 
    2020        return var; 
    2121} 
    2222 
    23 void UI::StringToUIMap::Add( const string &className, pUI pInstance ) 
     23void UI::Class_To_UI::add_class( const string &class_name, UI* ui ) 
    2424{ 
    25         privateMap().insert( make_pair( className, pInstance ) ); 
     25        private_map().insert( make_pair( class_name, ui ) ); 
    2626} 
    2727 
    28 UI::pUI UI::StringToUIMap::Retrieve( const string &className ) 
     28UI* UI::Class_To_UI::retrieve_ui( const string &class_name ) 
    2929{ 
    30         MappedString2UI::const_iterator iter = privateMap().find( className ); 
    31         if( iter == privateMap().end()) return NULL; 
     30        Class_To_UI_Map::const_iterator iter = private_map().find( class_name ); 
     31        if( iter == private_map().end()) return NULL; 
    3232        else return iter->second; 
    3333}        
     
    3636 
    3737 
    38 UIFile::UIFile ( const string &file_name ) : fileName( file_name ) 
     38UI_File::UI_File ( const string &file_name ) : file_name( file_name ) 
    3939{ 
    40         Config::setAutoConvert( true ); 
     40        setAutoConvert( true ); 
    4141} 
    4242 
    4343//! loads root element from a file 
    44 void UIFile::Load()  
     44void UI_File::load()  
    4545{ 
    4646        try 
    4747        { 
    48                 Config::readFile( fileName.c_str()  ); 
     48                readFile( file_name.c_str()  ); 
    4949        } 
    5050        catch ( FileIOException f )  
    5151        { 
    52                 it_error ( "UI: file " + fileName + " not found." ); 
     52                it_error ( "UI error: file " + file_name + " not found." ); 
    5353        } 
    5454        catch ( ParseException& P )  
    5555        { 
    5656                stringstream msg; 
    57                 msg << "UI: parsing error """ << P.getError() << """ in file " << fileName << " on line " <<  P.getLine() << "."; 
     57                msg << "UI error: parsing ui_error """ << P.getError() << """ in file " << file_name << " on line " <<  P.getLine() << "."; 
    5858                it_error ( msg.str() ); 
    5959        }        
     
    6161 
    6262 
    63 //! Save UserInfo to the file (typically with an XML extension) 
    64 void UIFile::Save() 
     63//! save UserInfo to the file (typically with an XML extension) 
     64void UI_File::save() 
    6565{ 
    6666        try 
    6767        { 
    68                 Config::writeFile ( fileName.c_str()  ); 
     68                writeFile ( file_name.c_str()  ); 
    6969        } 
    7070        catch ( FileIOException f )  
    7171        { 
    72                 it_error( "UI: file " + fileName + " is inacessible." ); 
     72                it_error( "UI error: file " + file_name + " is inacessible." ); 
    7373        }                
    7474}        
    7575 
    76 UIFile::operator Setting&() 
     76UI_File::operator Setting&() 
    7777{ 
    7878        return getRoot(); 
     
    8080 
    8181} 
    82 /* 
    83 #include "uibuilder.h" 
    8482 
    85 namespace bdm { 
    86  
    87 //! global map of UIbulder names to instances of UIbuilders. Created by UIREGISTER macro 
    88 UIbuilder::UImap UIbuilder::__uimap__; 
    89  
    90 bdmroot* UIexternal::build ( Setting &S ) const { 
    91         Config C; 
    92         bdmroot* tmp; 
    93         try { 
    94                 C.readFile ( ( const char* ) S["filename"] ); 
    95         } 
    96         catch ( ... ) { 
    97                 it_error ( "File " + string ( ( const char* ) S["filename"] ) + " not found or broken" ); 
    98         } 
    99         try { 
    100                 Setting& remS=C.lookup ( ( const char* ) S["path"] ); 
    101                 UIbuilder::build( remS,tmp ); 
    102         } 
    103         catch ( ... ) { 
    104                 it_error ( "External field " + string ( S.getPath() ) + " not valid" ); 
    105         } 
    106         return tmp; 
    107 }; 
    108 UIREGISTER ( UIexternal ); 
    109  
    110 bdmroot* UIinternal::build ( Setting &S ) const { 
    111         bdmroot* tmp; 
    112         try { 
    113                 Setting* Stmp = &S; 
    114                 do {Stmp=& ( Stmp->getParent() );} 
    115                 while ( !Stmp->isRoot() ); 
    116                 Setting& intS=Stmp->lookup ( ( const char* ) S["path"] ); 
    117                 UIbuilder::build( intS,tmp ); 
    118         } 
    119         catch ( ... ) { 
    120                 it_error ( "Internal field " + string ( S.getPath() ) + " not valid" ); 
    121         } 
    122         return tmp; 
    123 }; 
    124 UIREGISTER ( UIinternal ); 
    125  
    126 void UI_DBG ( Setting &S, const string &spc ) { 
    127         const char *Name=S.getName(); 
    128         if ( Name!=NULL ) {cout << spc << std::string ( Name );}; 
    129         Setting::Type T=S.getType(); 
    130         switch ( T ) { 
    131                 case Setting::TypeArray: 
    132                         cout << endl; 
    133                         for ( int i=0;i<S.getLength();i++ ) {UI_DBG ( S[i], spc+" " );}; 
    134                         break; 
    135                 case Setting::TypeList: 
    136                         cout << endl; 
    137                         for ( int i=0;i<S.getLength();i++ ) {UI_DBG ( S[i], spc+" " );}; 
    138                         break; 
    139                 case Setting::TypeGroup: 
    140                         cout << endl; 
    141                         for ( int i=0;i<S.getLength();i++ ) {UI_DBG ( S[i], spc+" " );} 
    142                         break; 
    143                 case Setting::TypeInt: 
    144                         cout << " = "; 
    145                         cout << int ( S ) <<endl; 
    146                         break; 
    147                 case Setting::TypeFloat: 
    148                         cout << " = "; 
    149                         cout << double ( S ) <<endl; 
    150                         break; 
    151                 case Setting::TypeString: 
    152                         cout << " = "; 
    153                         cout << ( const char* ) ( S ) <<endl; 
    154                         break; 
    155                 case Setting::TypeBoolean: 
    156                         cout << " = "; 
    157                         cout << bool ( S ) <<endl; 
    158                         break; 
    159                 default: {cout << "?";}; 
    160         } 
    161 } 
    162  
    163 } 
    164 //UIexternal* UIexternal_instance =new UIexternal(); 
    165 */