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"
8#include "../event_handler.hpp"
9#include "../object.hpp"
10#include "../string.hpp"
11#include "../optional.hpp"
15#include <functional>
16#include <memory>
17
19struct __init_process_message_box_message__;
21
23namespace xtd {
25 namespace diagnostics {
49 class core_export_ process final : public xtd::object {
50 struct data;
51
52 public:
59 friend process;
60 void set_data(process::data* data) {data_ = data;}
61 public:
63
67 bool is_empty() const noexcept;
69
71
76 xtd::diagnostics::data_received_event_handler& operator +=(const xtd::diagnostics::data_received_event_handler& handler) noexcept;
77
81 xtd::diagnostics::data_received_event_handler& operator +=(const typename xtd::diagnostics::data_received_event_handler::function_t& function) noexcept;
82
86 template<typename fn_t>
87 xtd::diagnostics::data_received_event_handler& operator +=(fn_t function) noexcept {
88 error_data_received_callback() += (function);
89 return xtd::diagnostics::data_received_event_handler::operator +=(function);
90 }
91
96
100 xtd::diagnostics::data_received_event_handler& operator -=(const typename xtd::diagnostics::data_received_event_handler::function_t& function) noexcept;
101
105 template<typename fn_t>
106 xtd::diagnostics::data_received_event_handler& operator -=(fn_t function) noexcept {
107 error_data_received_callback() -= (function);
108 return data_received_event_handler::operator -=(function);
109 }
111
112 private:
113 data_received_event_handler& error_data_received_callback() noexcept;
114 process::data* data_ = nullptr;
115 };
116
122 class exit_event : protected xtd::event_handler {
123 friend process;
124 void set_data(process::data* data) {data_ = data;}
125 public:
127
131 bool is_empty() const noexcept;
133
135
140 xtd::event_handler& operator +=(const xtd::event_handler& handler) noexcept;
141
145 xtd::event_handler& operator +=(const typename xtd::event_handler::function_t& function) noexcept;
146
150 template<typename fn_t>
151 xtd::event_handler& operator +=(fn_t function) noexcept {
152 exit_callback() += (function);
153 return xtd::event_handler::operator +=(function);
154 }
155
159 xtd::event_handler& operator -=(const xtd::event_handler& handler) noexcept;
160
164 xtd::event_handler& operator -=(const typename xtd::event_handler::function_t& function) noexcept;
165
169 template<typename fn_t>
170 xtd::event_handler& operator -=(fn_t function) noexcept {
171 exit_callback() -= (function);
172 return xtd::event_handler::operator -=(function);
173 }
175
176 private:
177 event_handler& exit_callback() noexcept;
178 process::data* data_ = nullptr;
179 };
180
187 friend process;
188 void set_data(process::data* data) {data_ = data;}
189 public:
191
195 bool is_empty() const noexcept;
197
199
204 xtd::diagnostics::data_received_event_handler& operator +=(const xtd::diagnostics::data_received_event_handler& handler) noexcept;
205
209 xtd::diagnostics::data_received_event_handler& operator +=(const typename xtd::diagnostics::data_received_event_handler::function_t& function) noexcept;
210
214 template<typename fn_t>
215 xtd::diagnostics::data_received_event_handler& operator +=(fn_t function) noexcept {
216 output_data_received_callback() += (function);
217 return xtd::diagnostics::data_received_event_handler::operator +=(function);
218 }
219
224
228 xtd::diagnostics::data_received_event_handler& operator -=(const typename xtd::diagnostics::data_received_event_handler::function_t& function) noexcept;
229
233 template<typename fn_t>
234 xtd::diagnostics::data_received_event_handler& operator -=(fn_t function) noexcept {
235 output_data_received_callback() -= (function);
236 return xtd::diagnostics::data_received_event_handler::operator -=(function);
237 }
239
240 private:
241 data_received_event_handler& output_data_received_callback() noexcept;
242 process::data* data_ = nullptr;
243 };
244
246
257
259 process(const process&) = default;
260 process& operator =(const process& value);
261 ~process();
263
265
282 int32 base_priority() const;
283
291 bool enable_raising_events() const;
299 process& enable_raising_events(bool value);
300
312 int32 exit_code() const;
313
318 xtd::date_time exit_time() const;
319
327 intptr handle() const;
328
336 bool has_exited() const;
337
345 int32 id() const;
346
352 string machine_name() const;
353
369 xtd::diagnostics::process_priority_class priority_class() const;
385 process& priority_class(xtd::diagnostics::process_priority_class value);
386
392 string process_name() const;
393
500 std::istream& standard_error();
501
564 std::ostream& standard_input();
565
686 std::istream& standard_output();
687
697 const xtd::diagnostics::process_start_info& start_info() const;
707 xtd::diagnostics::process_start_info& start_info();
717 process& start_info(const xtd::diagnostics::process_start_info& value);
718
722 xtd::date_time start_time() const;
724
726
731 void close();
732
741 void kill();
742
749 bool start();
750
758 process& wait_for_exit();
759
768 process& wait_for_exit(int32 milliseconds);
770
772
787 static process start(const xtd::diagnostics::process_start_info& start_info);
799 static process start(const string& file_name);
811 static process start(const string& file_name, const string& arguments);
813
815
821 error_data_received_event error_data_received;
822
829
834 output_data_received_event output_data_received;
836
837 protected:
839
844 virtual void on_exited();
846
847 private:
848 xtd::sptr<data> data_;
849 friend __init_process_message_box_message__;
850 inline static xtd::delegate<void(const string&)> message_box_message_;
851 };
852 }
853}
Represents an instant in time, typically expressed as a date and time of day.
Definition date_time.hpp:85
Represents a process error data received event.
Definition process.hpp:58
bool is_empty() const noexcept
Gets a value indicate if the event is empty.
Represents a process exit event.
Definition process.hpp:122
bool is_empty() const noexcept
Gets a value indicate if the event is empty.
Represents a process output data received event.
Definition process.hpp:186
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.hpp:39
Provides access to local and remote processes and enables you to start and stop local system processe...
Definition process.hpp:49
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:42
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.hpp: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.hpp:27
#define core_export_
Define shared library export.
Definition core_export.hpp:13
int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:23
intmax_t intptr
Represent a pointer or a handle.
Definition intptr.hpp:23
std::shared_ptr< type_t > sptr
The xtd::sptr object is a shared pointer.
Definition sptr.hpp:25
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
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10
Contains xtd::diagnostics::process_priority_class enum class.
Contains xtd::diagnostics::process_start_info class.