1 /*************************************************************************/
2 /*  os_unix.h                                                            */
3 /*************************************************************************/
4 /*                       This file is part of:                           */
5 /*                           GODOT ENGINE                                */
6 /*                      https://godotengine.org                          */
7 /*************************************************************************/
8 /* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur.                 */
9 /* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md)    */
10 /*                                                                       */
11 /* Permission is hereby granted, free of charge, to any person obtaining */
12 /* a copy of this software and associated documentation files (the       */
13 /* "Software"), to deal in the Software without restriction, including   */
14 /* without limitation the rights to use, copy, modify, merge, publish,   */
15 /* distribute, sublicense, and/or sell copies of the Software, and to    */
16 /* permit persons to whom the Software is furnished to do so, subject to */
17 /* the following conditions:                                             */
18 /*                                                                       */
19 /* The above copyright notice and this permission notice shall be        */
20 /* included in all copies or substantial portions of the Software.       */
21 /*                                                                       */
22 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       */
23 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    */
24 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
25 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY  */
26 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,  */
27 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE     */
28 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */
29 /*************************************************************************/
30 #ifndef OS_UNIX_H
31 #define OS_UNIX_H
32 
33 /**
34 	@author Juan Linietsky <reduzio@gmail.com>
35 */
36 
37 #ifdef UNIX_ENABLED
38 
39 #include "drivers/unix/ip_unix.h"
40 #include "os/os.h"
41 
42 class OS_Unix : public OS {
43 
44 	uint64_t ticks_start;
45 
46 protected:
47 	// UNIX only handles the core functions.
48 	// inheriting platforms under unix (eg. X11) should handle the rest
49 
50 	//virtual int get_video_driver_count() const;
51 	//virtual const char * get_video_driver_name(int p_driver) const;
52 	//virtual VideoMode get_default_video_mode() const;
53 
54 	virtual int get_audio_driver_count() const;
55 	virtual const char *get_audio_driver_name(int p_driver) const;
56 
57 	virtual void initialize_core();
58 	virtual int unix_initialize_audio(int p_audio_driver);
59 	//virtual void initialize(int p_video_driver,int p_audio_driver);
60 
61 	//virtual void finalize();
62 	virtual void finalize_core();
63 
64 	String stdin_buf;
65 
66 	String get_global_settings_path() const;
67 
68 public:
69 	virtual void print_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, ErrorType p_type = ERR_ERROR);
70 
71 	virtual void print(const char *p_format, ...);
72 	virtual void vprint(const char *p_format, va_list p_list, bool p_stderr = false);
73 	virtual void alert(const String &p_alert, const String &p_title = "ALERT!");
74 	virtual String get_stdin_string(bool p_block);
75 
76 	//virtual void set_mouse_show(bool p_show);
77 	//virtual void set_mouse_grab(bool p_grab);
78 	//virtual bool is_mouse_grab_enabled() const = 0;
79 	//virtual void get_mouse_pos(int &x, int &y) const;
80 	//virtual void set_window_title(const String& p_title);
81 
82 	//virtual void set_video_mode(const VideoMode& p_video_mode);
83 	//virtual VideoMode get_video_mode() const;
84 	//virtual void get_fullscreen_mode_list(List<VideoMode> *p_list) const;
85 
86 	virtual Error set_cwd(const String &p_cwd);
87 
88 	virtual String get_name();
89 
90 	virtual Date get_date(bool utc) const;
91 	virtual Time get_time(bool utc) const;
92 	virtual TimeZoneInfo get_time_zone_info() const;
93 
94 	virtual uint64_t get_unix_time() const;
95 	virtual uint64_t get_system_time_secs() const;
96 
97 	virtual void delay_usec(uint32_t p_usec) const;
98 	virtual uint64_t get_ticks_usec() const;
99 
100 	virtual Error execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id = NULL, String *r_pipe = NULL, int *r_exitcode = NULL, bool read_stderr = false);
101 	virtual Error kill(const ProcessID &p_pid);
102 	virtual int get_process_ID() const;
103 
104 	virtual bool has_environment(const String &p_var) const;
105 	virtual String get_environment(const String &p_var) const;
106 	virtual String get_locale() const;
107 
108 	virtual int get_processor_count() const;
109 
110 	virtual void debug_break();
111 
112 	virtual String get_installed_templates_path() const;
113 	virtual String get_executable_path() const;
114 	virtual String get_data_dir() const;
115 
116 	//virtual void run( MainLoop * p_main_loop );
117 };
118 
119 #endif
120 
121 #endif
122