PACS System 0.1.0
PACS DICOM system library
Loading...
Searching...
No Matches
kcenon::pacs::integration_test::background_process_guard Class Reference

RAII wrapper for a background process. More...

#include <test_fixtures.h>

Collaboration diagram for kcenon::pacs::integration_test::background_process_guard:
Collaboration graph

Public Member Functions

 background_process_guard (process_launcher::pid_type pid=process_launcher::invalid_pid)
 
 ~background_process_guard ()
 
 background_process_guard (const background_process_guard &)=delete
 
background_process_guardoperator= (const background_process_guard &)=delete
 
 background_process_guard (background_process_guard &&other) noexcept
 
background_process_guardoperator= (background_process_guard &&other) noexcept
 
void set_pid (process_launcher::pid_type pid)
 Set the process ID.
 
process_launcher::pid_type pid () const noexcept
 
bool is_running () const
 Check if process is running.
 
void stop ()
 Stop the process.
 
process_launcher::pid_type release ()
 Release ownership without stopping.
 

Private Attributes

process_launcher::pid_type pid_ {process_launcher::invalid_pid}
 

Detailed Description

RAII wrapper for a background process.

Automatically stops the process when the guard goes out of scope.

Definition at line 1448 of file test_fixtures.h.

Constructor & Destructor Documentation

◆ background_process_guard() [1/3]

kcenon::pacs::integration_test::background_process_guard::background_process_guard ( process_launcher::pid_type pid = process_launcher::invalid_pid)
inlineexplicit

Definition at line 1450 of file test_fixtures.h.

1452 : pid_(pid) {}
process_launcher::pid_type pid() const noexcept

◆ ~background_process_guard()

kcenon::pacs::integration_test::background_process_guard::~background_process_guard ( )
inline

Definition at line 1454 of file test_fixtures.h.

1454 {
1455 stop();
1456 }

References stop().

Here is the call graph for this function:

◆ background_process_guard() [2/3]

kcenon::pacs::integration_test::background_process_guard::background_process_guard ( const background_process_guard & )
delete

◆ background_process_guard() [3/3]

kcenon::pacs::integration_test::background_process_guard::background_process_guard ( background_process_guard && other)
inlinenoexcept

Definition at line 1463 of file test_fixtures.h.

1464 : pid_(other.pid_) {
1466 }
static constexpr pid_type invalid_pid
Invalid PID constant (0 is reserved on both platforms)

References kcenon::pacs::integration_test::process_launcher::invalid_pid.

Member Function Documentation

◆ is_running()

bool kcenon::pacs::integration_test::background_process_guard::is_running ( ) const
inlinenodiscard

Check if process is running.

Definition at line 1484 of file test_fixtures.h.

1484 {
1485 return pid_ > 0 && process_launcher::is_running(pid_);
1486 }
static bool is_running(pid_type pid)
Check if a process is still running.

References kcenon::pacs::integration_test::process_launcher::is_running(), and pid_.

Referenced by kcenon::pacs::integration_test::dcmtk_server_guard::is_running(), and TEST_CASE().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=() [1/2]

background_process_guard & kcenon::pacs::integration_test::background_process_guard::operator= ( background_process_guard && other)
inlinenoexcept

Definition at line 1468 of file test_fixtures.h.

1468 {
1469 if (this != &other) {
1470 stop();
1471 pid_ = other.pid_;
1473 }
1474 return *this;
1475 }

References kcenon::pacs::integration_test::process_launcher::invalid_pid, pid_, and stop().

Here is the call graph for this function:

◆ operator=() [2/2]

background_process_guard & kcenon::pacs::integration_test::background_process_guard::operator= ( const background_process_guard & )
delete

◆ pid()

process_launcher::pid_type kcenon::pacs::integration_test::background_process_guard::pid ( ) const
inlinenodiscardnoexcept
Returns
Process ID

Definition at line 1481 of file test_fixtures.h.

1481{ return pid_; }

References pid_.

Referenced by kcenon::pacs::integration_test::dcmtk_server_guard::pid(), and set_pid().

Here is the caller graph for this function:

◆ release()

process_launcher::pid_type kcenon::pacs::integration_test::background_process_guard::release ( )
inline

Release ownership without stopping.

Definition at line 1497 of file test_fixtures.h.

1497 {
1498 auto p = pid_;
1500 return p;
1501 }

References kcenon::pacs::integration_test::process_launcher::invalid_pid, and pid_.

◆ set_pid()

void kcenon::pacs::integration_test::background_process_guard::set_pid ( process_launcher::pid_type pid)
inline

Set the process ID.

Definition at line 1478 of file test_fixtures.h.

1478{ pid_ = pid; }

References pid(), and pid_.

Referenced by kcenon::pacs::integration_test::dcmtk_server_guard::dcmtk_server_guard().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ stop()

void kcenon::pacs::integration_test::background_process_guard::stop ( )
inline

Member Data Documentation

◆ pid_

process_launcher::pid_type kcenon::pacs::integration_test::background_process_guard::pid_ {process_launcher::invalid_pid}
private

Definition at line 1504 of file test_fixtures.h.

Referenced by is_running(), operator=(), pid(), release(), set_pid(), and stop().


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