Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitk::ProcessExecutor Class Reference

You may register an observer for an ExternalProcessOutputEvent, ExternalProcessStdOutEvent or ExternalProcessStdErrEvent in order to get notified of any output. More...

#include <mitkProcessExecutor.h>

Inheritance diagram for mitk::ProcessExecutor:
Collaboration diagram for mitk::ProcessExecutor:

Public Types

using Self = ProcessExecutor
 
using Superclass = ::itk::Object
 
using Pointer = ::itk::SmartPointer< Self >
 
using ConstPointer = ::itk::SmartPointer< const Self >
 
using ArgumentListType = std::vector< std::string >
 Type for the list of command-line arguments. More...
 

Public Member Functions

virtual const char * GetClassName () const
 
virtual void SetSharedOutputPipes (bool _arg)
 
virtual bool GetSharedOutputPipes () const
 
bool Execute (const std::string &executionPath, const std::string &executableName, ArgumentListType &argumentList)
 Executes an external process. More...
 
virtual bool Execute (const std::string &executionPath, const ArgumentListType &argumentList)
 Executes an external process. More...
 
int GetExitValue ()
 Returns the exit value of the last executed process. More...
 
void KillProcess ()
 Kills the currently running process. More...
 

Static Public Member Functions

static Pointer New ()
 
static std::string EnsureCorrectOSPathSeparator (const std::string &path)
 Converts path separators to the OS-correct form. More...
 
static std::string GetOSDependendExecutableName (const std::string &name)
 Returns the OS-dependent executable name (e.g. adds ".exe" on Windows). More...
 

Protected Member Functions

 ProcessExecutor ()
 
 ~ProcessExecutor () override
 

Protected Attributes

int m_ExitValue
 
bool m_SharedOutputPipes
 Specifies if the child process should share the output pipes (true) or not (false). If pipes are not shared the output will be passed by invoking ExternalProcessOutputEvents. More...
 

Detailed Description

You may register an observer for an ExternalProcessOutputEvent, ExternalProcessStdOutEvent or ExternalProcessStdErrEvent in order to get notified of any output.

Remarks
The events will only be invoked if the pipes are NOT(!) shared. By default the pipes are not shared.

Definition at line 81 of file mitkProcessExecutor.h.

Member Typedef Documentation

◆ ArgumentListType

using mitk::ProcessExecutor::ArgumentListType = std::vector<std::string>

Type for the list of command-line arguments.

Definition at line 96 of file mitkProcessExecutor.h.

◆ ConstPointer

◆ Pointer

◆ Self

◆ Superclass

using mitk::ProcessExecutor::Superclass = ::itk::Object

Definition at line 85 of file mitkProcessExecutor.h.

Constructor & Destructor Documentation

◆ ProcessExecutor()

mitk::ProcessExecutor::ProcessExecutor ( )
protected

◆ ~ProcessExecutor()

mitk::ProcessExecutor::~ProcessExecutor ( )
overrideprotected

Member Function Documentation

◆ EnsureCorrectOSPathSeparator()

static std::string mitk::ProcessExecutor::EnsureCorrectOSPathSeparator ( const std::string &  path)
static

Converts path separators to the OS-correct form.

Parameters
[in]pathThe path string to convert.
Returns
The path with correct OS-specific separators.

◆ Execute() [1/2]

virtual bool mitk::ProcessExecutor::Execute ( const std::string &  executionPath,
const ArgumentListType &  argumentList 
)
virtual

Executes an external process.

This version assumes that the executable name is the first argument in the argument list and has already been converted to its OS-dependent name.

Parameters
[in]executionPathWorking directory for the process.
[in]argumentListCommand-line arguments; first element is the executable.
Returns
true if the process executed successfully, false otherwise.

◆ Execute() [2/2]

bool mitk::ProcessExecutor::Execute ( const std::string &  executionPath,
const std::string &  executableName,
ArgumentListType &  argumentList 
)

Executes an external process.

Parameters
[in]executionPathWorking directory for the process.
[in]executableNameName of the executable to run.
[in,out]argumentListCommand-line arguments for the process.
Returns
true if the process executed successfully, false otherwise.

◆ GetClassName()

virtual const char* mitk::ProcessExecutor::GetClassName ( ) const
virtual

◆ GetExitValue()

int mitk::ProcessExecutor::GetExitValue ( )

Returns the exit value of the last executed process.

Returns
The process exit code.

◆ GetOSDependendExecutableName()

static std::string mitk::ProcessExecutor::GetOSDependendExecutableName ( const std::string &  name)
static

Returns the OS-dependent executable name (e.g. adds ".exe" on Windows).

Parameters
[in]nameThe platform-independent executable name.
Returns
The OS-dependent executable name.

◆ GetSharedOutputPipes()

virtual bool mitk::ProcessExecutor::GetSharedOutputPipes ( ) const
virtual

◆ KillProcess()

void mitk::ProcessExecutor::KillProcess ( )

Kills the currently running process.

◆ New()

static Pointer mitk::ProcessExecutor::New ( )
static

◆ SetSharedOutputPipes()

virtual void mitk::ProcessExecutor::SetSharedOutputPipes ( bool  _arg)
virtual

Member Data Documentation

◆ m_ExitValue

int mitk::ProcessExecutor::m_ExitValue
protected

Definition at line 148 of file mitkProcessExecutor.h.

◆ m_SharedOutputPipes

bool mitk::ProcessExecutor::m_SharedOutputPipes
protected

Specifies if the child process should share the output pipes (true) or not (false). If pipes are not shared the output will be passed by invoking ExternalProcessOutputEvents.

Remarks
The events will only be invoked if the pipes are NOT(!) shared.

Definition at line 155 of file mitkProcessExecutor.h.


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