58 #ifndef PROGRESSREPORTER_HH 59 #define PROGRESSREPORTER_HH 88 _verboseLevel(TASK_LEVEL_TWOCLASS),
89 _drawProgressBar( true),
90 _cursorPosSaved( false),
91 _progressBarLength( 20),
96 _rotatingDash.push_back(
"|");
97 _rotatingDash.push_back(
"/");
98 _rotatingDash.push_back(
"-");
99 _rotatingDash.push_back(
"\\");
125 _os <<
"\033[2J\033[H";
157 const std::string& taskName,
158 float completenessPercent,
159 const std::string& completenessPlainText)
161 if( taskLevel <= _verboseLevel)
166 if( _drawProgressBar)
171 if( _cursorPosSaved ==
false)
174 for(
int i = 0; i < 15; ++i)
179 _os <<
"\033[" << 15 <<
"A";
183 _cursorPosSaved =
true;
192 _os <<
"\033[u\033[s";
194 if( taskLevel-_maxTaskLevel > 0)
196 _os <<
"\033[" << (taskLevel-_maxTaskLevel)*3 <<
"B";
198 _os << taskName <<
" ";
205 _os <<
"\033[u\033[s";
207 if( taskLevel-_maxTaskLevel+1 > 0)
209 _os <<
"\033[" << (taskLevel-_maxTaskLevel)*3+1 <<
"B";
213 if( completenessPercent >= 0)
217 int nHashs =
static_cast<int>(
218 static_cast<float>(_progressBarLength) *
219 completenessPercent + 0.5f);
221 for(
int i = 0; i < nHashs; ++i)
225 for(
int i = nHashs; i < _progressBarLength; ++i)
229 _os <<
"| (" << completenessPlainText <<
") " 230 << int(completenessPercent*100) <<
"% "<< std::flush;
236 _os << _rotatingDash[_rotDashIndex];
237 _rotDashIndex = (_rotDashIndex + 1) %
238 static_cast<int>(_rotatingDash.size());
240 if( completenessPercent == -2)
245 for(
int i = 0; i < _dotCounter; ++i)
249 _os <<
" " << std::flush;
261 _os <<
"\033[u\033[s";
263 _os <<
"\033[" << (5-_maxTaskLevel)*3 <<
"B\n";
270 if( completenessPercent < 0)
274 _os << completenessPlainText << std::flush;
279 for(
int i = 1; i < taskLevel; ++i)
283 _os << taskName <<
": " << int(completenessPercent*100)
284 <<
"% (" << completenessPlainText <<
")\n";
305 const std::string& text)
307 if( taskLevel <= _verboseLevel)
309 if( _drawProgressBar)
316 _os <<
"\033[u\033[s";
318 _os <<
"\033[" << (5-_maxTaskLevel)*3 <<
"B\n";
321 _os << text << std::flush;
339 _verboseLevel = verboseLevel;
342 template<
typename STDATA>
345 stData.getValue(
"verbose_level", _verboseLevel);
346 stData.getValue(
"draw_progress_bar", _drawProgressBar);
349 template<
typename STDATA>
352 stData.setValue(
"verbose_level", _verboseLevel);
353 stData.setValue(
"draw_progress_bar", _drawProgressBar);
368 p.push_back(
ParamInfo(
"verbose_level",
"vb"));
369 p.back().addAlternative(
"0",
"report nothing");
370 p.back().addAlternative(
"1",
"report parameter tuning");
371 p.back().addAlternative(
"2",
"report cross validation");
372 p.back().addAlternative(
"3",
"report multi class svm");
373 p.back().addAlternative(
"4",
"report two class svm");
374 p.back().addAlternative(
"5",
"report addtitional training infos");
376 p.push_back(
ParamInfo(
"draw_progress_bar",
"p"));
377 p.back().addAlternative(
"0",
"no acsii progress bars");
378 p.back().addAlternative(
"1",
379 "draw acsii progress bars (default)");
385 return "ascii_progress_reporter";
390 return "reports progress on ansi ascii terminal";
396 bool _drawProgressBar;
397 bool _cursorPosSaved;
398 int _progressBarLength;
400 std::vector< std::string> _rotatingDash;
virtual void reportProgress(int taskLevel, const std::string &taskName, float completenessPercent, const std::string &completenessPlainText)
This method is called if some progress was made.
virtual void clearScreen()
(description)
static const char * name()
const int TASK_LEVEL_TRAINING_INFO
void setVerboseLevel(int verboseLevel)
set the reporting level for reportProgress() method.
ProgressReporter(std::ostream &os=std::cerr)
virtual void setMaxTaskLevel(int n)
static const char * description()
const int TASK_LEVEL_GRID_SEARCH
void loadParameters(STDATA &stData)
virtual void additionalInfo(int taskLevel, const std::string &text)
(description)
virtual ~ProgressReporter()
const int TASK_LEVEL_CROSS_VAL
const int TASK_LEVEL_MULTICLASS
The ParamInfo class contains informations about one parameter like key, help text, guiHints etc.
void saveParameters(STDATA &stData) const
const int TASK_LEVEL_TWOCLASS
static void getParamInfos(std::vector< ParamInfo > &p)
get information about the parameters, that are used in loadParameters() and saveParameters().