Changeset 394

Show
Ignore:
Timestamp:
06/22/09 13:10:28 (15 years ago)
Author:
mido
Message:

1) UI_File renamed to UIFile
2) part UI's documentation
3) stat/mixtures.h renamed to stat/emix.h and related changes applied

Files:
15 modified
5 moved

Legend:

Unmodified
Added
Removed
  • applications/bdmtoolbox/estimator.cpp

    r391 r394  
    6464        } 
    6565        fname = "arx_test.cfg"; 
    66         UI_File F ( fname ); 
     66        UIFile F ( fname ); 
    6767 
    6868        logger* L = UI::build<logger>( F, "logger"); 
  • applications/bdmtoolbox/mex/estimator.cpp

    r384 r394  
    2121         
    2222        printf("name: %s", fname.c_str()); 
    23         UI_File F ( fname.c_str()); 
     23        UIFile F ( fname.c_str()); 
    2424 
    2525        logger* L = UI::build<logger>( F, "logger"); 
  • applications/bdmtoolbox/mex/merger.cpp

    r393 r394  
    55int main() 
    66{ 
    7   UI_File Cfg("merger_mx.cfg"); 
     7  UIFile Cfg("merger_mx.cfg"); 
    88         
    99        // Sources 
  • applications/pmsm/TR2245/pmsm_wishart.cpp

    r384 r394  
    2626        if ( argc>1 ) {fname = argv[1]; } 
    2727        else { fname = "pmsm_wishart.cfg"; } 
    28         UI_File F ( fname ); 
     28        UIFile F ( fname ); 
    2929 
    3030        double h = 1e-6; 
  • applications/pmsm/TR2245/unitsteps.cpp

    r384 r394  
    3030        if ( argc>1 ) {fname = argv[1]; } 
    3131        else { fname = "unitsteps.cfg"; } 
    32         UI_File F ( fname ); 
     32        UIFile F ( fname ); 
    3333 
    3434        double h = 1e-6; 
  • applications/pmsm/TR2245/wishart.cpp

    r384 r394  
    2929        if ( argc>1 ) {fname = argv[1]; } 
    3030        else { fname = "unitsteps.cfg"; } 
    31         UI_File F ( fname ); 
     31        UIFile F ( fname ); 
    3232 
    3333        double h = 1e-6; 
  • applications/pmsm/pmsm_estim.cpp

    r384 r394  
    1818        if ( argc>1 ) {fname = argv[1]; } 
    1919        else { cout << "Missing configuration file.\n Usage: \n $> estimator config_file.cfg"<<endl; abort(); } 
    20         UI_File F ( fname ); 
     20        UIFile F ( fname ); 
    2121 
    2222        logger* L = UI::build <logger>( F, "logger" ); 
  • library/bdm/CMakeLists.txt

    r384 r394  
    33SET(bdm_base base/bdmbase.cpp base/bdmbase.h base/datasources.cpp base/datasources.h base/loggers.cpp base/loggers.h) 
    44SET(bdm_math math/square_mat.cpp math/square_mat.h math/chmat.cpp math/chmat.h math/functions.cpp math/functions.h) 
    5 SET(bdm_stat stat/exp_family.cpp stat/exp_family.h stat/mixtures.cpp stat/mixtures.h stat/merger.h stat/merger.cpp) 
     5SET(bdm_stat stat/exp_family.cpp stat/exp_family.h stat/emix.cpp stat/emix.h stat/merger.h stat/merger.cpp) 
    66SET(bdm_estim estim/kalman.cpp estim/kalman.h estim/particles.cpp estim/particles.h estim/arx.cpp estim/arx.h estim/mixtures.cpp estim/mixtures.h) 
    77SET(bdm_user_info base/libconfig/libconfigcpp.cc base/libconfig/grammar.c base/libconfig/libconfig.c base/libconfig/scanner.c base/user_info.cpp base/user_info.h ) 
  • library/bdm/base/user_info.cpp

    r392 r394  
    1515namespace bdm 
    1616{ 
    17 ///////////////////////// UI FILE ///////////////////////////////////////////// 
    18  
    19 UI_File::UI_File () 
    20 { 
    21     setAutoConvert( true ); 
    22 } 
    23  
    24 //! loads root element from a file 
    25 UI_File::UI_File ( const string &file_name ) 
     17///////////////////////////// Class UIFile ///////////////////////////////////////////// 
     18 
     19UIFile::UIFile() 
     20{ 
     21} 
     22 
     23UIFile::UIFile ( const string &file_name ) 
    2624{ 
    2725    try 
    2826    { 
    2927        readFile( file_name.c_str()  ); 
    30         setAutoConvert( true ); 
     28                // this flag has to be set AFTER each file load, that is why it is right here 
     29                setAutoConvert( true ); 
    3130    } 
    3231    catch ( FileIOException f ) 
     
    4342 
    4443 
    45 //! save UserInfo to the file (typically with an XML extension) 
    46 void UI_File::save(  const string &file_name ) 
     44void UIFile::save(const string &file_name ) 
    4745{ 
    4846    try 
     
    5654} 
    5755 
    58 UI_File::operator Setting&() 
     56UIFile::operator Setting&() 
    5957{ 
    6058    return getRoot(); 
    6159} 
    62 ///////////////////////// INTERNAL MAPPED_UI ///////////////////////////////////////////// 
    63  
    64 UI::Mapped_UI::String_To_UI_Map& UI::Mapped_UI::mapped_strings() 
    65 { 
    66     static String_To_UI_Map var; 
     60 
     61///////////////////////////// Class UI::MappedUI ///////////////////////////////////////////// 
     62 
     63UI::MappedUI::StringToUIMap& UI::MappedUI::mapped_strings() 
     64{ 
     65        // this way it is ensured that there is only one instance of StringTpUIMap, and  
     66        // what is more, this declaration leaves its allocation/deallocation on the compiler 
     67    static StringToUIMap var; 
    6768    return var; 
    6869} 
    6970 
    70 UI::Mapped_UI::Type_Info_To_String_Map& UI::Mapped_UI::mapped_type_infos() 
    71 { 
    72     static Type_Info_To_String_Map var; 
     71UI::MappedUI::TypeInfoToStringMap& UI::MappedUI::mapped_type_infos() 
     72{ 
     73        // this way it is ensured that there is only one instance of TypeInfoToStringMap, and  
     74        // what is more, this declaration leaves its allocation/deallocation on the compiler 
     75    static TypeInfoToStringMap var; 
    7376    return var; 
    7477} 
    7578 
    76 void UI::Mapped_UI::add_class( const string &class_name, const type_info * const class_type_info, const UI* const ui ) 
     79void UI::MappedUI::add_class( const string &class_name, const type_info * const class_type_info, const UI* const ui ) 
    7780{ 
    7881    pair< const string, const UI* const > new_pair = make_pair( class_name, ui ); 
     
    8184} 
    8285 
    83 const UI& UI::Mapped_UI::retrieve_ui( const string &class_name ) 
    84 { 
    85     String_To_UI_Map::const_iterator iter = mapped_strings().find( class_name ); 
     86void UI::MappedUI::unregistered_class_error( const string &unregistered_class_name ) 
     87{ 
     88        stringstream msg; 
     89    msg << "UI error: class " + unregistered_class_name + " was not properly registered. Use the macro ""UIREGISTER([class name]);"" within your code." << endl; 
     90 
     91        if( mapped_strings().size() ) 
     92        { 
     93            StringToUIMap::const_iterator iter = mapped_strings().begin(); 
     94                msg << "These classes are already registered: " << iter->first; 
     95                for(; iter != mapped_strings().end(); iter++) 
     96                        msg << ", " << iter->first; 
     97                msg << "." << endl; 
     98        }                        
     99        else 
     100                msg << "There is not any registered class yet!" << endl; 
     101         
     102    it_error ( msg.str() );              
     103} 
     104 
     105const UI& UI::MappedUI::retrieve_ui( const string &class_name ) 
     106{ 
     107    StringToUIMap::const_iterator iter = mapped_strings().find( class_name ); 
    86108    if ( iter == mapped_strings().end()) 
    87                 // TODO dat sem vypis seznamu registrovanych trid 
    88         it_error ( "UI error: class " + class_name + " was not properly registered. Use the macro ""UIREGISTER([class name]);"" within your code." ); 
    89     return *iter->second; 
    90 } 
    91  
    92 const string& UI::Mapped_UI::retrieve_class_name( const type_info * const class_type_info ) 
    93 { 
    94     Type_Info_To_String_Map::const_iterator iter = mapped_type_infos().find( class_type_info ); 
     109                unregistered_class_error( class_name ); 
     110             
     111        return *iter->second; 
     112} 
     113 
     114const string& UI::MappedUI::retrieve_class_name( const type_info * const class_type_info ) 
     115{ 
     116    TypeInfoToStringMap::const_iterator iter = mapped_type_infos().find( class_type_info ); 
    95117    if ( iter == mapped_type_infos().end()) 
    96         it_error ( "UI error: class with RTTI name " + string(class_type_info->name()) + " was not properly registered. Use the macro ""UIREGISTER([class name]);"" within your code." ); 
     118                unregistered_class_error( "with RTTI name " + string(class_type_info->name()) ); 
    97119    return iter->second; 
    98120} 
    99121 
    100 ///////////////////////// INTERNAL LINK EXPANDER ///////////////////////////////////////////// 
    101  
    102 UI::SettingResolver::SettingResolver( const Setting &potential_link ): result( initialize_reference( file, potential_link ) ) 
    103 { 
    104 } 
    105  
    106 const Setting& UI::SettingResolver::initialize_reference(UI_File *&file, const Setting &potential_link) 
     122///////////////////////////// Class UI::SettingResolver ///////////////////////////////////////////// 
     123 
     124UI::SettingResolver::SettingResolver( const Setting &potential_link ) 
     125        : result( initialize_reference( file, potential_link ) ) 
     126{ 
     127} 
     128 
     129const Setting& UI::SettingResolver::initialize_reference(UIFile *&file, const Setting &potential_link) 
    107130{ 
    108131        file = NULL; 
     
    118141    { 
    119142        string file_name = link.substr( aerobase + 1, link.length() ); 
    120         file = new UI_File( file_name ); 
     143        file = new UIFile( file_name ); 
    121144        result = &(Setting&)(*file); 
    122145        link = link.substr( 0, aerobase ); 
     
    130153 
    131154    if ( !result->exists( link ) ) 
    132         ui_error( "linked Setting was not found", potential_link ); 
     155        ui_error( "linked setting was not found", potential_link ); 
    133156 
    134157    return (*result)[link]; 
     
    140163} 
    141164 
    142 ///////////////////////// UI ///////////////////////////////////////////// 
     165///////////////////////////// Class UI ///////////////////////////////////////////// 
    143166 
    144167void UI::ui_error( string message, const Setting &element ) 
     
    149172} 
    150173 
    151 //! This methods - kvuli ukladani pole stringu, dat jen privatne? 
    152 void UI::save( const string &str, Setting &element ) 
    153 { 
    154     Setting &set = element.add( Setting::TypeString ); 
     174const Setting& UI::to_child_setting( const Setting &element, const int index ) 
     175{ 
     176    if ( !element.isList()) 
     177        ui_error( "only TypeList elements could be indexed by integers", element ); 
     178 
     179    if ( element.getLength() <= index ) 
     180        ui_error( "there is not any child with index " + index, element ); 
     181 
     182    return element[index]; 
     183} 
     184 
     185const Setting& UI::to_child_setting( const Setting &element, const string &name ) 
     186{ 
     187    if ( !element.isGroup()) 
     188        ui_error( "only TypeGroup elements could be indexed by strings", element ); 
     189 
     190    if ( !element.exists( name ) ) 
     191        ui_error( "there is not any child named """ + name, element ); 
     192 
     193    return element[name]; 
     194} 
     195 
     196void UI::save( const int &integer, Setting &element, const string &name) 
     197{ 
     198    Setting &set = (name == "") ? element.add( Setting::TypeInt ) 
     199                                            : element.add( name, Setting::TypeInt ); 
     200    set = integer; 
     201} 
     202 
     203void UI::save( const double &real, Setting &element, const string &name) 
     204{ 
     205    Setting &set = (name == "") ? element.add( Setting::TypeFloat ) 
     206                                            : element.add( name, Setting::TypeFloat ); 
     207    set = real; 
     208} 
     209 
     210void UI::save( const string &str, Setting &element, const string &name) 
     211{ 
     212    Setting &set = (name == "") ? element.add( Setting::TypeString ) 
     213                                            : element.add( name, Setting::TypeString ); 
    155214    set = str; 
    156215} 
     
    158217void UI::save( const mat &matrix, Setting &element, const string &name) 
    159218{ 
    160  
    161219    Setting &set = (name == "") ? element.add( Setting::TypeList ) 
    162                     : element.add( name, Setting::TypeList ); 
     220                                            : element.add( name, Setting::TypeList ); 
    163221 
    164222    Setting &cols = set.add( Setting::TypeInt ); 
     
    179237} 
    180238 
    181  
    182 //! This methods tries to save a integer vector 
    183239void UI::save( const ivec &vector, Setting &element, const string &name) 
    184240{ 
    185  
    186241    Setting &set = (name == "") ? element.add( Setting::TypeArray ) 
    187242                    : element.add( name, Setting::TypeArray ); 
     
    193248} 
    194249 
    195  
    196 //! This methods tries to save a double vector 
    197250void UI::save( const vec &vector, Setting &element, const string &name) 
    198251{ 
     
    205258    } 
    206259} 
    207  
    208  
    209 //! This methods tries to build a new double matrix 
    210260 
    211261void UI::from_setting( mat& matrix, const Setting &element ) 
     
    274324} 
    275325 
    276 //! This methods tries to build a new integer vector 
    277326void UI::from_setting( ivec &vector, const Setting &element ) 
    278327{ 
     
    301350                Setting &elements = link.result[2]; 
    302351        // ASSERT_UITYPE(elements[0],TypeInt); -- spolehame an autoconvert 
    303  
    304352 
    305353        if ( matrix.cols() == 1 ) 
     
    328376} 
    329377 
    330 //! This methods tries to build a new double vector 
    331378void UI::from_setting( vec &vector, const Setting &element ) 
    332379{ 
     
    379426} 
    380427 
    381  
    382428void UI::from_setting( string &str, const Setting &element ) 
    383429{ 
     
    386432} 
    387433 
    388  
    389 ///////////////////////// UI FILE ///////////////////////////////////////////// 
    390 //! This methods tries to save an instance of type T (or some of its descendant types) 
    391 //! and build DOM tree accordingly. Then, it creates a new DOMNode named according class_name 
    392 //! and connecti it to the passed Setting as a new child node. 
    393 const Setting& UI::to_child_setting( const Setting &element, const int index ) 
    394 { 
    395     if ( !element.isList()) 
    396         ui_error( "only TypeList elements could be indexed by integers", element ); 
    397  
    398     if ( element.getLength() <= index ) 
    399         ui_error( "there is not any child with index " + index, element ); 
    400  
    401     return element[index]; 
    402 } 
    403  
    404 const Setting& UI::to_child_setting( const Setting &element, const string &name ) 
    405 { 
    406     ASSERT_UITYPE(element,TypeGroup); 
    407     if ( !element.exists( name ) ) 
    408         ui_error( "there is not any child named """ + name, element ); 
    409     return element[name]; 
    410 } 
    411  
    412  
    413 } 
    414  
     434void UI::from_setting( int &integer, const Setting &element ) 
     435{ 
     436    ASSERT_UITYPE(element,TypeInt); 
     437    integer = element; 
     438} 
     439 
     440void UI::from_setting( double &real, const Setting &element ) 
     441{ 
     442    ASSERT_UITYPE(element,TypeFloat); 
     443    real = element; 
     444} 
     445 
     446} 
  • library/bdm/base/user_info.h

    r392 r394  
    1717using namespace libconfig; 
    1818 
     19namespace bdm 
     20{ 
     21         
     22/*! 
     23  \def UIREGISTER(class_name) 
     24  Macro for registration of class into map of UserInfos -- registered class is scriptable  
     25 
     26  TODO napsat i to, ze UIREG musi byt v hacku.. 
     27*/ 
    1928#ifndef BDMLIB  
    20 //!Macro for registration of classes into map of UserInfos -- registered class is scriptable  
    21 #define UIREGISTER(class_name) template<> const Particular_UI<class_name>& Particular_UI<class_name>::ui = Particular_UI<class_name>(#class_name)  
     29#define UIREGISTER(class_name) template<> const ParticularUI<class_name>& ParticularUI<class_name>::ui = ParticularUI<class_name>(#class_name)  
    2230#else 
    2331#define UIREGISTER(class_name) 
    2432#endif 
    2533 
    26 #define ASSERT_UITYPE(S,Type) it_assert_debug(S.getType()==Setting::Type, string("Wrong setting type, see input path \"")+string(S.getPath())+string("\"")) 
    27  
    28 namespace bdm 
    29 { 
    30          
    31         //! exception used in UI::build if it fails it can be caught and handled - see merger_mex.h 
     34//!  macro assertting that the setting SET is of the SettingType TYPE 
     35#define ASSERT_UITYPE(SET,TYPE) it_assert_debug(SET.getType()==Setting::TYPE, string("Wrong setting type, see input path \"")+string(SET.getPath())+string("\"")) 
     36 
     37//! exception used in UI::build if it fails it can be caught and handled - see merger_mex.h 
    3238class UIbuildException : public std::invalid_argument { 
    3339        public: 
    3440                UIbuildException() : std::invalid_argument("class name") { } 
    3541}; 
    36          
    37 class UI_File : public Config 
    38 { 
    39 private: 
    40         const string file_name; 
    41  
    42 public: 
    43         //! create empty object prepared to store Settings 
    44         UI_File(); 
    45  
    46         //! creates object and fills it from a file 
    47         UI_File( const string &file_name ); 
    48  
    49         //! save UserInfo to the file  
    50         void save(const string &file_name); 
    51  
    52         operator Setting&(); 
    53 }; 
    5442 
    5543/*! 
    56 @brief This class serves to load and/or save DOMElements into/from files 
    57 stored on a hard-disk. 
    58  
    59 Firstly, you associate new RootElement instance with some filename during a time of its  
    60 construtcion. Then, you save some object into the new RootElement instance, 
    61 and save it into the file this way: 
     44@brief This class serves to load and/or save user-infos into/from  
     45configuration files stored on a hard-disk. 
     46 
     47Firstly, save some user-infos into the new UIFile instance. Then,  
     48call the save method with a filename as its only argument: 
     49 
    6250\code 
    6351        CAudi audi; 
    64         RootElement root("cars.xml"); 
    65         UserInfo::save( audi, root, "TT"); 
    66         root.save(); 
     52        UIFile file; 
     53        UI::save( audi, file, "TT"); 
     54        file.save("cars.cfg"); 
    6755\endcode 
    6856 
    69 In the other way round, when loading object from a XML file, the appropriate code looks like this: 
     57In the other way round, when loading object from a configuration file,  
     58the appropriate code looks like this: 
     59 
    7060\code 
    71         RootElement root("cars.xml"); 
    72         root.load(); 
    73         UserInfo::build<T>(root,"TT"); 
     61        UIFile file("cars.cfg"); 
     62        CAudi *audi = UI::build<CAudi>(file,"TT"); 
    7463\endcode 
    7564*/ 
     65class UIFile : public Config 
     66{ 
     67public: 
     68        //! create empty file instance prepared to store Settings 
     69        UIFile(); 
     70 
     71        //! creates instance and fills it from the configuration file file_name 
     72        UIFile( const string &file_name ); 
     73 
     74        //! save all the stored Settings into the configuration file file_name 
     75        void save(const string &file_name); 
     76 
     77        //! this operator allows the ability of substituting Setting parameter by UIFile instance 
     78        operator Setting&(); 
     79}; 
     80 
    7681 
    7782 
    7883/*! 
    79 @brief UserInfo is an abstract is for internal purposes only. Use CompoundUserInfo<T> or Particular_UI<T> instead. 
    80 The raison d'etre of this class is to allow pointers to its templated descendants.  
    81  
    82 Also, the main functions of the whole UserInfo library are included within this class, see 
    83 static methods 'build' and 'save'. 
    84  
     84@brief UI is an abstract class and it is intended for internal purposes only 
     85 
     86This class exists mainly to allow pointers to its templated descendant ParticularUI<T>. Next,  
     87it collects all the auxiliary functions useful to prepare some concret user-infos, see static  
     88methods 'build', 'get' and 'save'.  
    8589*/ 
    8690class UI  
    8791{ 
    8892private: 
    89         //! static class encalupsating map of names to related UserInfos 
     93        //! Atatic class encalupsating two maps, one mapping names to UI instances and the other mapping type_infos to class names 
    9094        //!  
    91         //! The key property of this class is that it initilaized the internal map immediately 
    92         //! when it is used for a first time. 
    93         class Mapped_UI 
     95        //! The key property of this class is that it initilaize the internal map immediately 
     96        //! when it is used for a first time. Therefore, we do not have to care about the  
     97        //! order of calls to UIREGISTER macro, which operates with both these mappings. 
     98        class MappedUI 
    9499        { 
    95100        private: 
    96                 //! Type definition of mapping which transforms type names to the related user infors 
    97                 typedef map< const string, const UI* const > String_To_UI_Map; 
    98  
    99                 //! Type definition of mapping which transforms type names to the related user infors 
    100                 typedef map< const type_info * const, const string > Type_Info_To_String_Map; 
    101  
    102                 //! immediately initialized instance of type String_To_UI_Map 
    103                 static String_To_UI_Map& mapped_strings(); 
    104  
    105                 //! immediately initialized instance of type String_To_UI_Map 
    106                 static Type_Info_To_String_Map& mapped_type_infos(); 
     101                //! Type definition of mapping which transforms class names to the related UI instances 
     102                typedef map< const string, const UI* const > StringToUIMap; 
     103 
     104                //! Type definition of mapping which transforms RTTI type_infos to the related class names 
     105                typedef map< const type_info * const, const string > TypeInfoToStringMap; 
     106 
     107                //! immediately initialized instance of type StringToUIMap 
     108                static StringToUIMap& mapped_strings(); 
     109 
     110                //! immediately initialized instance of type TypeInfoToStringMap 
     111                static TypeInfoToStringMap& mapped_type_infos(); 
     112 
     113                //! method for reporting a error when an attempt to operate with an unregistered class occures 
     114                static void unregistered_class_error( const string &unregistered_class_name ); 
    107115 
    108116        public: 
     
    110118                static void add_class( const string &class_name, const type_info * const class_type_info, const UI* const ui ); 
    111119 
    112                 //! search for an userinfo related to the passed key within the internal map 
     120                //! search for an userinfo related to the passed class name within the internal map 
    113121                static const UI& retrieve_ui( const string &class_name ); 
    114122 
    115                 //! search for an userinfo related to the passed key within the internal map 
     123                //! search for an class name related to the passed type_info within the internal map 
    116124                static const string& retrieve_class_name( const type_info* const class_type_info ); 
    117125        }; 
    118126 
    119  
    120  
    121  
    122         //! internal method assembling a typeless instance from components obtained by the 'AssemblyComponentsFromSetting()' method 
     127        //! Method assembling a typeless instance, it is implemented in descendant class ParticularUI<T> 
    123128        virtual root* new_instance() const = 0; 
    124129         
    125         //! This methods tries to save an instance of type T (or some of its descendant types) 
    126         //! and build DOM tree accordingly. Then, it creates a new DOMNode named according class_name 
    127         //! and connecti it to the passed Setting as a new child node. 
     130        //! Method switching from the \a element to its child Setting according the passed \a index, it also does all the necessary error-checking  
    128131        static const Setting& to_child_setting( const Setting &element, const int index ); 
    129132 
     133        //! Method switching from the \a element to its child Setting according the passed \a name, it also does all the necessary error-checking  
    130134        static const Setting& to_child_setting( const Setting &element, const string &name ); 
    131135 
    132  
    133         //! \name Matematical Operations TODO 
    134         //!@{ 
    135  
    136         //! This methods tries to build a new double matrix  
     136        //! This methods converts a Setting into a matrix  
    137137        static void from_setting( mat& matrix, const Setting &element );         
    138         //! This methods tries to build a new integer vector 
     138        //! This methods converts a Setting into an integer vector 
    139139        static void from_setting( ivec &vector, const Setting &element ); 
    140         // jednak kvuli pretypovani, apak taky proto, ze na string nefunguje link_expander.. 
     140        //! This methods converts a Setting into a string 
    141141        static void from_setting( string &str, const Setting &element ); 
    142         //! This methods tries to build a new templated array  
    143  
     142        //! This methods converts a Setting into a real vector 
    144143        static void from_setting( vec &vector, const Setting &element ); 
    145  
     144        //! This methods converts a Setting into a integer scalar  
     145        static void from_setting( int &integer, const Setting &element ); 
     146        //! This methods converts a Setting into a real scalar  
     147        static void from_setting( double &real, const Setting &element ); 
     148        //! This methods converts a Setting into a class T descendant 
    146149        template<class T> static void from_setting( T* &instance, const Setting &element ) 
    147150        {                        
     
    155158                        ui_error( "the obligatory ""class"" identifier is missing", link.result ); 
    156159         
    157                 // and finally we find a UserInfo related to this type 
    158                 const UI& related_UI = Mapped_UI::retrieve_ui( class_name ); 
     160                // then we find a user-info related to this type 
     161                const UI& related_UI = MappedUI::retrieve_ui( class_name ); 
    159162                 
    160163                root* typeless_instance = related_UI.new_instance(); 
     
    168171//              catch(...) 
    169172//              { 
     173                        // TODO pouzit ui_error?  
    170174//                      it_error ( "UI error: class " + class_name + " is not a descendant of the desired output class. Try to call the UI::build function with a different type parameter." ); 
    171175//              } 
     
    177181                catch(SettingException xcptn) 
    178182                { 
     183                        // TODO pouzit ui_error?  
    179184                        it_error ( "UI error: the method " + class_name + ".from_setting(Setting&) has thrown an exception when parsing the setting " + xcptn.getPath() + ". Try to correct this method." ); 
    180185                } 
    181186        }        
    182187 
    183  
    184         //! This methods tries to build a new templated array ,  
    185         // efektivne jen pro vect, mat a string, pro dalsi je nutne pridat from_setting metodu.. ale to asi necceme 
     188        //! This methods converts a Setting into a new templated array ,  
     189        // TODO efektivne jen pro vect, mat a string, pro dalsi je nutne pridat from_setting metodu.. ale to asi necceme 
    186190        template<class T> static void from_setting( Array<T> &array_to_load, const Setting &element ) 
    187191        { 
     
    198202        } 
    199203 
    200           //!@} 
    201  
    202  
     204        //! Method for reporting user-info errors related to some concrete Setting 
    203205        static void ui_error( string message, const Setting &element ); 
    204206 
    205207protected: 
    206         //! default constructor  
     208        //! Default constructor for internal use only, see \sa ParticularUI<T> 
    207209        UI( const string& class_name, const type_info * const class_type_info )  
    208210        {        
    209                 Mapped_UI::add_class( class_name, class_type_info, this ); 
    210         } 
    211  
    212         //! Virtual destructor for future use; 
    213         virtual ~UI(){}; 
     211                MappedUI::add_class( class_name, class_type_info, this ); 
     212        } 
    214213 
    215214public:  
    216         //! This methods tries to build a new instance of type T (or some of its descendant types) 
    217         //! according to a data stored in a DOMNode named class_name within a child nodes of the passed element. 
    218         //! If an error occurs, it returns a NULL pointer. 
    219  
    220         // vraci true, kdyz to byl platny link, jinak false.. v pripade chyby konci it_errorem.. 
    221         // do elementu vrati setting prislusny po rozbaleni linku, jinak ponecha beze zmeny 
     215 
     216        /*! 
     217        @brief This class serves to expand links used in configuration file.  
     218 
     219        TODO - napsat co dela, a hlavne proc je to takhle implementovany.. otevreny soubor! 
     220 
     221        ABSOLUTE PATH..  
     222 
     223        Firstly, save some user-infos into the new UIFile instance. Then,  
     224        call the save method with a filename as its only argument: 
     225 
     226        \code 
     227                CAudi audi; 
     228                UIFile file; 
     229                UI::save( audi, file, "TT"); 
     230                file.save("cars.cfg"); 
     231        \endcode 
     232 
     233        */ 
    222234        class SettingResolver    
    223235        { 
    224236        private: 
    225                 UI_File *file; 
    226  
    227                 const Setting &initialize_reference( UI_File* &file, const Setting &potential_link); 
     237                //! If necessary, this pointer stores an addres of an opened UIFile, else it equals NULL 
     238                UIFile *file; 
     239 
     240                //! This method initialize result reference, i.e., it executes the main code of SettingResolver class 
     241                //! 
     242                //! This code could be also located directly in constructor. The only reason why we made this  
     243                //! method is the keyword 'const' within the declaration of result reference (TODO funguje odkaz?). Such a reference 
     244                //! have to be intialized before any other constructor command, exactly in the way it is implemented now. 
     245                const Setting &initialize_reference( UIFile* &file, const Setting &potential_link); 
    228246 
    229247        public: 
     248                //! Reference to a resolved link or to the original Setting in the case it does not contain a link 
    230249                const Setting &result; 
    231250 
     251                //! If potential_link contains a link to some other setting, it is resolved here. Anyway, the Setting reference result is prepared for use. 
    232252                SettingResolver( const Setting &potential_link ); 
    233253                 
     254                //! An opened UIFile file is closed here if necessary. 
    234255                ~SettingResolver();              
    235256        }; 
    236257 
    237  
    238  
    239         //! Prototype of a UI builder. Return value is by the second argument since it type checking via \c dynamic_cast. 
     258        //TODO 
     259        //! \name Initialization of bdm::root descendant classes according the values stored in a Setting variable 
     260        //!@{ 
     261        //! Return value is by the second argument since it type checking via \c dynamic_cast. 
    240262        template<class T> static T* build( const Setting &element, const int index ) 
    241263        { 
     
    258280                return instance; 
    259281        } 
    260  
     282        //!@} 
     283 
     284        //! \name Initialization of structures according the values stored in a Setting variable - TODO VYCET?! 
     285        //!@{ 
    261286        //! This methods tries to build a new double matrix  
    262287        template<class T> static void get( T &instance, const Setting &element, const string &name ) 
     
    272297 
    273298        //! This methods tries to build a new double matrix  
     299        template<class T> static void get( T &instance, const Setting &element  ) 
     300        { 
     301                from_setting( instance, element ); 
     302        } 
     303 
     304        //! This methods tries to build a new double matrix  
    274305        template<class T> static void get( Array<T> &array_to_load, const Setting &element, const string &name ) 
    275306        { 
     
    282313                from_setting( array_to_load, to_child_setting( element, index ) ); 
    283314        } 
     315 
     316        //! This methods tries to build a new double matrix  
     317        template<class T> static void get( Array<T> &array_to_load, const Setting &element  ) 
     318        { 
     319                from_setting( array_to_load, element ); 
     320        } 
     321        //!@} 
    284322 
    285323        template< class T> static void save( const T * const instance, Setting &element, const string &name = "") 
     
    288326                                                                         : element.add( name, Setting::TypeGroup );              
    289327 
    290                 const string &class_name = Mapped_UI::retrieve_class_name( &typeid(*instance) ); 
     328                const string &class_name = MappedUI::retrieve_class_name( &typeid(*instance) ); 
    291329                         
    292330                // add attribute "class"  
     
    321359        static void save( const ivec &vec, Setting &element, const string &name = "" ); 
    322360         
    323         static void save( const vec &vector, Setting &element, const string &name); 
    324  
    325         private:  
     361        static void save( const vec &vector, Setting &element, const string &name = "" ); 
    326362        //! This methods tries to save a double vec  
    327         static void save( const string &str, Setting &element);  
     363        static void save( const string &str, Setting &element, const string &name = "" ); 
     364 
     365        static void save( const int &integer, Setting &element, const string &name = "" ); 
     366 
     367        static void save( const double &real, Setting &element, const string &name = "" );       
    328368 
    329369}; 
     
    335375own userinfo class prepared). 
    336376*/ 
    337 template<typename T> class Particular_UI : private UI 
     377template<typename T> class ParticularUI : private UI 
    338378{ 
    339379        public: 
    340380 
    341381        //! default constructor, which is intentionally declared as private 
    342         Particular_UI<T>( const string &class_name) : UI( class_name, &typeid(T) )  
     382        ParticularUI<T>( const string &class_name) : UI( class_name, &typeid(T) )  
    343383        {       cout << class_name << endl; 
    344384        }; 
     
    346386        //! the only instance of this class (each type T has its own instance) 
    347387        //! which is used as a factory for processing related UI 
    348         static const Particular_UI<T>& ui;       
     388        static const ParticularUI<T>& ui;        
    349389 
    350390        root* new_instance() const 
  • library/bdm/estim/mixtures.h

    r384 r394  
    1111*/ 
    1212 
    13 #ifndef ESTIM_MIXTURES_H 
    14 #define ESTIM_MIXTURES_H 
     13#ifndef MIXTURES_H 
     14#define MIXTURES_H 
    1515 
    1616 
    1717#include "../math/functions.h" 
    1818#include "../stat/exp_family.h" 
    19 #include "../stat/mixtures.h" 
     19#include "../stat/emix.h" 
    2020 
    2121namespace bdm { 
  • library/bdm/stat/emix.cpp

    r384 r394  
    1 #include "mixtures.h" 
     1#include "emix.h" 
    22 
    33namespace bdm{ 
  • library/bdm/stat/emix.h

    r384 r394  
    1111*/ 
    1212 
    13 #ifndef STAT_MIXTURES_H 
    14 #define STAT_MIXTURES_H 
     13#ifndef EMIX_H 
     14#define EMIX_H 
    1515 
    1616#define LOG2  0.69314718055995   
  • library/tests/CMakeLists.txt

    r386 r394  
    1919EXEC(enorm_test) 
    2020EXEC(egiw_test) 
    21 EXEC(stat_mixtures_test) 
     21EXEC(emix_test) 
    2222EXEC(test0) 
    2323EXEC(testResample) 
     
    2929EXEC(merger_2d_test) 
    3030EXEC(merger_iter_test) 
    31 EXEC(estim_mixtures_test) 
     31EXEC(mixtures_test) 
    3232 
    3333EXEC(test_kalman) 
  • library/tests/emix_test.cpp

    r386 r394  
    11#include "stat/exp_family.h" 
    2 #include "stat/mixtures.h" 
     2#include "stat/emix.h" 
    33using namespace bdm; 
    44 
  • library/tests/enorm_test.cpp

    r386 r394  
    11#include "stat/exp_family.h" 
    2 #include "stat/mixtures.h" 
     2#include "stat/emix.h" 
    33using namespace bdm; 
    44 
  • library/tests/testSmp.cpp

    r386 r394  
    11 
    22#include "stat/exp_family.h" 
    3 #include "stat/mixtures.h" 
     3#include "stat/emix.h" 
    44 
    55using namespace bdm; 
  • library/tests/test_user_info.cpp

    r390 r394  
    197197{ 
    198198  //////////////////////////////////// LOADING //////////////////////////////// 
    199   UI_File in("test_user_info_input.cfg"); 
     199  UIFile in("test_user_info_input.cfg"); 
    200200  Transport *pepikovo = UI::build<Transport>(in, "pepikovo"); 
    201201  cout << "pepikovo: " << pepikovo->to_string() << endl; 
     
    216216  Car liaz(1989, "skoda", 1000); 
    217217  Bike author(2001, "noname", false); 
    218   UI_File out; 
     218  UIFile out; 
    219219 
    220220  UI::save(&audi, out, "marty");