libnick 2024.9.2
A cross-platform base for native Nickvision applications.
Loading...
Searching...
No Matches
Nickvision::System::Process Class Reference

A managed process. More...

#include <process.h>

Public Member Functions

 Process (const std::filesystem::path &path, const std::vector< std::string > &args={})
 Constructs a Process.
 
 ~Process ()
 Destructs a Process.
 
const std::filesystem::path & getPath () const
 Gets the path of the process.
 
Events::Event< ProcessExitedEventArgs > & exited ()
 Gets the event for when the process has exited.
 
bool isRunning () const
 Gets whether or not the process is running.
 
bool hasCompleted () const
 Gets whether or not the process has completed.
 
int getExitCode () const
 Gets the exit code of the process.
 
const std::string & getOutput () const
 Gets the console output of the process.
 
bool start ()
 Starts the process.
 
bool kill ()
 Kills the process.
 
int waitForExit ()
 Waits for the process to exit.
 

Detailed Description

A managed process.

Constructor & Destructor Documentation

◆ Process()

Nickvision::System::Process::Process ( const std::filesystem::path & path,
const std::vector< std::string > & args = {} )

Constructs a Process.

Parameters
pathThe path of the process to execute
argsThe arguments to pass to the process
Exceptions
std::runtime_errorThrown if the process could not be created

◆ ~Process()

Nickvision::System::Process::~Process ( )

Destructs a Process.

This method will wait for the process to exit if it is still running.

Member Function Documentation

◆ exited()

Events::Event< ProcessExitedEventArgs > & Nickvision::System::Process::exited ( )

Gets the event for when the process has exited.

Returns
The process exited event

◆ getExitCode()

int Nickvision::System::Process::getExitCode ( ) const

Gets the exit code of the process.

Returns
The exit code of the process. -1 if the process has not completed.

◆ getOutput()

const std::string & Nickvision::System::Process::getOutput ( ) const

Gets the console output of the process.

Returns
The console output of the process. Empty if the process has not completed.

◆ getPath()

const std::filesystem::path & Nickvision::System::Process::getPath ( ) const

Gets the path of the process.

Returns
The path of the process

◆ hasCompleted()

bool Nickvision::System::Process::hasCompleted ( ) const

Gets whether or not the process has completed.

Returns
True if completed, else false.

◆ isRunning()

bool Nickvision::System::Process::isRunning ( ) const

Gets whether or not the process is running.

Returns
True if running, else false.

◆ kill()

bool Nickvision::System::Process::kill ( )

Kills the process.

Returns
True if the process was killed, else false.

◆ start()

bool Nickvision::System::Process::start ( )

Starts the process.

Returns
True if the process was started, else false.

◆ waitForExit()

int Nickvision::System::Process::waitForExit ( )

Waits for the process to exit.

This function will block until the process has exited.

Make sure to call start() before calling this function.

Returns
The exit code of the process

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