SourceXtractorPlusPlus  0.11
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 
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
std::string
STL class.
std::shared_ptr
STL class.
std::chrono::seconds
SourceXtractor::PROGRESS_BAR_DISABLED
static const std::string PROGRESS_BAR_DISABLED
Definition: ProgressReporterFactory.cpp:26
SourceXtractor::ProgressReporterFactory::addOptions
void addOptions(boost::program_options::options_description &options) const
Definition: ProgressReporterFactory.cpp:31
SourceXtractor::PROGRESS_MIN_INTERVAL
static const std::string PROGRESS_MIN_INTERVAL
Definition: ProgressReporterFactory.cpp:25
SourceXtractor
Definition: Aperture.h:30
SourceXtractor::ProgressNCurses::isTerminalCapable
static bool isTerminalCapable()
Definition: ProgressNCurses.cpp:867
ProgressLogger.h
std::map::at
T at(T... args)
SourceXtractor::ProgressReporterFactory::m_min_interval
std::chrono::steady_clock::duration m_min_interval
Definition: ProgressReporterFactory.h:54
std::string::c_str
T c_str(T... args)
std::map
STL class.
SourceXtractor::ProgressReporterFactory::m_disable_progress_bar
bool m_disable_progress_bar
Definition: ProgressReporterFactory.h:55
SourceXtractor::logger
static Elements::Logging logger
Definition: PluginManager.cpp:45
ProgressReporterFactory.h
ProgressNCurses.h
SourceXtractor::ProgressReporterFactory::ProgressReporterFactory
ProgressReporterFactory()
Definition: ProgressReporterFactory.cpp:28
SourceXtractor::ProgressReporterFactory::createProgressMediator
std::shared_ptr< ProgressMediator > createProgressMediator(void) const
Definition: ProgressReporterFactory.cpp:47
SourceXtractor::ProgressReporterFactory::configure
void configure(const std::map< std::string, boost::program_options::variable_value > &args)
Definition: ProgressReporterFactory.cpp:38