xtd 0.2.0
Loading...
Searching...
No Matches
process.hpp
Go to the documentation of this file.
1
4#pragma once
5#include "../core_export.hpp"
6#include "../date_time.hpp"
7#include "../event.hpp"
9#include "../icomparable.hpp"
10#include "../object.hpp"
11#include "../string.hpp"
12#include "../optional.hpp"
16#include <functional>
17#include <memory>
18
20struct __init_process_message_box_message__;
22
24namespace xtd {
26 namespace diagnostics {
50 class core_export_ process final : public xtd::object, public xtd::icomparable<process> {
51 struct data;
52
53 public:
61 void set_data(xtd::diagnostics::process::data* data) {data_ = data;}
62 public:
64
68 [[nodiscard]] auto is_empty() const noexcept -> bool;
70
72
77 auto operator +=(const xtd::diagnostics::data_received_event_handler& handler) noexcept -> xtd::diagnostics::data_received_event_handler&;
78
82 auto operator +=(const typename xtd::diagnostics::data_received_event_handler::function_t& function) noexcept -> xtd::diagnostics::data_received_event_handler&;
83
87 template<class fn_t>
88 auto operator +=(fn_t function) noexcept -> xtd::diagnostics::data_received_event_handler& {
89 error_data_received_callback() += (function);
90 return xtd::diagnostics::data_received_event_handler::operator +=(function);
91 }
92
97
101 auto operator -=(const typename xtd::diagnostics::data_received_event_handler::function_t& function) noexcept -> xtd::diagnostics::data_received_event_handler&;
102
106 template<class fn_t>
107 auto operator -=(fn_t function) noexcept -> xtd::diagnostics::data_received_event_handler& {
108 error_data_received_callback() -= (function);
109 return data_received_event_handler::operator -=(function);
110 }
111
112
113 private:
114 xtd::diagnostics::data_received_event_handler& error_data_received_callback() noexcept;
115 xtd::diagnostics::process::data* data_ = nullptr;
116 };
117
123 class exit_event : protected xtd::event_handler {
125 void set_data(xtd::diagnostics::process::data* data) {data_ = data;}
126 public:
128
132 [[nodiscard]] auto is_empty() const noexcept -> bool;
134
136
141 auto operator +=(const xtd::event_handler& handler) noexcept -> xtd::event_handler&;
142
146 auto operator +=(const typename xtd::event_handler::function_t& function) noexcept -> xtd::event_handler&;
147
151 template<class fn_t>
152 auto operator +=(fn_t function) noexcept -> xtd::event_handler& {
153 exit_callback() += (function);
154 return xtd::event_handler::operator +=(function);
155 }
156
160 auto operator -=(const xtd::event_handler& handler) noexcept -> xtd::event_handler&;
161
165 auto operator -=(const typename xtd::event_handler::function_t& function) noexcept -> xtd::event_handler&;
166
170 template<class fn_t>
171 auto operator -=(fn_t function) noexcept -> xtd::event_handler& {
172 exit_callback() -= (function);
173 return xtd::event_handler::operator -=(function);
174 }
175
176
177 private:
178 xtd::event_handler& exit_callback() noexcept;
179 xtd::diagnostics::process::data* data_ = nullptr;
180 };
181
189 void set_data(xtd::diagnostics::process::data* data) {data_ = data;}
190 public:
192
196 [[nodiscard]] auto is_empty() const noexcept -> bool;
198
200
206
210 auto operator +=(const typename xtd::diagnostics::data_received_event_handler::function_t& function) noexcept -> xtd::diagnostics::data_received_event_handler&;
211
215 template<class fn_t>
216 auto operator +=(fn_t function) noexcept -> xtd::diagnostics::data_received_event_handler& {
217 output_data_received_callback() += (function);
218 return xtd::diagnostics::data_received_event_handler::operator +=(function);
219 }
220
225
229 auto operator -=(const typename xtd::diagnostics::data_received_event_handler::function_t& function) noexcept -> xtd::diagnostics::data_received_event_handler&;
230
234 template<class fn_t>
235 auto operator -=(fn_t function) noexcept -> xtd::diagnostics::data_received_event_handler& {
236 output_data_received_callback() -= (function);
237 return xtd::diagnostics::data_received_event_handler::operator -=(function);
238 }
239
240
241 private:
242 xtd::diagnostics::data_received_event_handler& output_data_received_callback() noexcept;
243 xtd::diagnostics::process::data* data_ = nullptr;
244 };
245
247
258
260 process(const xtd::diagnostics::process&) = default;
261 auto operator =(const xtd::diagnostics::process& value) -> process&;
262 ~process();
264
266
283 [[nodiscard]] auto base_priority() const -> xtd::int32;
284
292 [[nodiscard]] auto enable_raising_events() const -> bool;
301
313 [[nodiscard]] auto exit_code() const -> xtd::int32;
314
319 [[nodiscard]] auto exit_time() const -> xtd::date_time;
320
328 [[nodiscard]] auto handle() const -> xtd::intptr;
329
337 [[nodiscard]] auto has_exited() const -> bool;
338
346 [[nodiscard]] auto id() const -> xtd::int32;
347
353 [[nodiscard]] auto machine_name() const -> xtd::string;
354
370 [[nodiscard]] auto priority_class() const -> xtd::diagnostics::process_priority_class;
387
393 [[nodiscard]] auto process_name() const -> xtd::string;
394
501 [[nodiscard]] auto standard_error() -> std::istream&;
502
565 [[nodiscard]] auto standard_input() -> std::ostream&;
566
687 [[nodiscard]] auto standard_output() -> std::istream&;
688
698 [[nodiscard]] auto start_info() const -> const xtd::diagnostics::process_start_info&;
708 [[nodiscard]] auto start_info() -> xtd::diagnostics::process_start_info&;
719
723 [[nodiscard]] auto start_time() const -> xtd::date_time;
725
727
732 auto close() -> void;
733
742 auto kill() -> void;
743
750 auto start() -> bool;
751
760
769 auto wait_for_exit(int32 milliseconds) -> xtd::diagnostics::process&;
771
773
800 static auto start(const xtd::string& file_name) -> xtd::diagnostics::process;
812 static auto start(const xtd::string& file_name, const xtd::string& arguments) -> xtd::diagnostics::process;
814
816
823
830
837
839 [[nodiscard]] auto compare_to(const xtd::diagnostics::process& o) const noexcept -> xtd::int32 override {return this < &o ? -1 : this > &o ? 1 : 0;}
841
842 protected:
844
849 virtual auto on_exited() -> void;
851
852 private:
853 xtd::sptr<data> data_;
854 friend __init_process_message_box_message__;
855 inline static xtd::delegate<void(const xtd::string&)> message_box_message_;
856 };
857 }
858}
Represents a process error data received event.
Definition process.hpp:59
auto is_empty() const noexcept -> bool
Gets a value indicate if the event is empty.
Represents a process exit event.
Definition process.hpp:123
auto is_empty() const noexcept -> bool
Gets a value indicate if the event is empty.
Represents a process output data received event.
Definition process.hpp:187
auto is_empty() const noexcept -> bool
Gets a value indicate if the event is empty.
Specifies a set of values that are used when you start a process.
Definition process_start_info.hpp:40
Provides access to local and remote processes and enables you to start and stop local system processe...
Definition process.hpp:50
auto process_name() const -> xtd::string
Gets the name of the process.
auto exit_time() const -> xtd::date_time
Gets the time that the associated process exited.
auto start_time() const -> xtd::date_time
Gets the time that the associated process was started.
auto kill() -> void
Immediately stops the associated process.
output_data_received_event output_data_received
Occurs each time an application writes a line to its redirected xtd::diagnostics::process::standard_o...
Definition process.hpp:835
auto base_priority() const -> xtd::int32
Gets the base priority xof the associated process.
auto wait_for_exit() -> xtd::diagnostics::process &
Instructs the xtd::diagnostics::process component to wait indefinitely for the associated process to ...
auto standard_input() -> std::ostream &
Gets a stream used to write the input of the application.
auto standard_error() -> std::istream &
Gets a stream used to read the error output of the application.
process()
Initializes a new instance of the xtd::diagnostics::process class.
auto start() -> bool
Starts (or reuses) the process resource that is specified by the xtd::diagnostics::process::start_inf...
auto has_exited() const -> bool
Gets a value indicating whether the associated process has been terminated.
auto exit_code() const -> xtd::int32
Gets the value that the associated process specified when it terminated.
auto handle() const -> xtd::intptr
Gets the native handle of the associated process.
auto priority_class() const -> xtd::diagnostics::process_priority_class
Gets the overall priority category for the associated process.
auto close() -> void
Frees all the resources that are associated with this component.
error_data_received_event error_data_received
Occurs when an application writes to its redirected xtd::diagnostics::process::standard_error stream.
Definition process.hpp:822
auto machine_name() const -> xtd::string
Gets the name of the computer the associated process is running on.
auto start_info() const -> const xtd::diagnostics::process_start_info &
Gets the properties to pass to the xtd::diagnostics::process::start() method of the xtd::diagnostics:...
exit_event exited
Occurs when a process exits.
Definition process.hpp:829
virtual auto on_exited() -> void
Raises the xtd::diagnostics::process::exited event.
auto standard_output() -> std::istream &
Gets a stream used to read the textual output of the application.
auto enable_raising_events() const -> bool
Gets whether the xtd::diagnostics::process::exited event should be raised when the process terminates...
Defines a generalized comparison method that a value type or class implements to create a type-specif...
Definition icomparable.hpp:22
virtual int32 compare_to(const process &obj) const noexcept=0
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:45
Contains core_export_ keyword.
Contains xtd::diagnostics::data_received_event_handler event handler.
Contains xtd::date_time class.
Contains xtd::event event.
Contains xtd::event_handler event handler.
@ date_time
Write the date and time.
Definition trace_options.hpp:31
generic_event_handler< const xtd::event_args & > event_handler
Represents the method that will handle an event that has no event data.
Definition event_handler.hpp:24
xtd::delegate< void(xtd::object &sender, const xtd::diagnostics::data_received_event_args &e)> data_received_event_handler
Represents the method that will handle the xtd::diagnostics::process::output_data_received and xtd::d...
Definition data_received_event_handler.hpp:27
#define core_export_
Define shared library export.
Definition core_export.hpp:13
xtd::basic_string< char > string
Represents text as a sequence of UTF-8 code units.
Definition __string_definitions.hpp:43
xtd::shared_ptr_object< type_t > sptr
The xtd::sptr object is a shared pointer.
Definition sptr.hpp:25
std::intmax_t intptr
Represent a pointer or a handle.
Definition intptr.hpp:23
std::int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:23
process_priority_class
Indicates the priority that the system associates with a process. This value, together with the prior...
Definition process_priority_class.hpp:26
@ o
The O key.
Definition console_key.hpp:116
Contains xtd::icomparable interface.
The xtd::diagnostics namespace provides classes that allow you to interact with system processes,...
Definition assert_dialog_result.hpp:10
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
constexpr const_pointer data() const noexcept
Gets direct access to the underlying contiguous storage.
Definition read_only_span.hpp:201
Contains xtd::object class.
Contains xtd::optional type.
Contains xtd::diagnostics::process_priority_class enum class.
Contains xtd::diagnostics::process_start_info class.
Contains xtd::string alias.