UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
LaunchContext Class Reference

#include <launch_manager.hpp>

Inheritance diagram for LaunchContext:
Inheritance graph
Collaboration diagram for LaunchContext:
Collaboration graph

Classes

struct  ExtraData
 

Public Types

enum class  Type { None = 0 , Preview , Run , Query }
 

Signals

void processOutputLine (std::string_view sv)
 
void processOutputRead (QString str)
 
void processTerminated (int code, QProcess::ExitStatus es, bool wasRequested)
 

Public Member Functions

 LaunchContext ()
 
void terminate ()
 

Public Attributes

QStringList args
 
QString executablePath
 
std::unique_ptr< ExtraData > extraData
 
LineBuffer lineBuf
 
QProcess process
 
Type type = Type::None
 

Private Slots

void processOutput ()
 
void processTerminationHandler (int code, QProcess::ExitStatus es)
 

Private Attributes

QTimer killTimer
 
bool terminationRequested = false
 

Static Private Attributes

static constexpr int terminateTimeoutMs = 1000
 

Detailed Description

Definition at line 11 of file launch_manager.hpp.

Member Enumeration Documentation

◆ Type

enum class LaunchContext::Type
strong
Enumerator
None 
Preview 
Run 
Query 

Definition at line 14 of file launch_manager.hpp.

Constructor & Destructor Documentation

◆ LaunchContext()

LaunchContext::LaunchContext ( )

Definition at line 76 of file launch_manager.cpp.

76 {
77 connect(&killTimer, &QTimer::timeout, [=](){ process.kill(); });
78 killTimer.setSingleShot(true);
79 connect(&process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
81
82 process.setProcessChannelMode(QProcess::MergedChannels);
83 connect(&process, &QProcess::readyReadStandardOutput, this, &LaunchContext::processOutput);
84 connect(&process, &QProcess::readyReadStandardError, this, &LaunchContext::processOutput);
85}
void processTerminationHandler(int code, QProcess::ExitStatus es)

References killTimer, process, processOutput(), and processTerminationHandler().

Here is the call graph for this function:

Member Function Documentation

◆ processOutput

void LaunchContext::processOutput ( )
privateslot

Definition at line 91 of file launch_manager.cpp.

91 {
92 QString str = process.isReadable() ? process.readAll() : QByteArray();
93
94 emit processOutputRead(str);
95
96 lineBuf.write(str.toStdString());
97
98 while(lineBuf.hasLine()){
100 lineBuf.pop();
101 }
102}
void processOutputLine(std::string_view sv)
LineBuffer lineBuf
void processOutputRead(QString str)
bool hasLine() const
void write(std::string_view str)
std::string_view peek() const

References LineBuffer::hasLine(), lineBuf, LineBuffer::peek(), LineBuffer::pop(), process, processOutputLine(), processOutputRead(), and LineBuffer::write().

Referenced by LaunchContext().

Here is the call graph for this function:

◆ processOutputLine

void LaunchContext::processOutputLine ( std::string_view sv)
signal

Referenced by processOutput().

◆ processOutputRead

void LaunchContext::processOutputRead ( QString str)
signal

Referenced by processOutput().

◆ processTerminated

void LaunchContext::processTerminated ( int code,
QProcess::ExitStatus es,
bool wasRequested )
signal

◆ processTerminationHandler

void LaunchContext::processTerminationHandler ( int code,
QProcess::ExitStatus es )
privateslot

Definition at line 87 of file launch_manager.cpp.

87 {
89}
void processTerminated(int code, QProcess::ExitStatus es, bool wasRequested)

References processTerminated(), and terminationRequested.

Referenced by LaunchContext().

Here is the call graph for this function:

◆ terminate()

void LaunchContext::terminate ( )

Definition at line 104 of file launch_manager.cpp.

104 {
106 process.terminate();
108}
static constexpr int terminateTimeoutMs

References killTimer, process, terminateTimeoutMs, and terminationRequested.

Member Data Documentation

◆ args

QStringList LaunchContext::args

Definition at line 29 of file launch_manager.hpp.

◆ executablePath

QString LaunchContext::executablePath

Definition at line 28 of file launch_manager.hpp.

◆ extraData

std::unique_ptr<ExtraData> LaunchContext::extraData

Definition at line 32 of file launch_manager.hpp.

◆ killTimer

QTimer LaunchContext::killTimer
private

Definition at line 43 of file launch_manager.hpp.

Referenced by LaunchContext(), and terminate().

◆ lineBuf

LineBuffer LaunchContext::lineBuf

Definition at line 31 of file launch_manager.hpp.

Referenced by processOutput().

◆ process

QProcess LaunchContext::process

Definition at line 30 of file launch_manager.hpp.

Referenced by LaunchContext(), processOutput(), and terminate().

◆ terminateTimeoutMs

int LaunchContext::terminateTimeoutMs = 1000
staticconstexprprivate

Definition at line 42 of file launch_manager.hpp.

Referenced by terminate().

◆ terminationRequested

bool LaunchContext::terminationRequested = false
private

Definition at line 44 of file launch_manager.hpp.

Referenced by processTerminationHandler(), and terminate().

◆ type

Type LaunchContext::type = Type::None

Definition at line 27 of file launch_manager.hpp.


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