SourceXtractorPlusPlus  0.19
SourceXtractor++, the next generation SExtractor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ProgressReporterFactory.cpp
Go to the documentation of this file.
1 
18 #include "SEMain/ProgressLogger.h"
19 #include "SEMain/ProgressNCurses.h"
20 
21 namespace SourceXtractor {
22 
23 namespace po = boost::program_options;
24 
25 static const std::string PROGRESS_MIN_INTERVAL{"progress-min-interval"};
26 static const std::string PROGRESS_BAR {"progress-bar"};
27 
29  m_disable_progress_bar{false} {}
30 
31 void ProgressReporterFactory::addOptions(boost::program_options::options_description& options) const {
32  options.add_options() (PROGRESS_MIN_INTERVAL.c_str(), po::value<int>()->default_value(5),
33  "Minimal interval to wait before printing a new log entry with the progress report");
34  options.add_options() (PROGRESS_BAR.c_str(), po::value<bool>()->default_value(true),
35  "Show/Hide progress bar display");
36 }
37 
40  m_disable_progress_bar = !args.at(PROGRESS_BAR).as<bool>();
41  // If the output is written to stdout, we can't use the terminal for the fancy ncurses interface
42  if (args.at("output-catalog-filename").as<std::string>().empty()) {
44  }
45 }
46 
48  auto mediator = std::make_shared<ProgressMediator>();
49 
50 #ifndef WITHOUT_NCURSES
52  auto progress_bar = std::make_shared<ProgressNCurses>();
53  mediator->ProgressObservable::addObserver(progress_bar);
54  mediator->DoneObservable::addObserver(progress_bar);
55  }
56 #endif
57  // Always register the logger
58  auto logger = std::make_shared<ProgressLogger>(m_min_interval);
59  mediator->ProgressObservable::addObserver(logger);
60  mediator->DoneObservable::addObserver(logger);
61  return mediator;
62 }
63 
64 } // end SourceXtractor
static auto logger
Definition: WCS.cpp:41
void addOptions(boost::program_options::options_description &options) const
STL class.
STL class.
T at(T...args)
std::chrono::steady_clock::duration m_min_interval
static const std::string PROGRESS_BAR
static const std::string PROGRESS_MIN_INTERVAL
T c_str(T...args)
void configure(const std::map< std::string, boost::program_options::variable_value > &args)
std::shared_ptr< ProgressMediator > createProgressMediator(void) const