Changeset 925

Show
Ignore:
Timestamp:
08/06/08 17:17:34
Author:
robert
Message:

Added support for aborting the current task when FATAL messages are logged, with
DataSet? now generating FATAL log messages when AbortTaskOnError? is set (as it is now by default).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/applications/osgdem/osgdem.cpp

    r908 r925  
    204204    } 
    205205 
    206  
    207206    double duration = 0.0; 
    208207 
     
    238237            vpb::sync(); 
    239238 
    240             int result = dataset->run(); 
     239            result = dataset->run(); 
    241240 
    242241            if (dataset->getBuildLog() && report) 
     
    249248            dataset->log(osg::NOTICE,"Elapsed time = %f",duration); 
    250249             
     250            if (taskFile.valid()) 
     251            { 
     252                taskFile->setStatus(vpb::Task::COMPLETED); 
     253            } 
     254 
     255        } 
     256        catch(std::string str) 
     257        { 
     258            printf("Caught exception : %s\n",str.c_str()); 
     259             
     260            taskFile->setStatus(vpb::Task::FAILED); 
     261 
     262            result = 1; 
     263 
    251264        } 
    252265        catch(...) 
    253266        { 
    254267            printf("Caught exception.\n"); 
     268             
     269            taskFile->setStatus(vpb::Task::FAILED); 
     270 
     271            result = 1; 
    255272        } 
    256273 
     
    261278    if (taskFile.valid()) 
    262279    { 
    263         taskFile->setStatus(vpb::Task::COMPLETED); 
    264280        taskFile->setProperty("duration",duration); 
    265281        taskFile->write(); 
     
    269285    vpb::sync(); 
    270286     
    271     return 0
     287    return result
    272288} 
    273289 
  • trunk/include/vpb/BuildLog

    r917 r925  
    3636#include <sstream> 
    3737#include <fstream> 
     38#include <iostream> 
    3839 
    3940 
     
    9899        void log(osg::NotifySeverity level, const char* message, ...); 
    99100         
     101        void log(osg::NotifySeverity level, const std::string& message); 
     102 
    100103        void setStartPendingTime(double t) { _startPendingTime = t; } 
    101104        double getStartPendingTime() const { return _startPendingTime; } 
     
    192195        const BuildLog* getBuildLog() const { return _buildLog.get(); } 
    193196 
     197        void log(osg::NotifySeverity level, const std::string& message) const 
     198        { 
     199            if (level>osg::getNotifyLevel()) return; 
     200         
     201            if (_buildLog.valid()) 
     202            { 
     203                _buildLog->log(level, message); 
     204            } 
     205            else  
     206            { 
     207                std::cout<<message<<std::endl; 
     208            } 
     209             
     210            if (level==osg::FATAL) throw message; 
     211        } 
     212         
    194213        void log(osg::NotifySeverity level, const char* format, ...) const 
    195214        { 
     
    202221                vsnprintf(str, sizeof(str), format, args); 
    203222                _buildLog->log(level, str); 
     223 
     224                if (level==osg::FATAL) throw std::string(str); 
    204225            } 
    205226            else  
    206227            { 
    207228                vprintf(format, args); printf("\n"); 
     229 
     230                if (level==osg::FATAL)  
     231                { 
     232                    char str[1024]; 
     233                    vsnprintf(str, sizeof(str), format, args); 
     234                    throw std::string(str); 
     235                } 
    208236            } 
    209237            va_end(args); 
    210         } 
     238 
     239    } 
    211240 
    212241    protected: 
  • trunk/include/vpb/BuildOptions

    r890 r925  
    261261        LayerInheritance getLayerInheritance() const { return _layerInheritance; } 
    262262 
     263        void setAbortTaskOnError(bool flag) { _abortTaskOnError = flag; } 
     264        bool getAbortTaskOnError() const { return _abortTaskOnError; } 
     265 
     266        void setAbortRunOnError(bool flag) { _abortRunOnError = flag; } 
     267        bool getAbortRunOnError() const { return _abortRunOnError; } 
    263268         
    264269    protected: 
     
    323328 
    324329        LayerInheritance                            _layerInheritance; 
     330         
     331        bool                                        _abortTaskOnError; 
     332        bool                                        _abortRunOnError; 
    325333}; 
    326334 
  • trunk/src/vpb/BuildOptions.cpp

    r913 r925  
    7474     
    7575    _layerInheritance = INHERIT_NEAREST_AVAILABLE; 
     76     
     77    _abortTaskOnError = true; 
     78    _abortRunOnError = false; 
    7679} 
    7780 
     
    148151     
    149152    _layerInheritance = rhs._layerInheritance; 
     153     
     154    _abortTaskOnError = rhs._abortTaskOnError; 
     155    _abortRunOnError = rhs._abortRunOnError; 
    150156} 
    151157 
  • trunk/src/vpb/BuildOptionsIO.cpp

    r890 r925  
    221221        { AEP(LayerInheritance); AEV(INHERIT_LOWEST_AVAILABLE); AEV(INHERIT_NEAREST_AVAILABLE); AEV(NO_INHERITANCE); } 
    222222 
     223        ADD_BOOL_PROPERTY(AbortTaskOnError); 
     224        ADD_BOOL_PROPERTY(AbortRunOnError); 
    223225    } 
    224226     
  • trunk/src/vpb/Commandline.cpp

    r913 r925  
    497497    usage.addCommandLineOption("--interpolate-imagery","Enable the use of interpolation when sampling data from source imagery."); 
    498498    usage.addCommandLineOption("--no-interpolate-imagery","Disable the use of interpolation when sampling data from source imagery."); 
     499    usage.addCommandLineOption("--abort-task-on-error","Hint to osgdem to abort the build when any errors occur."); 
     500    usage.addCommandLineOption("--no-abort-task-on-error","Hint to osgdem to abort the build when any errors occur."); 
     501    usage.addCommandLineOption("--abort-run-on-error","Hint to vpbmaster to abort the run when any errors occur."); 
     502    usage.addCommandLineOption("--no-abort-run-on-error","Hint to vpbmaster to abort the run when any errors occur."); 
    499503} 
    500504 
     
    775779 
    776780    while (arguments.read("--type-attribute",typeAttributeName)) {} 
     781 
     782    while (arguments.read("--abort-task-on-error")) { buildOptions->setAbortTaskOnError(true); } 
     783    while (arguments.read("--no-abort-task-on-error")) { buildOptions->setAbortTaskOnError(false); } 
     784 
     785    while (arguments.read("--abort-run-on-error")) { buildOptions->setAbortRunOnError(true); } 
     786    while (arguments.read("--no-abort-run-on-error")) { buildOptions->setAbortRunOnError(false); } 
    777787 
    778788    float ratio=0.0f; 
  • trunk/src/vpb/DataSet.cpp

    r924 r925  
    14851485            if (!result.success()) 
    14861486            { 
    1487                 log(osg::WARN, "Error: error occurred when writing out file %s",filename.c_str()); 
     1487                osg::NotifySeverity level = getAbortTaskOnError() ? osg::FATAL : osg::WARN; 
     1488                log(level, "Error: do not have write permission to write out file %s",filename.c_str()); 
    14881489            } 
    14891490        } 
    14901491        else 
    14911492        { 
    1492             log(osg::WARN, "Error: do not have write permission to write out file %s",filename.c_str()); 
     1493            osg::NotifySeverity level = getAbortTaskOnError() ? osg::FATAL : osg::WARN; 
     1494            log(level, "Error: do not have write permission to write out file %s",filename.c_str()); 
    14931495        } 
    14941496    }