#ifndef PROCESS_LIBPROCESS_INCLUDE_PROCESS_HPP #define PROCESS_LIBPROCESS_INCLUDE_PROCESS_HPP #include #include "process/libprocess_export.hpp" #include "process_status.hpp" #include "process_statistic.hpp" namespace process::controller { class ProcessDefinition; } namespace process { /** Process interface expected to be used by library user. This interface represents a process, be it for a console application, a window application or a services. Processes can be started, stopped or terminated using this interfaces. Instances of this interface are created through the factory method create_process_for() declared in process_factory. This file is a public header, that is, one that a user of libprocess is expected to see and use. */ class LIBPROCESS_EXPORT Process { public: virtual ~Process() = default; Process(Process const&) = delete; Process& operator=(Process const&) & = delete; Process(Process&&) = delete; Process& operator=(Process&&) & = delete; /** Start this process. Attempts to start process. @throws ProcessAlreadyStartedException if process is already running @throws ProcessStartException if start failed for some reason @throws ProcessUpdateException if updating the process (essentially calling Process::update()) failed */ virtual void start() = 0; /** Stop this process. Attempts to stop process. @throws ProcessAlreadyStoppedException if process is already stopped @throws ProcessStopException if stop failed for some reason @throws ProcessUpdateException if updating the process (essentially calling Process::update()) failed */ virtual void stop() = 0; /** Terminates this process. Attempts to terminate this process. THIS IS ONLY A LAST RESORT WAY TO STOP A PROCESS! @throws ProcessAlreadyStoppedException if process is already stopped @throws ProcessTerminationException if terminate failed for some reason @throws ProcessUpdateException if updating the process (essentially calling Process::update()) failed */ virtual void terminate() = 0; /** Update the process, that is, its state. Attempts to update the state of the process (currently just whether or not it is running and its PID). May at a later time also update resource consumption. @throws ProcessUpdateException if updating the process (essentially calling Process::update()) failed */ virtual void update() = 0; /** Check whether or not the process is running. */ virtual bool is_running() const = 0; /** Retrieve the process definition used to create this process. @returns process definition */ virtual const controller::ProcessDefinition& get_definition() const = 0; /** Retrieve the process status. The process status is updated on every call to @ref Process::update(). @param status Struct contains all available status information */ virtual std::pair get_status() const = 0; protected: Process() = default; }; } #endif