musredit 1.0.0
Loading...
Searching...
No Matches
PDumpOutputHandler Class Reference

Dialog for executing and displaying dump_header command output. More...

#include <PDumpOutputHandler.h>

Inheritance diagram for PDumpOutputHandler:
Collaboration diagram for PDumpOutputHandler:

Public Member Functions

 PDumpOutputHandler (QVector< QString > &cmd)
 Constructs the dump output handler dialog and starts the command.
 
virtual ~PDumpOutputHandler ()
 Destructor - ensures the dump_header process is terminated.
 

Private Slots

virtual void readFromStdOut ()
 Slot to read and display standard output from the process.
 
virtual void readFromStdErr ()
 Slot to read and display standard error from the process.
 
virtual void quitButtonPressed ()
 Slot called when the Quit button is pressed.
 

Private Attributes

Process Management

Members for managing the external process.

qint64 fProcPID
 Process ID of the running dump_header command.
 
std::unique_ptr< QProcess > fProc
 QProcess object managing the dump_header execution.
 
UI Components

Dialog user interface elements.

std::unique_ptr< QVBoxLayout > fVbox
 Vertical layout manager for dialog widgets.
 
std::unique_ptr< QTextEdit > fOutput
 Read-only text widget displaying command output.
 
std::unique_ptr< QPushButton > fQuitButton
 Button to close dialog and terminate process.
 

Detailed Description

Dialog for executing and displaying dump_header command output.

This class provides a modal dialog that executes the dump_header external command and displays its output in real-time. The dump_header tool is part of the musrfit suite and extracts header information from muon spin rotation/relaxation data files.

Features:
  • Executes dump_header as a child process via QProcess
  • Captures both stdout and stderr output
  • Displays output in a read-only text widget
  • Provides a Quit button to terminate the process
  • Handles process cleanup on dialog close
Usage:
QVector<QString> cmd;
cmd << "/path/to/dump_header" << "-f" << "datafile.root";
PDumpOutputHandler dialog(cmd);
dialog.exec();
PDumpOutputHandler(QVector< QString > &cmd)
Constructs the dump output handler dialog and starts the command.
Platform Notes:
  • On macOS, sets DYLD_LIBRARY_PATH for ROOT library access
  • On Linux, sets LD_LIBRARY_PATH for ROOT library access
See also
PFitOutputHandler For similar handling of musrfit output

Definition at line 92 of file PDumpOutputHandler.h.

Constructor & Destructor Documentation

◆ PDumpOutputHandler()

PDumpOutputHandler::PDumpOutputHandler ( QVector< QString > & cmd)

Constructs the dump output handler dialog and starts the command.

Initializes the dialog UI and starts the dump_header process. The constructor performs the following steps:

  1. Creates the dialog layout with a text output area and Quit button
  2. Configures the process environment with appropriate library paths
  3. Extracts the program and arguments from the command vector
  4. Starts the process and connects output signals to display slots
Environment Configuration:
  • On macOS: Sets DYLD_LIBRARY_PATH to include $ROOTSYS/lib
  • On Linux: Sets LD_LIBRARY_PATH to include $ROOTSYS/lib
Parameters
cmdCommand vector where cmd[0] is the executable path and subsequent elements are command-line arguments.
Note
If the command vector is empty, the constructor returns immediately without creating the UI. If the process fails to start, an error dialog is displayed.

Definition at line 71 of file PDumpOutputHandler.cpp.

◆ ~PDumpOutputHandler()

PDumpOutputHandler::~PDumpOutputHandler ( )
virtual

Destructor - ensures the dump_header process is terminated.

Performs cleanup by ensuring the child process is properly terminated. The termination sequence is:

  1. Attempt graceful termination with QProcess::terminate()
  2. Wait for process to finish
  3. If still running, use QProcess::kill()
  4. As a last resort, use system kill -9 command

This multi-stage approach ensures the process doesn't become orphaned, even if it doesn't respond to normal termination signals.

Definition at line 136 of file PDumpOutputHandler.cpp.

Member Function Documentation

◆ quitButtonPressed

void PDumpOutputHandler::quitButtonPressed ( )
privatevirtualslot

Slot called when the Quit button is pressed.

Handles user request to close the dialog. If the dump_header process is still running, attempts to terminate it gracefully using QProcess::terminate(). If graceful termination fails within the timeout period, forcefully kills the process using QProcess::kill().

After ensuring the process is stopped, accepts the dialog (closes it with QDialog::Accepted result).

Definition at line 201 of file PDumpOutputHandler.cpp.

◆ readFromStdErr

void PDumpOutputHandler::readFromStdErr ( )
privatevirtualslot

Slot to read and display standard error from the process.

Slot to capture and display standard error from the process.

Reads all available data from the process's standard error stream and appends it to the text display widget. This slot is connected to the QProcess::readyReadStandardError signal and may be called multiple times as error output arrives in chunks.

Error output is displayed alongside normal output in the same text widget, allowing users to see errors in context with regular output.

Definition at line 182 of file PDumpOutputHandler.cpp.

◆ readFromStdOut

void PDumpOutputHandler::readFromStdOut ( )
privatevirtualslot

Slot to read and display standard output from the process.

Slot to capture and display standard output from the process.

Reads all available data from the process's standard output stream and appends it to the text display widget. This slot is connected to the QProcess::readyReadStandardOutput signal and may be called multiple times as output arrives in chunks.

Definition at line 163 of file PDumpOutputHandler.cpp.

Member Data Documentation

◆ fOutput

std::unique_ptr<QTextEdit> PDumpOutputHandler::fOutput
private

Read-only text widget displaying command output.

Definition at line 130 of file PDumpOutputHandler.h.

◆ fProc

std::unique_ptr<QProcess> PDumpOutputHandler::fProc
private

QProcess object managing the dump_header execution.

Definition at line 122 of file PDumpOutputHandler.h.

◆ fProcPID

qint64 PDumpOutputHandler::fProcPID
private

Process ID of the running dump_header command.

Definition at line 121 of file PDumpOutputHandler.h.

◆ fQuitButton

std::unique_ptr<QPushButton> PDumpOutputHandler::fQuitButton
private

Button to close dialog and terminate process.

Definition at line 131 of file PDumpOutputHandler.h.

◆ fVbox

std::unique_ptr<QVBoxLayout> PDumpOutputHandler::fVbox
private

Vertical layout manager for dialog widgets.

Definition at line 129 of file PDumpOutputHandler.h.


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