BsPlatformUtility.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsPlatformDefines.h"
  5. #include "BsString.h"
  6. #include "BsTypes.h"
  7. namespace bs
  8. {
  9. /** @addtogroup General
  10. * @{
  11. */
  12. struct MACAddress;
  13. /** Possible type of platform file dialogs. */
  14. enum class FileDialogType
  15. {
  16. OpenFile = 0x0,
  17. OpenFolder = 0x1,
  18. Save = 0x2,
  19. Multiselect = 0x10000,
  20. TypeMask = 0xFFFF
  21. };
  22. /** Contains information about available GPUs on the system. */
  23. struct GPUInfo
  24. {
  25. String names[5];
  26. UINT32 numGPUs;
  27. };
  28. /** Contains information about the system hardware and operating system. */
  29. struct SystemInfo
  30. {
  31. String cpuManufacturer;
  32. String cpuModel;
  33. UINT32 cpuClockSpeedMhz;
  34. UINT32 cpuNumCores;
  35. UINT32 memoryAmountMb;
  36. String osName;
  37. bool osIs64Bit;
  38. GPUInfo gpuInfo;
  39. };
  40. /** Provides access to various operating system specific utility functions. */
  41. class BS_UTILITY_EXPORT PlatformUtility
  42. {
  43. public:
  44. /**
  45. * Terminates the current process.
  46. *
  47. * @param[in] force True if the process should be forcefully terminated with no cleanup.
  48. */
  49. static void terminate(bool force = false);
  50. /**
  51. * Adds a string to the clipboard.
  52. *
  53. * @note Thread safe.
  54. */
  55. static void copyToClipboard(const WString& string);
  56. /**
  57. * Reads a string from the clipboard and returns it. If there is no string in the clipboard it returns an empty
  58. * string.
  59. *
  60. * @note
  61. * Both wide and normal strings will be read, but normal strings will be converted to a wide string before returning.
  62. * @note
  63. * Thread safe.
  64. */
  65. static WString copyFromClipboard();
  66. /**
  67. * Converts a keyboard key-code to a Unicode character.
  68. *
  69. * @note
  70. * Normally this will output a single character, but it can happen it outputs multiple in case a accent/diacritic
  71. * character could not be combined with the virtual key into a single character.
  72. */
  73. static WString keyCodeToUnicode(UINT32 keyCode);
  74. /**
  75. * Populates the provided buffer with a MAC address of the first available adapter, if one exists. If no adapters
  76. * exist, returns false.
  77. */
  78. static bool getMACAddress(MACAddress& address);
  79. /** Returns information about the underlying hardware. */
  80. static SystemInfo getSystemInfo();
  81. /** Creates a new universally unique identifier and returns it as a string. */
  82. static String generateUUID();
  83. /**
  84. * Opens the provided file or folder using the default application for that file type, as specified by the operating
  85. * system.
  86. *
  87. * @param[in] path Absolute path to the file or folder to open.
  88. */
  89. static void open(const Path& path);
  90. /** @name Internal
  91. * @{
  92. */
  93. /**
  94. * Assigns information about GPU hardware. This data will be returned by getSystemInfo() when requested. This is
  95. * expeced to be called by the render API backend when initialized.
  96. */
  97. static void _setGPUInfo(GPUInfo gpuInfo) { sGPUInfo = gpuInfo; }
  98. /** @} */
  99. private:
  100. static GPUInfo sGPUInfo;
  101. };
  102. /** Represents a MAC (ethernet) address. */
  103. struct MACAddress
  104. {
  105. UINT8 value[6];
  106. };
  107. /** @} */
  108. }