Show
Ignore:
Timestamp:
08/20/09 00:54:44 (15 years ago)
Author:
smidl
Message:

bdmtoolbox adapted to shared_ptr, merger_grid (partially) working,

Files:
1 modified

Legend:

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

    r490 r568  
    5959#endif 
    6060        // Sources 
    61         Array<mpdf*> Sources; 
     61        Array<shared_ptr<mpdf> > Sources; 
    6262        //abuse Mer to store sources 
    6363        Setting& _Sources = Cfg.lookup ("Sources"); 
     
    6666        for (int i = 0; i < Slen; i++) { 
    6767                try { 
    68                         mpdf* mtmp = UI::build<mpdf> (_Sources, i); 
     68                        shared_ptr<mpdf> mtmp = UI::build<mpdf> (_Sources, i); 
    6969                        Sources (i) = mtmp; 
    7070                } catch (UIException) { 
     
    7373                                shared_ptr<epdf> etmp = UI::build<epdf> (_Sources, i); 
    7474                                if (etmp) { 
    75                                         Sources (i) = new mepdf (etmp); 
     75                                        Sources (i) = new mepdf (etmp); // hopefully OK 
    7676                                } 
    77                         } catch (UIException e) { 
     77                        } catch (UIException &e) { 
    7878                                it_error ("No mpdfs or epdfs found! " + string (e.what())); 
    7979                        } catch (std::exception e) { 
    8080                                it_error ("Error in UI at " + _Sources[i].getPath()); 
    8181                        } 
    82                 } catch (std::exception e) { 
     82                } catch (std::exception &e) { 
    8383                        it_error ("Error in UI at " + _Sources[i].getPath()); 
    8484                } 
    8585        } 
    8686 
    87         merger_base* Merger = UI::build<merger_base> (Cfg, "Merger"); 
     87        shared_ptr<merger_base> Merger = UI::build<merger_base> (Cfg, "Merger"); 
    8888 
    8989        // Support 
    90         Setting & _Supp = Cfg.lookup ("Support"); 
    91  
    92         if (_Supp.exists ("grid") &&  _Supp.exists ("nbins")) { 
    93                 Array<vec> bounds (0); 
    94                 UI::get (bounds, _Supp, "grid"); 
    95                 ivec nbins (0); 
    96                 UI::get (nbins, _Supp, "nbins"); 
    97                 Merger->set_support (bounds, nbins); 
    98  
    99         } else { 
    100                 if (_Supp.exists ("pdf") &&  _Supp.exists ("nsamples")) { 
    101                         epdf *g0 = UI::build<epdf> (_Supp, "pdf"); 
    102                         int npoints = 100; 
    103                         _Supp.lookupValue ("nsamples", npoints); 
    104                         Merger->set_support (*g0, npoints); 
    105                         delete g0; 
    106                 } else it_error ("Use either [grid,nbins] or [pdf,nsamples]."); 
     90        try { 
     91                shared_ptr<rectangular_support> RecSup = UI::build<rectangular_support> (Cfg, "Support"); 
     92                Merger->set_support(*RecSup); 
     93        } 
     94        catch (UIException &e) { 
     95                shared_ptr<epdf> g0 = UI::build<epdf> (Cfg, "Support"); 
     96                Merger->set_support (*g0, 100); 
    10797        } 
    10898// COMPUTE RESULTS 
    109         Merger->set_sources (Sources, true); // takes care of deletion of sources 
     99        Merger->set_sources (Sources);  
    110100        Merger->merge(); 
    111101 
     
    128118        } 
    129119 
    130         merger_mix* MerMix=dynamic_cast<merger_mix*>(Merger); 
     120        merger_mix* MerMix=dynamic_cast<merger_mix*>(Merger.get()); 
    131121        vec mix_val; 
    132122