Show
Ignore:
Timestamp:
10/29/09 23:23:56 (15 years ago)
Author:
smidl
Message:

mex tutorial cleanup + working mexDS

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • applications/bdmtoolbox/mex/merger.cpp

    r622 r685  
    5858#endif 
    5959        // Sources 
    60         Array<shared_ptr<mpdf> > Sources; 
    61         //abuse Mer to store sources 
    62         Setting& _Sources = Cfg.lookup ( "Sources" ); 
    63         int Slen = _Sources.getLength(); 
    64         Sources.set_size ( Slen ); 
    65         for ( int i = 0; i < Slen; i++ ) { 
    66                 try { 
    67                         shared_ptr<mpdf> mtmp = UI::build<mpdf> ( _Sources, i ); 
    68                         Sources ( i ) = mtmp; 
    69                 } catch ( UIException ) { 
    70                         // it is not mpdf - see if it is epdf 
    71                         try { 
    72                                 shared_ptr<epdf> etmp = UI::build<epdf> ( _Sources, i ); 
    73                                 if ( etmp ) { 
    74                                         Sources ( i ) = new mepdf ( etmp ); // hopefully OK 
    75                                 } 
    76                         } catch ( UIException &e ) { 
    77                                 it_error ( "No mpdfs or epdfs found! " + string ( e.what() ) ); 
    78                         } catch ( std::exception e ) { 
    79                                 it_error ( "Error in UI at " + _Sources[i].getPath() ); 
    80                         } 
    81                 } catch ( std::exception &e ) { 
    82                         it_error ( "Error in UI at " + _Sources[i].getPath() ); 
    83                 } 
    84         } 
    85  
     60        Array<shared_ptr<mpdf> >  Sources; 
     61        UI::get(Sources, Cfg, "Sources", UI::compulsory); 
    8662        shared_ptr<merger_base> Merger = UI::build<merger_base> ( Cfg, "Merger" ); 
    8763 
    8864        // Support 
    89         try { 
    90                 shared_ptr<rectangular_support> RecSup = UI::build<rectangular_support> ( Cfg, "Support" ); 
     65        try{ 
     66        shared_ptr<rectangular_support> RecSup = UI::build<rectangular_support> ( Cfg, "Support" ,UI::optional); 
     67        if(RecSup){ 
    9168                Merger->set_support ( *RecSup ); 
    92         } catch ( UIException &e ) { 
    93                 shared_ptr<discrete_support> DisSup = UI::build<discrete_support> ( Cfg, "Support" ); 
    94                 Merger->set_support ( *DisSup ); 
     69        }  
     70        } catch (UIException &e) { 
     71                shared_ptr<discrete_support> DisSup = UI::build<discrete_support> ( Cfg, "Support", UI::optional ); 
     72                if (DisSup){ 
     73                        Merger->set_support ( *DisSup ); 
     74                } else{bdm_error("Support not defined");} 
    9575        } 
    9676// COMPUTE RESULTS