Changeset 377 for bdm/user_info.h

Show
Ignore:
Timestamp:
06/15/09 18:27:16 (15 years ago)
Author:
mido
Message:

1) globalni prejmenovani Setting &root na Setting &set
2) smazani par zastaralych adresaru
3) oprava warningu v doc\local
4) prejmenovani SettingsResolver? na SettingResolver? a drobne vylepseni funkcnosti
5) odstranena duplikace kodu v user_info.cpp

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • bdm/user_info.h

    r370 r377  
    137137        template<class T> static void from_setting( T* &instance, const Setting &element ) 
    138138        {                        
    139                 const SettingsResolver link_expander( element ); 
    140                 const Setting &root = link_expander.root(); 
    141  
    142                 ASSERT_UITYPE(root,TypeGroup); 
     139                const SettingResolver link( element ); 
     140 
     141                ASSERT_UITYPE(link.result,TypeGroup); 
    143142 
    144143                // we get a velue stored in the "class" attribute  
    145144                string class_name; 
    146                 if( !root.lookupValue( "class", class_name ) ) 
    147                         ui_error( "the obligatory ""class"" identifier is missing", root ); 
     145                if( !link.result.lookupValue( "class", class_name ) ) 
     146                        ui_error( "the obligatory ""class"" identifier is missing", link.result ); 
    148147         
    149148                // and finally we find a UserInfo related to this type 
     
    164163                try 
    165164                { 
    166                         instance->from_setting( root ); 
     165                        instance->from_setting( link.result ); 
    167166                } 
    168167                catch(SettingException xcptn) 
     
    177176        template<class T> static void from_setting( Array<T> &array_to_load, const Setting &element ) 
    178177        { 
    179                 const SettingsResolver link_expander( element ); 
    180                 const Setting &root = link_expander.root(); 
    181  
    182                 ASSERT_UITYPE(root,TypeList); 
    183  
    184                 int len = root.getLength(); 
     178                const SettingResolver link( element ); 
     179 
     180                ASSERT_UITYPE(link.result,TypeList); 
     181 
     182                int len = link.result.getLength(); 
    185183                array_to_load.set_length( len ); 
    186184                if( len == 0 ) return; 
    187185                 
    188186                for( int i=0; i < len; i++ )  
    189                         from_setting( array_to_load(i), root[i] );  
     187                        from_setting( array_to_load(i), link.result[i] );  
    190188        } 
    191189 
     
    212210        // vraci true, kdyz to byl platny link, jinak false.. v pripade chyby konci it_errorem.. 
    213211        // do elementu vrati setting prislusny po rozbaleni linku, jinak ponecha beze zmeny 
    214         class SettingsResolver   
     212        class SettingResolver    
    215213        { 
    216214        private: 
    217215                UI_File *file; 
    218                 const Setting *result; 
     216 
     217                const Setting &initialize_reference( UI_File* &file, const Setting &potential_link); 
    219218 
    220219        public: 
    221  
    222                 SettingsResolver( const Setting &potential_link ); 
     220                const Setting &result; 
     221 
     222                SettingResolver( const Setting &potential_link ); 
    223223                 
    224                 ~SettingsResolver(); 
    225                  
    226                 const Setting& root() const; 
     224                ~SettingResolver();              
    227225        }; 
    228226 
     
    270268        template< class T> static void save( const T * const instance, Setting &element, const string &name = "") 
    271269        { 
    272                 Setting &root = (name == "") ? element.add( Setting::TypeGroup )                                                         
     270                Setting &set = (name == "") ? element.add( Setting::TypeGroup )                                                  
    273271                                                                         : element.add( name, Setting::TypeGroup );              
    274272 
     
    276274                         
    277275                // add attribute "class"  
    278                 Setting &type = root.add( "class", Setting::TypeString ); 
     276                Setting &type = set.add( "class", Setting::TypeString ); 
    279277                type = class_name; 
    280278 
    281279                try 
    282280                { 
    283                         instance->to_setting( root ); 
     281                        instance->to_setting( set ); 
    284282                } 
    285283                catch(SettingException xcptn)