os_unix.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /**************************************************************************/
  2. /* os_unix.h */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  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. #ifdef UNIX_ENABLED
  33. #include "core/os/os.h"
  34. #include "drivers/unix/ip_unix.h"
  35. class OS_Unix : public OS {
  36. protected:
  37. // UNIX only handles the core functions.
  38. // inheriting platforms under unix (eg. X11) should handle the rest
  39. virtual void initialize_core();
  40. virtual int unix_initialize_audio(int p_audio_driver);
  41. //virtual Error initialize(int p_video_driver,int p_audio_driver);
  42. virtual void finalize_core();
  43. String stdin_buf;
  44. public:
  45. OS_Unix();
  46. virtual void alert(const String &p_alert, const String &p_title = "ALERT!");
  47. virtual String get_stdin_string(bool p_block);
  48. //virtual void set_mouse_show(bool p_show);
  49. //virtual void set_mouse_grab(bool p_grab);
  50. //virtual bool is_mouse_grab_enabled() const = 0;
  51. //virtual void get_mouse_position(int &x, int &y) const;
  52. //virtual void set_window_title(const String& p_title);
  53. //virtual void set_video_mode(const VideoMode& p_video_mode);
  54. //virtual VideoMode get_video_mode() const;
  55. //virtual void get_fullscreen_mode_list(List<VideoMode> *p_list) const;
  56. virtual Error open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path = false);
  57. virtual Error close_dynamic_library(void *p_library_handle);
  58. virtual Error get_dynamic_library_symbol_handle(void *p_library_handle, const String p_name, void *&p_symbol_handle, bool p_optional = false);
  59. virtual Error set_cwd(const String &p_cwd);
  60. virtual String get_name() const;
  61. virtual Date get_date(bool utc) const;
  62. virtual Time get_time(bool utc) const;
  63. virtual TimeZoneInfo get_time_zone_info() const;
  64. virtual uint64_t get_unix_time() const;
  65. virtual uint64_t get_system_time_secs() const;
  66. virtual uint64_t get_system_time_msecs() const;
  67. virtual double get_subsecond_unix_time() const;
  68. virtual void delay_usec(uint32_t p_usec) const;
  69. virtual uint64_t get_ticks_usec() const;
  70. virtual Error execute(const String &p_path, const List<String> &p_arguments, bool p_blocking = true, ProcessID *r_child_id = nullptr, String *r_pipe = nullptr, int *r_exitcode = nullptr, bool read_stderr = false, Mutex *p_pipe_mutex = nullptr, bool p_open_console = false);
  71. virtual Error kill(const ProcessID &p_pid);
  72. virtual int get_process_id() const;
  73. virtual bool is_process_running(const ProcessID &p_pid) const;
  74. virtual bool has_environment(const String &p_var) const;
  75. virtual String get_environment(const String &p_var) const;
  76. virtual bool set_environment(const String &p_var, const String &p_value) const;
  77. virtual String get_locale() const;
  78. virtual int get_processor_count() const;
  79. virtual void debug_break();
  80. virtual void initialize_debugging();
  81. virtual String get_executable_path() const;
  82. virtual String get_user_data_dir() const;
  83. };
  84. class UnixTerminalLogger : public StdLogger {
  85. public:
  86. virtual void log_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);
  87. virtual ~UnixTerminalLogger();
  88. };
  89. #endif
  90. #endif // OS_UNIX_H