OpenMS  2.6.0
Public Member Functions | Private Attributes | List of all members
ExternalProcessMBox Class Reference

A wrapper around ExternalProcess to conveniently show a MessageBox when an error occurs. More...

#include <OpenMS/VISUAL/MISC/ExternalProcessMBox.h>

Collaboration diagram for ExternalProcessMBox:
[legend]

Public Member Functions

 ExternalProcessMBox ()
 default Ctor; callbacks for stdout/stderr are empty More...
 
 ExternalProcessMBox (std::function< void(const String &)> callbackStdOut, std::function< void(const String &)> callbackStdErr)
 set the callback functions to process stdout and stderr output when the external process generates it More...
 
 ~ExternalProcessMBox ()
 D'tor. More...
 
void setCallbacks (std::function< void(const String &)> callbackStdOut, std::function< void(const String &)> callbackStdErr)
 re-wire the callbacks used using run() More...
 
ExternalProcess::RETURNSTATE run (QWidget *parent, const QString &exe, const QStringList &args, const QString &working_dir, const bool verbose, String &error_msg)
 Runs a program by calling ExternalProcess::run and shows any error reported in error_msg as a MessageBox before this function returns. More...
 
ExternalProcess::RETURNSTATE run (QWidget *parent, const QString &exe, const QStringList &args, const QString &working_dir, const bool verbose)
 Same as other overload, just without a returned error message. More...
 

Private Attributes

ExternalProcess ep_
 

Detailed Description

A wrapper around ExternalProcess to conveniently show a MessageBox when an error occurs.

Use the custom Ctor to provide callback functions for stdout/stderr output or set them via setCallbacks().

Running an external program blocks the caller, so do not use this in a main GUI thread (unless you have some other means to tell the user that no interaction is possible at the moment).

Constructor & Destructor Documentation

◆ ExternalProcessMBox() [1/2]

default Ctor; callbacks for stdout/stderr are empty

◆ ExternalProcessMBox() [2/2]

ExternalProcessMBox ( std::function< void(const String &)>  callbackStdOut,
std::function< void(const String &)>  callbackStdErr 
)

set the callback functions to process stdout and stderr output when the external process generates it

◆ ~ExternalProcessMBox()

D'tor.

Member Function Documentation

◆ run() [1/2]

ExternalProcess::RETURNSTATE run ( QWidget parent,
const QString &  exe,
const QStringList &  args,
const QString &  working_dir,
const bool  verbose 
)

Same as other overload, just without a returned error message.

◆ run() [2/2]

ExternalProcess::RETURNSTATE run ( QWidget parent,
const QString &  exe,
const QStringList &  args,
const QString &  working_dir,
const bool  verbose,
String error_msg 
)

Runs a program by calling ExternalProcess::run and shows any error reported in error_msg as a MessageBox before this function returns.

Parameters
parentOptional parent widget, used to position QMesssageBoxes above the parent
exeThe program to call (can contain spaces in path, no problem)
argsA list of extra arguments (can be empty)
working_dirExecute the external process in the given directory (relevant when relative input/output paths are given). Leave empty to use the current working directory.
verboseReport the call command and errors via the callbacks (default: false)
[out]error_stringMessage to display to the user or log somewhere if something went wrong (if return != SUCCESS)
Returns
Did the external program succeed (SUCCESS) or did something go wrong?

◆ setCallbacks()

void setCallbacks ( std::function< void(const String &)>  callbackStdOut,
std::function< void(const String &)>  callbackStdErr 
)

re-wire the callbacks used using run()

Member Data Documentation

◆ ep_

ExternalProcess ep_
private