Changeset 344 for bdm/uibuilder.cpp

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

funkcni verze noveho UI, zbyva jeste ucesat

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • bdm/uibuilder.cpp

    r281 r344  
     1// 
     2// C++ Implementation: itpp_ext 
     3// 
     4// Description: 
     5// 
     6// 
     7// Author: smidl <smidl@utia.cas.cz>, (C) 2008 
     8// 
     9// Copyright: See COPYING file that comes with this distribution 
     10// 
     11// 
     12 
     13#include "uibuilder.h" 
     14 
     15namespace bdm { 
     16 
     17UI::StringToUIMap::MappedString2UI& UI::StringToUIMap::privateMap() 
     18{ 
     19        static MappedString2UI var; 
     20        return var; 
     21} 
     22 
     23void UI::StringToUIMap::Add( const string &className, pUI pInstance ) 
     24{ 
     25        privateMap().insert( make_pair( className, pInstance ) ); 
     26} 
     27 
     28UI::pUI UI::StringToUIMap::Retrieve( const string &className ) 
     29{ 
     30        MappedString2UI::const_iterator iter = privateMap().find( className ); 
     31        if( iter == privateMap().end()) return NULL; 
     32        else return iter->second; 
     33}        
     34 
     35////////////////////////////////////////////////////////////////////// 
     36 
     37 
     38UIFile::UIFile ( const string &file_name ) : fileName( file_name ) 
     39{ 
     40        Config::setAutoConvert( true ); 
     41} 
     42 
     43//! loads root element from a file 
     44void UIFile::Load()  
     45{ 
     46        try 
     47        { 
     48                Config::readFile( fileName.c_str()  ); 
     49        } 
     50        catch ( FileIOException f )  
     51        { 
     52                it_error ( "UI: file " + fileName + " not found." ); 
     53        } 
     54        catch ( ParseException& P )  
     55        { 
     56                stringstream msg; 
     57                msg << "UI: parsing error """ << P.getError() << """ in file " << fileName << " on line " <<  P.getLine() << "."; 
     58                it_error ( msg.str() ); 
     59        }        
     60} 
     61 
     62 
     63//! Save UserInfo to the file (typically with an XML extension) 
     64void UIFile::Save() 
     65{ 
     66        try 
     67        { 
     68                Config::writeFile ( fileName.c_str()  ); 
     69        } 
     70        catch ( FileIOException f )  
     71        { 
     72                it_error( "UI: file " + fileName + " is inacessible." ); 
     73        }                
     74}        
     75 
     76UIFile::operator Setting&() 
     77{ 
     78        return getRoot(); 
     79} 
     80 
     81} 
     82/* 
    183#include "uibuilder.h" 
    284 
     
    486 
    587//! global map of UIbulder names to instances of UIbuilders. Created by UIREGISTER macro 
    6 UImap __uimap__; 
     88UIbuilder::UImap UIbuilder::__uimap__; 
    789 
    890bdmroot* UIexternal::build ( Setting &S ) const { 
     
    1799        try { 
    18100                Setting& remS=C.lookup ( ( const char* ) S["path"] ); 
    19                 UIbuild ( remS,tmp ); 
     101                UIbuilder::build( remS,tmp ); 
    20102        } 
    21103        catch ( ... ) { 
     
    33115                while ( !Stmp->isRoot() ); 
    34116                Setting& intS=Stmp->lookup ( ( const char* ) S["path"] ); 
    35                 UIbuild ( intS,tmp ); 
     117                UIbuilder::build( intS,tmp ); 
    36118        } 
    37119        catch ( ... ) { 
     
    81163} 
    82164//UIexternal* UIexternal_instance =new UIexternal(); 
     165*/