SourceXtractorPlusPlus  0.15
Please provide a description of the project.
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_DISABLED{"progress-bar-disable"};
27 
28 ProgressReporterFactory::ProgressReporterFactory() : m_min_interval{std::chrono::seconds(5)},
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_DISABLED.c_str(), po::bool_switch(),
35  "Disable progress bar display");
36 }
37 
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
T at(T... args)
T c_str(T... args)
std::shared_ptr< ProgressMediator > createProgressMediator(void) const
void addOptions(boost::program_options::options_description &options) const
void configure(const std::map< std::string, boost::program_options::variable_value > &args)
std::chrono::steady_clock::duration m_min_interval
static const std::string PROGRESS_MIN_INTERVAL
static auto logger
Definition: WCS.cpp:44
static const std::string PROGRESS_BAR_DISABLED
STL namespace.