46 lines
1.8 KiB
C++
46 lines
1.8 KiB
C++
#ifndef PROCESS_LIBPROCESS_INCLUDE_PROCESS_FACTORY_HPP
|
|
#define PROCESS_LIBPROCESS_INCLUDE_PROCESS_FACTORY_HPP
|
|
|
|
#include <memory>
|
|
#include <string>
|
|
#include "process/process.hpp"
|
|
#include "process/libprocess_export.hpp"
|
|
|
|
namespace process::controller {
|
|
class ProcessDefinition;
|
|
enum class ProcessType : uint32_t;
|
|
}
|
|
|
|
namespace process {
|
|
/**
|
|
@brief Factory method that creates Process instances for specific process definitions.
|
|
|
|
In order to control a process, you need an instance of Process controlling a process
|
|
based on a process description.
|
|
|
|
Given a valid process definition, create_process_for will create an appropriate
|
|
instance of Process for you.
|
|
|
|
Note that multiple calls to create_process_for with the same process definition
|
|
will create separate instances of Process for this definition.
|
|
|
|
This file is a public header, that is, one that a user of libprocess is
|
|
expected to see and use.
|
|
@param pd ProcessDefinition to use for the process object
|
|
@param user optional parameter if using this library in an application; Required if running as a service. if specified will try to run the process under that user.
|
|
Note that this (at least if using windows) only works if that specific user is logged in.
|
|
|
|
@note In case function is invoked by multipe threads they must be serialized.
|
|
*/
|
|
LIBPROCESS_EXPORT extern std::shared_ptr<Process> create_process(const process::controller::ProcessDefinition& pd, const std::string& default_user = "");
|
|
|
|
/**
|
|
* @brief creates a Process instance for an already existing process id
|
|
|
|
* @param pt Type of process, necessary to order to stop the process correctly
|
|
* @return Instance of process for the given process id
|
|
*/
|
|
LIBPROCESS_EXPORT extern std::shared_ptr<Process> attach_process(const process::controller::ProcessType pt, const os_pid_t os_pid);
|
|
}
|
|
|
|
#endif
|