xtd 0.2.0
Loading...
Searching...
No Matches
process.h
Go to the documentation of this file.
1
4#pragma once
5#include "../core_export.h"
6#include "../date_time.h"
7#include "../event.h"
8#include "../event_handler.h"
9#include "../object.h"
10#include "../ustring.h"
11#include "../optional.h"
14#include "process_start_info.h"
15#include <functional>
16#include <memory>
17
19struct __init_process_message_box_message__;
21
23namespace xtd {
25 namespace diagnostics {
47 class core_export_ process final : public xtd::object {
48 struct data;
49
50 public:
57 friend process;
58 void set_data(process::data* data) {data_ = data;}
59 public:
61
65 bool is_empty() const noexcept;
67
69
74 xtd::diagnostics::data_received_event_handler& operator +=(const xtd::diagnostics::data_received_event_handler& handler) noexcept;
75
79 xtd::diagnostics::data_received_event_handler& operator +=(const typename xtd::diagnostics::data_received_event_handler::function_t& function) noexcept;
80
84 template<typename fn_t>
85 xtd::diagnostics::data_received_event_handler& operator +=(fn_t function) noexcept {
86 error_data_received_callback() += (function);
87 return xtd::diagnostics::data_received_event_handler::operator +=(function);
88 }
89
94
98 xtd::diagnostics::data_received_event_handler& operator -=(const typename xtd::diagnostics::data_received_event_handler::function_t& function) noexcept;
99
103 template<typename fn_t>
104 xtd::diagnostics::data_received_event_handler& operator -=(fn_t function) noexcept {
105 error_data_received_callback() -= (function);
106 return data_received_event_handler::operator -=(function);
107 }
109
110 private:
111 data_received_event_handler& error_data_received_callback() noexcept;
112 process::data* data_ = nullptr;
113 };
114
120 class exit_event : protected xtd::event_handler {
121 friend process;
122 void set_data(process::data* data) {data_ = data;}
123 public:
125
129 bool is_empty() const noexcept;
131
133
138 xtd::event_handler& operator +=(const xtd::event_handler& handler) noexcept;
139
143 xtd::event_handler& operator +=(const typename xtd::event_handler::function_t& function) noexcept;
144
148 template<typename fn_t>
149 xtd::event_handler& operator +=(fn_t function) noexcept {
150 exit_callback() += (function);
151 return xtd::event_handler::operator +=(function);
152 }
153
157 xtd::event_handler& operator -=(const xtd::event_handler& handler) noexcept;
158
162 xtd::event_handler& operator -=(const typename xtd::event_handler::function_t& function) noexcept;
163
167 template<typename fn_t>
168 xtd::event_handler& operator -=(fn_t function) noexcept {
169 exit_callback() -= (function);
170 return xtd::event_handler::operator -=(function);
171 }
173
174 private:
175 event_handler& exit_callback() noexcept;
176 process::data* data_ = nullptr;
177 };
178
185 friend process;
186 void set_data(process::data* data) {data_ = data;}
187 public:
189
193 bool is_empty() const noexcept;
195
197
202 xtd::diagnostics::data_received_event_handler& operator +=(const xtd::diagnostics::data_received_event_handler& handler) noexcept;
203
207 xtd::diagnostics::data_received_event_handler& operator +=(const typename xtd::diagnostics::data_received_event_handler::function_t& function) noexcept;
208
212 template<typename fn_t>
213 xtd::diagnostics::data_received_event_handler& operator +=(fn_t function) noexcept {
214 output_data_received_callback() += (function);
215 return xtd::diagnostics::data_received_event_handler::operator +=(function);
216 }
217
222
226 xtd::diagnostics::data_received_event_handler& operator -=(const typename xtd::diagnostics::data_received_event_handler::function_t& function) noexcept;
227
231 template<typename fn_t>
232 xtd::diagnostics::data_received_event_handler& operator -=(fn_t function) noexcept {
233 output_data_received_callback() -= (function);
234 return xtd::diagnostics::data_received_event_handler::operator -=(function);
235 }
237
238 private:
239 data_received_event_handler& output_data_received_callback() noexcept;
240 process::data* data_ = nullptr;
241 };
242
244
255
257 process(const process&) = default;
258 process& operator =(const process& value);
259 ~process();
261
263
280 int32 base_priority() const;
281
289 bool enable_raising_events() const;
297 process& enable_raising_events(bool value);
298
310 int32 exit_code() const;
311
316 xtd::date_time exit_time() const;
317
325 intptr handle() const;
326
334 bool has_exited() const;
335
343 int32 id() const;
344
350 ustring machine_name() const;
351
367 xtd::diagnostics::process_priority_class priority_class() const;
383 process& priority_class(xtd::diagnostics::process_priority_class value);
384
390 ustring process_name() const;
391
500 std::istream& standard_error();
501
565 std::ostream& standard_input();
566
690 std::istream& standard_output();
691
701 const xtd::diagnostics::process_start_info& start_info() const;
711 xtd::diagnostics::process_start_info& start_info();
721 process& start_info(const xtd::diagnostics::process_start_info& value);
722
726 xtd::date_time start_time() const;
728
730
735 void close();
736
745 void kill();
746
753 bool start();
754
762 process& wait_for_exit();
763
772 process& wait_for_exit(int32 milliseconds);
774
776
791 static process start(const xtd::diagnostics::process_start_info& start_info);
803 static process start(const ustring& file_name);
815 static process start(const ustring& file_name, const ustring& arguments);
817
819
825 error_data_received_event error_data_received;
826
833
838 output_data_received_event output_data_received;
840
841 protected:
843
848 virtual void on_exited();
850
851 private:
852 std::shared_ptr<data> data_;
853 friend __init_process_message_box_message__;
854 inline static xtd::delegate<void(const ustring&)> message_box_message_;
855 };
856 }
857}
Represents an instant in time, typically expressed as a date and time of day.
Definition date_time.h:79
Represents a process error data received event.
Definition process.h:56
bool is_empty() const noexcept
Gets a value indicate if the event is empty.
Represents a process exit event.
Definition process.h:120
bool is_empty() const noexcept
Gets a value indicate if the event is empty.
Represents a process output data received event.
Definition process.h:184
bool is_empty() const noexcept
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.h:37
Provides access to local and remote processes and enables you to start and stop local system processe...
Definition process.h:47
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.h:32
Represents text as a sequence of UTF-8 code units.
Definition ustring.h:47
Contains xtd::diagnostics::data_received_event_handler event handler.
generic_event_handler<> event_handler
Represents the method that will handle an event that has no event data.
Definition event_handler.h:32
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.h:25
#define core_export_
Define shared library export.
Definition core_export.h:13
int_least32_t int32
Represents a 32-bit signed integer.
Definition types.h:131
intmax_t intptr
Represent a pointer or a handle.
Definition types.h:153
process_priority_class
Indicates the priority that the system associates with a process. This value, together with the prior...
Definition process_priority_class.h:24
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10
Contains xtd::diagnostics::process_priority_class enum class.
Contains xtd::diagnostics::process_start_info class.