ifw-daq  2.1.0-pre1
IFW Data Acquisition modules
Public Member Functions | List of all members
daq::AsyncProcessIf Class Referenceabstract

Interface to asynchronous process. More...

#include <asyncProcess.hpp>

+ Inheritance diagram for daq::AsyncProcessIf:

Public Member Functions

virtual ~AsyncProcessIf ()
 
virtual boost::future< int > Initiate ()=0
 Initiates async operation by executing the specified process. More...
 
virtual std::optional< pid_t > GetPid () const noexcept=0
 Get PID. More...
 
virtual std::error_code Abort () noexcept=0
 Aborts the operation by terminating process which completes the operation. More...
 
virtual std::error_code Signal (int sig) noexcept=0
 Send signal to process. More...
 
virtual std::vector< std::string > const & GetArguments () const noexcept=0
 
virtual bool IsRunning () const noexcept=0
 

Signals

using SigOutStream = boost::signals2::signal< void(pid_t, std::string const &)>
 Signal type for stdout/stderr signals. More...
 
virtual boost::signals2::connection ConnectStdout (SigOutStream::slot_type const &slot)=0
 Connect slot to line-buffered stdout signal. More...
 
virtual boost::signals2::connection ConnectStderr (SigOutStream::slot_type const &slot)=0
 Connect slot to line-buffered stderr signal. More...
 

Detailed Description

Interface to asynchronous process.

Definition at line 27 of file asyncProcess.hpp.

Member Typedef Documentation

◆ SigOutStream

using daq::AsyncProcessIf::SigOutStream = boost::signals2::signal<void(pid_t, std::string const&)>

Signal type for stdout/stderr signals.

Definition at line 82 of file asyncProcess.hpp.

Constructor & Destructor Documentation

◆ ~AsyncProcessIf()

virtual daq::AsyncProcessIf::~AsyncProcessIf ( )
inlinevirtual

Definition at line 29 of file asyncProcess.hpp.

Member Function Documentation

◆ Abort()

virtual std::error_code daq::AsyncProcessIf::Abort ( )
pure virtualnoexcept

Aborts the operation by terminating process which completes the operation.

If process is not running this will not do anything.

Returns
Error code of operation. If process is not running, because it has not been started for with AsyncProcess::Initiate() for example, it returns std::errc::no_such_process.

Implemented in daq::AsyncProcess.

◆ ConnectStderr()

virtual boost::signals2::connection daq::AsyncProcessIf::ConnectStderr ( SigOutStream::slot_type const &  slot)
pure virtual

Connect slot to line-buffered stderr signal.

Signal is invoked for every line read from process.

Returns
connection object.

Implemented in daq::MockAsyncProcess, and daq::AsyncProcess.

◆ ConnectStdout()

virtual boost::signals2::connection daq::AsyncProcessIf::ConnectStdout ( SigOutStream::slot_type const &  slot)
pure virtual

Connect slot to line-buffered stdout signal.

Signal is invoked for every line read from process.

Returns
connection object.

Implemented in daq::MockAsyncProcess, and daq::AsyncProcess.

◆ GetArguments()

virtual std::vector<std::string> const& daq::AsyncProcessIf::GetArguments ( ) const
pure virtualnoexcept
Returns
arguments used when launching process.

Implemented in daq::AsyncProcess.

◆ GetPid()

virtual std::optional<pid_t> daq::AsyncProcessIf::GetPid ( ) const
pure virtualnoexcept

Get PID.

Returns
pid of process if process is running, otherwise nullopt.

Implemented in daq::AsyncProcess.

◆ Initiate()

virtual boost::future<int> daq::AsyncProcessIf::Initiate ( )
pure virtual

Initiates async operation by executing the specified process.

This can only be called once.

Implemented in daq::MockAsyncProcess, daq::RsyncAsyncProcess, and daq::AsyncProcess.

◆ IsRunning()

virtual bool daq::AsyncProcessIf::IsRunning ( ) const
pure virtualnoexcept
Returns
true if process is running.
false otherwise.

Implemented in daq::AsyncProcess.

◆ Signal()

virtual std::error_code daq::AsyncProcessIf::Signal ( int  sig)
pure virtualnoexcept

Send signal to process.

Unlike Abort() this can be used to gracefully terminate application by sending e.g. SIGTERM.

Parameters
sigSignal to send.
Returns
Error code of operation. If process is not running, because it has not been started for with AsyncProcess::Initiate() for example, it returns std::errc::no_such_process.

Implemented in daq::AsyncProcess.


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