Changeset 357 for bdm/user_info.h

Show
Ignore:
Timestamp:
06/08/09 02:15:30 (15 years ago)
Author:
mido
Message:

mnoho zmen:
1) presun FindXXX modulu do \system
2) zalozeni dokumentace \doc\local\library_structure.dox
3) presun obsahu \tests\UI primo do \tests
4) namisto \INSTALL zalozen \install.html, je to vhodnejsi pro uzivatele WINDOWS, a snad i obecne
5) snaha o predelani veskerych UI podle nove koncepce, soubory pmsm_ui.h, arx_ui.h, KF_ui.h, libDS_ui.h, libEF_ui.h a loggers_ui.h ponechavam
jen zdokumentacnich duvodu, nic by na nich jiz nemelo zaviset, a po zkontrolovani spravnosti provedenych uprav by mely byt smazany
6) predelani estimatoru tak, aby fungoval s novym UI konceptem
7) vytazeni tridy bdmroot do samostatneho souboru \bdm\bdmroot.h
8) pridana dokumentace pro zacleneni programu ASTYLE do Visual studia, ASTYLE pridan do instalacniho balicku pro Windows

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • bdm/user_info.h

    r351 r357  
    1 #ifndef UIBUILD 
    2 #define UIBUILD 
    3  
    4  
    5 #include <sstream> 
    6 #include <iostream> 
     1#ifndef USER_INFO_H 
     2#define USER_INFO_H 
     3 
    74#include <stdio.h> 
    85#include <string> 
    96#include <typeinfo> 
    107#include <map> 
    11 #include <utility> 
    12 #include <vector> 
    13 #include <iostream> 
    148 
    159#include "libconfig/libconfig.h++" 
    16  
    17 #include <itpp/itbase.h> 
    18  
    19 #include "stat/libBM.h" 
     10#include "bdmroot.h" 
     11#include "itpp/itbase.h" 
     12 
    2013 
    2114using std::string; 
     
    3528 
    3629public: 
    37         //! attach new RootElement instance to a file (typically with an XML extension) 
     30        //! create empty object prepared to store Settings 
     31        UI_File(); 
     32 
     33        //! creates object and fills it from a file 
    3834        UI_File( const string &file_name ); 
    3935 
    40         //! loads root element from a file 
    41         void load(); 
    42  
    43         //! save UserInfo to the file (typically with an XML extension) 
    44         void save(); 
     36        //! save UserInfo to the file  
     37        void save(const string &file_name); 
    4538 
    4639        operator Setting&(); 
     
    141134        //! and build DOM tree accordingly. Then, it creates a new DOMNode named according class_name 
    142135        //! and connecti it to the passed Setting as a new child node. 
    143         static const Setting* pointer_to_child_setting( const Setting &element, const int index ); 
    144  
    145         static const Setting* pointer_to_child_setting( const Setting &element, const string &name ); 
    146  
    147         static const Setting& reference_to_child_setting( const Setting &element, const int index ); 
    148  
    149         static const Setting& reference_to_child_setting( const Setting &element, const string &name ); 
     136        static const Setting& to_child_setting( const Setting &element, const int index ); 
     137 
     138        static const Setting& to_child_setting( const Setting &element, const string &name ); 
    150139 
    151140 
     
    153142        static void from_setting( mat& matrix, const Setting &element );         
    154143        //! This methods tries to build a new integer vector 
    155         static void from_setting( ivec &vec, const Setting &element ); 
     144        static void from_setting( ivec &vector, const Setting &element ); 
    156145        // jednak kvuli pretypovani, apak taky proto, ze na string nefunguje link_expander.. 
    157146        static void from_setting( string &str, const Setting &element ); 
    158147        //! This methods tries to build a new templated array  
     148 
     149        static void from_setting( vec &vector, const Setting &element ); 
    159150 
    160151        template<class T> static void from_setting( T* &instance, const Setting &element ) 
     
    213204        } 
    214205 
     206        static void ui_error( string message, const Setting &element ); 
     207 
    215208protected: 
    216209        //! default constructor  
     
    223216        virtual ~UI(){}; 
    224217 
    225  
    226218public:  
    227         static void ui_error( string message, const Setting &element ) 
    228         { 
    229                 stringstream error_message; 
    230                 error_message << "UI ui_error: " << message << "! Check path """ << element.getPath() << """, source line " << element.getSourceLine() << "."; 
    231                 it_error ( error_message.str() ); 
    232         } 
    233  
    234219        //! This methods tries to build a new instance of type T (or some of its descendant types) 
    235220        //! according to a data stored in a DOMNode named class_name within a child nodes of the passed element. 
    236         //! If an ui_error occurs, it returns a NULL pointer. 
     221        //! If an error occurs, it returns a NULL pointer. 
    237222 
    238223        //! Prototype of a UI builder. Return value is by the second argument since it type checking via \c dynamic_cast. 
     
    240225        { 
    241226                T* instance; 
    242                 from_setting<T>( reference_to_child_setting( element, index ) ); 
     227                from_setting<T>( to_child_setting( element, index ) ); 
    243228                return instance; 
    244229        } 
     
    247232        {                        
    248233                T* instance; 
    249                 from_setting<T>( instance, reference_to_child_setting( element, name ) ); 
     234                from_setting<T>( instance, to_child_setting( element, name ) ); 
    250235                return instance; 
    251236        } 
    252237 
    253238        //! This methods tries to build a new double matrix  
    254         template<class T> static bool get( T &instance, const Setting &element, const string &name ) 
    255         { 
    256                 const Setting *root = pointer_to_child_setting( element, name ); 
    257                 if( !root ) return false;                                
    258                 from_setting( instance, *root ); 
    259                 return true; 
    260         } 
    261  
    262         //! This methods tries to build a new double matrix  
    263         template<class T> static bool get( T &instance, const Setting &element, const int index ) 
    264         { 
    265                 const Setting *root = pointer_to_child_setting( element, index ); 
    266                 if( !root ) return false;                                
    267                 from_setting( instance, *root ); 
    268                 return true; 
    269         } 
    270  
    271         //! This methods tries to build a new double matrix  
    272         template<class T> static bool get( Array<T> &array_to_load, const Setting &element, const string &name ) 
    273         { 
    274                 const Setting *root = pointer_to_child_setting( element, name ); 
    275                 if( !root ) return false;                                
    276                 from_setting( array_to_load, *root ); 
    277                 return true; 
    278         } 
    279  
    280         //! This methods tries to build a new double matrix  
    281         template<class T> static bool get( Array<T> &array_to_load, const Setting &element, const int index ) 
    282         { 
    283                 const Setting *root = pointer_to_child_setting( element, index ); 
    284                 if( !root ) return false;                                
    285                 from_setting( array_to_load, *root ); 
    286                 return true; 
     239        template<class T> static void get( T &instance, const Setting &element, const string &name ) 
     240        { 
     241                from_setting( instance, to_child_setting( element, name ) ); 
     242        } 
     243 
     244        //! This methods tries to build a new double matrix  
     245        template<class T> static void get( T &instance, const Setting &element, const int index ) 
     246        { 
     247                from_setting( instance, to_child_setting( element, index ) ); 
     248        } 
     249 
     250        //! This methods tries to build a new double matrix  
     251        template<class T> static void get( Array<T> &array_to_load, const Setting &element, const string &name ) 
     252        { 
     253                from_setting( array_to_load, to_child_setting( element, name ) ); 
     254        } 
     255 
     256        //! This methods tries to build a new double matrix  
     257        template<class T> static void get( Array<T> &array_to_load, const Setting &element, const int index ) 
     258        { 
     259                from_setting( array_to_load, to_child_setting( element, index ) ); 
    287260        } 
    288261 
     
    325298        static void save( const ivec &vec, Setting &element, const string &name = "" ); 
    326299         
     300        static void save( const vec &vector, Setting &element, const string &name); 
     301 
    327302        private:  
    328303        //! This methods tries to save a double vec  
     
    385360*/ 
    386361 
    387 #endif // #ifndef UIBUILD 
     362#endif // #ifndef USER_INFO_H