SourceXtractorPlusPlus
1.0.3
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
SEMain
src
lib
ProgressReporterFactory.cpp
Go to the documentation of this file.
1
17
#include "
SEMain/ProgressReporterFactory.h
"
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
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
.c_str(), po::value<bool>()->default_value(
true
),
35
"Show/Hide progress bar display"
);
36
}
37
38
void
ProgressReporterFactory::configure
(
const
std::map<std::string, boost::program_options::variable_value>
&args) {
39
m_min_interval
=
std::chrono::seconds
(args.
at
(
PROGRESS_MIN_INTERVAL
).as<
int
>());
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
()) {
43
m_disable_progress_bar
=
true
;
44
}
45
}
46
47
std::shared_ptr<ProgressMediator>
ProgressReporterFactory::createProgressMediator
()
const
{
48
auto
mediator =
std::make_shared<ProgressMediator>
();
49
50
#ifndef WITHOUT_NCURSES
51
if
(!
m_disable_progress_bar
&&
ProgressNCurses::isTerminalCapable
()) {
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
ProgressLogger.h
ProgressNCurses.h
ProgressReporterFactory.h
std::map::at
T at(T... args)
std::string
SourceXtractor::ProgressNCurses::isTerminalCapable
static bool isTerminalCapable()
Definition
ProgressNCurses.cpp:893
SourceXtractor::ProgressReporterFactory::m_disable_progress_bar
bool m_disable_progress_bar
Definition
ProgressReporterFactory.h:55
SourceXtractor::ProgressReporterFactory::createProgressMediator
std::shared_ptr< ProgressMediator > createProgressMediator(void) const
Definition
ProgressReporterFactory.cpp:47
SourceXtractor::ProgressReporterFactory::addOptions
void addOptions(boost::program_options::options_description &options) const
Definition
ProgressReporterFactory.cpp:31
SourceXtractor::ProgressReporterFactory::configure
void configure(const std::map< std::string, boost::program_options::variable_value > &args)
Definition
ProgressReporterFactory.cpp:38
SourceXtractor::ProgressReporterFactory::m_min_interval
std::chrono::steady_clock::duration m_min_interval
Definition
ProgressReporterFactory.h:54
SourceXtractor::ProgressReporterFactory::ProgressReporterFactory
ProgressReporterFactory()
Definition
ProgressReporterFactory.cpp:28
std::chrono::seconds
std::string::empty
T empty(T... args)
std::make_shared
T make_shared(T... args)
std::map
Euclid::Configuration::logger
static Elements::Logging logger
SourceXtractor
Definition
Aperture.h:30
SourceXtractor::PROGRESS_BAR
static const std::string PROGRESS_BAR
Definition
ProgressReporterFactory.cpp:26
SourceXtractor::PROGRESS_MIN_INTERVAL
static const std::string PROGRESS_MIN_INTERVAL
Definition
ProgressReporterFactory.cpp:25
boost::program_options
std::chrono
std
STL namespace.
std::shared_ptr
Generated by
1.14.0