Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

process_progress_dialog Class Reference

A details_progress_dialog customized for an array of processes to execute. More...

#include <process_progress_dialog.h>

Inheritance diagram for process_progress_dialog:

details_progress_dialog wxDialog build_progress_dialog List of all members.

Public Methods

  process_progress_dialog (wxWindow *parent, const wxArrayString &commandline_array, long stream_kind=optionPROCESS_PROGRESS_DIALOG_STDOUT_STREAM_KIND|optionPROCESS_PROGRESS_DIALOG_STDERR_STREAM_KIND, wxSignal kill_signal=wxSIGKILL, bool automatically_close_when_done=TRUE, const wxString &show_hide_listbox_configuration_key=wxEmptyString, const wxString &log_filename=wxEmptyString, const wxString &log_path=wxEmptyString, long scroll_history=optionDETAILS_PROGRESS_LISTBOX_RECOMMENDED_SCROLL_HISTORY)
  Constructor.

  process_progress_dialog ()
virtual  ~process_progress_dialog ()
  Destructor.

virtual bool  on_before_execute_commandline_array ()
  Virtual: optional action to do before starting execution of the commandline array.

virtual bool  on_before_execute_commandline_array_item (size_t commandline_array_index)
  Virtual: optional action to do before start execution of a commandline in array.

virtual bool  on_after_commandline_array_item_execution_finished (size_t commandline_array_index)
  Virtual: optional action to do after a commandline in the array has terminated.

virtual bool  on_after_commandline_array_executions_finished ()
  Virtual: optional action to de after all commands's processes have terminated.

virtual void  on_process_generated_an_output_line (long stream_kind, const wxString &line_text, size_t commandline_array_index)
  The vital function to override: actions to do when process made a line of output.

virtual void  action_to_do_when_dialog_is_ready ()
  Start up the actions watched by the progress dialog. Called from on_paint().

virtual void  action_to_do_before_dialog_finishes_closing ()
  Clean up any actions before the dialog vanishes. Called from on_close().

virtual void  action_to_do_after_dialog_finishes_closing ()
  Clean up any actions after the dialog EndModal()s. Called from on_close().

void  set_stream_kind (long stream_kind)
  Accessor to m_stream_kind,allowing switching of what types of streams to catch.

long  get_stream_kind ()
  Accessor to query what types of streams should be caught (used by piped_process).

size_t  get_current_commandline_array_index ()
  Acessor to m_current_commandline_array_index.

virtual void  custom_kill (long pid, wxSignal sig, wxKillError *krc)
  An optional custom kill for the process instead of a stock wxKill().


Detailed Description

A details_progress_dialog customized for an array of processes to execute.

This dialog manages the execution of an array of processes. The processes are run one after another: when one terminates, the next one starts. If the class is used directly, it will just run the processes and put the output into the progress_listbox. However, it is more useful as a derived class, using the pluggable virtual functions for things that are to be done before and after each commandline, and before and after the entire suite of commandlines, and most importantly: something to do when a line of output is generated from the process.

The stream kinds that are caught by the process dialog can be either stdout, stderr, both or neither. The stream kinds are specified in the constructor, but also can be changed by a derived class while the array of processes is running. IMPORTANTLY, however, don't use a stream of which there will be no/little output generated, unless you don't care about the program freezing while it gets a character from the stream (to see if Eof and other things).

When the dialog is closed, via stop button or window's corner 'X' button it will detach and kill all processes that it started, that are still running (which should only be 1 at a time, since they are executed in sequence).

\note: This implementation is the only current approach that works as of wx2.3.3. All other avenues have already been examined.


Constructor & Destructor Documentation

process_progress_dialog::process_progress_dialog wxWindow *    parent,
const wxArrayString &    commandline_array,
long    stream_kind = optionPROCESS_PROGRESS_DIALOG_STDOUT_STREAM_KIND|optionPROCESS_PROGRESS_DIALOG_STDERR_STREAM_KIND,
wxSignal    kill_signal = wxSIGKILL,
bool    automatically_close_when_done = TRUE,
const wxString &    show_hide_listbox_configuration_key = wxEmptyString,
const wxString &    log_filename = wxEmptyString,
const wxString &    log_path = wxEmptyString,
long    scroll_history = optionDETAILS_PROGRESS_LISTBOX_RECOMMENDED_SCROLL_HISTORY
 

Constructor.

Parameters:
parent  The parent window.
commandline_array  An array of commandline commands to be executed.
stream_kind  The kind of stream to be analyzed: stdout, stderr, both or none.
kill_signal.  The kill signal to be used to kill the commandline. See wxKill() docs for a list of signals.
Note:
On MSW, there is really only a wxSIGNONE, wxSIGTERM and wxSIGKILL. All others go to wxSIGTERM. Very importantly, on MSW, wxSIGTERM only works if the program has windows: it won't do anything if it is a console only app.
Parameters:
automatically_close_when_done  Whether to close when done. This can be overridden later with set_automatically_close_when_done();
show_hide_listbox_configuration_key  Configuration key of active configuration to store show/hide details. wxEmptyString means don't load/save.
log_filename  Filename of the process logfile. A plkrFILE_FRIENDLY_DATETIME_STAMP in the string will replace with a file-friendly datetime string. If using plkrFILE_FRIENDLY_DATETIME_STAMP, recommended to keep the rest of name below 11 characters total if need Macintosh 31-character limit requirement.
log_path  Default path of the logfile in dialog. Default of wxEmptyString means the current directory.
scroll_history  Number of lines to keep in the listbox at one time. After this, newly appended lines will remove the topmost line. Can be a number, or can use one of the options* to get a recommended for OS or an infinite one.

Member Function Documentation

virtual void process_progress_dialog::action_to_do_after_dialog_finishes_closing   [virtual]
 

Clean up any actions after the dialog EndModal()s. Called from on_close().

Needed for MSW to drop in something to terminate program if this is the only window, as otherwise app doesn't seem to quit

Reimplemented from details_progress_dialog.

Reimplemented in build_progress_dialog.

virtual void process_progress_dialog::custom_kill long    pid,
wxSignal    sig,
wxKillError *    krc
[virtual]
 

An optional custom kill for the process instead of a stock wxKill().

See wxKill() for parameter list

Reimplemented in build_progress_dialog.

virtual bool process_progress_dialog::on_after_commandline_array_executions_finished   [inline, virtual]
 

Virtual: optional action to de after all commands's processes have terminated.

Returns :
TRUE if there was no error.

Reimplemented in build_progress_dialog.

virtual bool process_progress_dialog::on_after_commandline_array_item_execution_finished size_t    commandline_array_index [inline, virtual]
 

Virtual: optional action to do after a commandline in the array has terminated.

Parameters:
commandline_array_index  The index of the commandline_array.
Returns :
TRUE if there was no error.

Reimplemented in build_progress_dialog.

virtual bool process_progress_dialog::on_before_execute_commandline_array   [inline, virtual]
 

Virtual: optional action to do before starting execution of the commandline array.

Returns :
TRUE if there was no error.

Reimplemented in build_progress_dialog.

virtual bool process_progress_dialog::on_before_execute_commandline_array_item size_t    commandline_array_index [inline, virtual]
 

Virtual: optional action to do before start execution of a commandline in array.

Parameters:
commandline_array_index  The index of the commandline_array.
Returns :
TRUE if there was no error.

Reimplemented in build_progress_dialog.

virtual void process_progress_dialog::on_process_generated_an_output_line long    stream_kind,
const wxString &    line_text,
size_t    commandline_array_index
[virtual]
 

The vital function to override: actions to do when process made a line of output.

Most likely you are going to want to parse the added line and based on what the line said, append_line_to_listbox() (or not), set_gauge(), or set_statictext() or maybe throw up a message box or something else.

The Default is to just call_append_line_to_listbox() and then keep going, but you'll probably want to override with what you want it to do.

Parameters:
stream_kind  the kind of stream that was added. Either optionPROCESS_PROGRESS_DIALOG_STDOUT_STREAM_KIND (stdout) or optionPROCESS_PROGRESS_DIALOG_STDERR_STREAM_KIND (stderr). This allows you to do one thing for an line from one kind of stream, and another for another kind of stream.
line_text  The output string line from that stream.
commandline_array_index  Index of the command array that generated this line, (in case you want to handle them differently).

Reimplemented in build_progress_dialog.