SourceXtractorPlusPlus 1.0.3
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
SourceXtractor::ProgressNCurses::Dashboard Class Reference
Collaboration diagram for SourceXtractor::ProgressNCurses::Dashboard:

Public Member Functions

 Dashboard ()
 ~Dashboard ()
void update (const std::list< ProgressInfo > &info)

Private Member Functions

void uiThread ()
void handleSignal (const struct pollfd &poll_fd, LogWidget &logWidget)
void pipeToLog (const struct pollfd &poll_fd, int pipe, LogWidget &out) const
void handleKeyPress (const struct pollfd &poll_fd, LogWidget &logWidget) const
void ncursesMode ()

Private Attributes

std::unique_ptr< boost::thread > m_ui_thread
std::list< ProgressInfom_progress_info
std::mutex m_progress_info_mutex
int m_stderr_original
int m_stderr_pipe
FILEm_stderr
int m_stdout_original
int m_stdout_pipe
std::vector< std::stringm_log_text
std::atomic_bool m_trigger_resize {false}
std::atomic_bool m_exit_loop {false}

Detailed Description

The Dashboard wraps the UI screen, which runs on an independent thread to avoid race conditions.

ncurses calls are not thread safe, so it is better to contain them within a single thread. Normally, ncurses does a proper setup of signal handling (i.e. SIGINT), so the terminal is returned into its proper state. However, we want to re-print the output after exiting the curses mode, so we need to handle the signals ourselves: catch, exit ncurses, dump log, and delegate to the previously installed handler.

See also
handleTerminatingSignal

Definition at line 688 of file ProgressNCurses.cpp.

Constructor & Destructor Documentation

◆ Dashboard()

SourceXtractor::ProgressNCurses::Dashboard::Dashboard ( )
inline

Constructor

Note
Intercepts stdout and stderr and starts up the UI thread

Definition at line 842 of file ProgressNCurses.cpp.

References std::bind(), std::generic_category(), SourceXtractor::interceptFileDescriptor(), m_stderr, m_stderr_original, m_stderr_pipe, m_stdout_original, m_stdout_pipe, m_ui_thread, Euclid::make_unique(), and uiThread().

Here is the call graph for this function:

◆ ~Dashboard()

SourceXtractor::ProgressNCurses::Dashboard::~Dashboard ( )
inline

Destructor Notifies the UI thread to finish and clean up, and recover stdout and stderr

Definition at line 857 of file ProgressNCurses.cpp.

References std::fclose(), m_stderr, m_stderr_original, m_stderr_pipe, m_stdout_original, m_stdout_pipe, and m_ui_thread.

Here is the call graph for this function:

Member Function Documentation

◆ handleKeyPress()

void SourceXtractor::ProgressNCurses::Dashboard::handleKeyPress ( const struct pollfd & poll_fd,
LogWidget & logWidget ) const
inlineprivate

Definition at line 761 of file ProgressNCurses.cpp.

References SourceXtractor::LogWidget::handleKeyPress().

Referenced by ncursesMode().

Here is the call graph for this function:

◆ handleSignal()

void SourceXtractor::ProgressNCurses::Dashboard::handleSignal ( const struct pollfd & poll_fd,
LogWidget & logWidget )
inlineprivate

Definition at line 734 of file ProgressNCurses.cpp.

References m_exit_loop, m_trigger_resize, SourceXtractor::signal_fds, std::snprintf(), and SourceXtractor::LogWidget::write().

Referenced by ncursesMode().

Here is the call graph for this function:

◆ ncursesMode()

◆ pipeToLog()

void SourceXtractor::ProgressNCurses::Dashboard::pipeToLog ( const struct pollfd & poll_fd,
int pipe,
LogWidget & out ) const
inlineprivate

Definition at line 751 of file ProgressNCurses.cpp.

References SourceXtractor::LogWidget::write().

Referenced by ncursesMode().

Here is the call graph for this function:

◆ uiThread()

void SourceXtractor::ProgressNCurses::Dashboard::uiThread ( )
inlineprivate

Main UI thread. All (almost) ncurses handling should be done here, as it is not thread safe

Definition at line 711 of file ProgressNCurses.cpp.

References std::endl(), m_log_text, m_stderr_original, m_stdout_original, SourceXtractor::ncurses_done, and ncursesMode().

Referenced by Dashboard().

Here is the call graph for this function:

◆ update()

void SourceXtractor::ProgressNCurses::Dashboard::update ( const std::list< ProgressInfo > & info)
inline

Update the progress information

Definition at line 880 of file ProgressNCurses.cpp.

References m_progress_info, m_progress_info_mutex, m_trigger_resize, and std::list< T >::size().

Here is the call graph for this function:

Member Data Documentation

◆ m_exit_loop

std::atomic_bool SourceXtractor::ProgressNCurses::Dashboard::m_exit_loop {false}
private

Definition at line 706 of file ProgressNCurses.cpp.

Referenced by handleSignal(), and ncursesMode().

◆ m_log_text

std::vector<std::string> SourceXtractor::ProgressNCurses::Dashboard::m_log_text
private

Definition at line 703 of file ProgressNCurses.cpp.

Referenced by ncursesMode(), and uiThread().

◆ m_progress_info

std::list<ProgressInfo> SourceXtractor::ProgressNCurses::Dashboard::m_progress_info
private

Definition at line 691 of file ProgressNCurses.cpp.

Referenced by ncursesMode(), and update().

◆ m_progress_info_mutex

std::mutex SourceXtractor::ProgressNCurses::Dashboard::m_progress_info_mutex
private

Definition at line 692 of file ProgressNCurses.cpp.

Referenced by ncursesMode(), and update().

◆ m_stderr

FILE* SourceXtractor::ProgressNCurses::Dashboard::m_stderr
private

Definition at line 697 of file ProgressNCurses.cpp.

Referenced by Dashboard(), ncursesMode(), and ~Dashboard().

◆ m_stderr_original

int SourceXtractor::ProgressNCurses::Dashboard::m_stderr_original
private

Definition at line 695 of file ProgressNCurses.cpp.

Referenced by Dashboard(), uiThread(), and ~Dashboard().

◆ m_stderr_pipe

int SourceXtractor::ProgressNCurses::Dashboard::m_stderr_pipe
private

Definition at line 696 of file ProgressNCurses.cpp.

Referenced by Dashboard(), ncursesMode(), and ~Dashboard().

◆ m_stdout_original

int SourceXtractor::ProgressNCurses::Dashboard::m_stdout_original
private

Definition at line 699 of file ProgressNCurses.cpp.

Referenced by Dashboard(), uiThread(), and ~Dashboard().

◆ m_stdout_pipe

int SourceXtractor::ProgressNCurses::Dashboard::m_stdout_pipe
private

Definition at line 700 of file ProgressNCurses.cpp.

Referenced by Dashboard(), ncursesMode(), and ~Dashboard().

◆ m_trigger_resize

std::atomic_bool SourceXtractor::ProgressNCurses::Dashboard::m_trigger_resize {false}
private

Definition at line 705 of file ProgressNCurses.cpp.

Referenced by handleSignal(), ncursesMode(), and update().

◆ m_ui_thread

std::unique_ptr<boost::thread> SourceXtractor::ProgressNCurses::Dashboard::m_ui_thread
private

Definition at line 690 of file ProgressNCurses.cpp.

Referenced by Dashboard(), and ~Dashboard().


The documentation for this class was generated from the following file: