dfx 0.1.0
Linux-based dynamic dataflow executor
Loading...
Searching...
No Matches
dfx::Subprocess::ProcessFactory Class Reference

Small builder-style helper to assemble a Process::Config and then construct a Process. More...

#include <dfx-subprocess/ProcessFactory.hpp>

Public Member Functions

Process build (FdWatch::Poller &poller)
 Build a Process using the current configuration and bind it to a poller.
Process::Config buildConfig ()
 Extract the current Process::Config.
ProcessFactorysetBin (fs::path p) noexcept
 Set the program path/name to execute.
ProcessFactorysetArgs (std::vector< std::string > args) noexcept
 Set the argument vector.
ProcessFactorysetEnv (std::vector< std::string > env) noexcept
 Set the environment vector.
ProcessFactorysetCwd (fs::path p) noexcept
 Set the working directory.
ProcessFactorysetEnvMode (Process::EnvMode mode) noexcept
 Set the environment mode.
ProcessFactorysetStdinMode (Process::StreamMode mode) noexcept
 Set how stdin is connected for the child.
ProcessFactorysetStdoutMode (Process::StreamMode mode) noexcept
 Set how stdout is connected for the child.
ProcessFactorysetStderrMode (Process::StreamMode mode) noexcept
 Set how stderr is connected for the child.
ProcessFactorysetStdoutCaptureConfig (Process::CaptureConfig conf)
 Set capture configuration for stdout.
ProcessFactorysetStderrCaptureConfig (Process::CaptureConfig conf)
 Set capture configuration for stderr.
ProcessFactorysetUseParentDeathSignal (bool use) noexcept
 Enable/disable the parent-death signal behavior.

Detailed Description

Small builder-style helper to assemble a Process::Config and then construct a Process.

ProcessFactory owns a single mutable Process::Config instance. You configure it via the set*() fluent setters, then either:

Warning
This helper is effectively single-use: both build() and buildConfig() move (std::move) the internal configuration out of the factory. After calling either, the factory’s internal config is in a moved-from state and should be considered unspecified until you assign all fields again.
Note
This class performs no validation. For example, it does not call Process::resolveProgramPath() or check that bin exists/is executable; any such behavior is handled elsewhere.

Member Function Documentation

◆ build()

Process dfx::Subprocess::ProcessFactory::build ( FdWatch::Poller & poller)
inline

Build a Process using the current configuration and bind it to a poller.

This function moves (std::move) the internal configuration into the returned Process. After this call, the factory is left with a moved-from configuration.

Parameters
pollerPoller instance used by the created process.
Returns
A new Process constructed with the current configuration.
Warning
After calling this, the factory should not be reused unless you fully reinitialize its configuration via the setters.

◆ buildConfig()

Process::Config dfx::Subprocess::ProcessFactory::buildConfig ( )
inline

Extract the current Process::Config.

This function moves (std::move) the internal configuration out of the factory. After this call, the factory is left with a moved-from configuration.

Returns
The configuration currently stored in the factory.
Warning
After calling this, the factory should not be reused unless you fully reinitialize its configuration via the setters.

◆ setArgs()

ProcessFactory & dfx::Subprocess::ProcessFactory::setArgs ( std::vector< std::string > args)
inlinenoexcept

Set the argument vector.

Parameters
argsArgument list.
Returns
*this for fluent chaining.

◆ setBin()

ProcessFactory & dfx::Subprocess::ProcessFactory::setBin ( fs::path p)
inlinenoexcept

Set the program path/name to execute.

Parameters
pBinary path/name.
Returns
*this for fluent chaining.

◆ setCwd()

ProcessFactory & dfx::Subprocess::ProcessFactory::setCwd ( fs::path p)
inlinenoexcept

Set the working directory.

Parameters
pWorking directory path.
Returns
*this for fluent chaining.

◆ setEnv()

ProcessFactory & dfx::Subprocess::ProcessFactory::setEnv ( std::vector< std::string > env)
inlinenoexcept

Set the environment vector.

Parameters
envEnvironment entries (typically "KEY=VALUE" strings).
Returns
*this for fluent chaining.

◆ setEnvMode()

ProcessFactory & dfx::Subprocess::ProcessFactory::setEnvMode ( Process::EnvMode mode)
inlinenoexcept

Set the environment mode.

Parameters
modeHow Process::Config::env is applied.
Returns
*this for fluent chaining.

◆ setStderrCaptureConfig()

ProcessFactory & dfx::Subprocess::ProcessFactory::setStderrCaptureConfig ( Process::CaptureConfig conf)
inline

Set capture configuration for stderr.

Parameters
confCapture configuration.
Returns
*this for fluent chaining.

◆ setStderrMode()

ProcessFactory & dfx::Subprocess::ProcessFactory::setStderrMode ( Process::StreamMode mode)
inlinenoexcept

Set how stderr is connected for the child.

Parameters
modeStream wiring mode.
Returns
*this for fluent chaining.

◆ setStdinMode()

ProcessFactory & dfx::Subprocess::ProcessFactory::setStdinMode ( Process::StreamMode mode)
inlinenoexcept

Set how stdin is connected for the child.

Parameters
modeStream wiring mode.
Returns
*this for fluent chaining.

◆ setStdoutCaptureConfig()

ProcessFactory & dfx::Subprocess::ProcessFactory::setStdoutCaptureConfig ( Process::CaptureConfig conf)
inline

Set capture configuration for stdout.

Parameters
confCapture configuration.
Returns
*this for fluent chaining.

◆ setStdoutMode()

ProcessFactory & dfx::Subprocess::ProcessFactory::setStdoutMode ( Process::StreamMode mode)
inlinenoexcept

Set how stdout is connected for the child.

Parameters
modeStream wiring mode.
Returns
*this for fluent chaining.

◆ setUseParentDeathSignal()

ProcessFactory & dfx::Subprocess::ProcessFactory::setUseParentDeathSignal ( bool use)
inlinenoexcept

Enable/disable the parent-death signal behavior.

Parameters
useWhether to enable it.
Returns
*this for fluent chaining.

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