The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

187 lines
6.5KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-11 by Raw Material Software Ltd.
  5. ------------------------------------------------------------------------------
  6. JUCE can be redistributed and/or modified under the terms of the GNU General
  7. Public License (Version 2), as published by the Free Software Foundation.
  8. A copy of the license is included in the JUCE distribution, or can be found
  9. online at www.gnu.org/licenses.
  10. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  13. ------------------------------------------------------------------------------
  14. To release a closed-source product which uses JUCE, commercial licenses are
  15. available: visit www.rawmaterialsoftware.com/juce for more information.
  16. ==============================================================================
  17. */
  18. #ifndef __JUCE_SYSTEMSTATS_JUCEHEADER__
  19. #define __JUCE_SYSTEMSTATS_JUCEHEADER__
  20. #include "../text/juce_StringArray.h"
  21. //==============================================================================
  22. /**
  23. Contains methods for finding out about the current hardware and OS configuration.
  24. */
  25. class JUCE_API SystemStats
  26. {
  27. public:
  28. //==============================================================================
  29. /** Returns the current version of JUCE,
  30. See also the JUCE_VERSION, JUCE_MAJOR_VERSION and JUCE_MINOR_VERSION macros.
  31. */
  32. static String getJUCEVersion();
  33. //==============================================================================
  34. /** The set of possible results of the getOperatingSystemType() method. */
  35. enum OperatingSystemType
  36. {
  37. UnknownOS = 0,
  38. Linux = 0x2000,
  39. Android = 0x3000,
  40. iOS = 0x5000,
  41. MacOSX_10_4 = 0x1004,
  42. MacOSX_10_5 = 0x1005,
  43. MacOSX_10_6 = 0x1006,
  44. MacOSX_10_7 = 0x1007,
  45. MacOSX_10_8 = 0x1008,
  46. Win2000 = 0x4105,
  47. WinXP = 0x4106,
  48. WinVista = 0x4107,
  49. Windows7 = 0x4108,
  50. Windows8 = 0x4109,
  51. Windows = 0x4000, /**< To test whether any version of Windows is running,
  52. you can use the expression ((getOperatingSystemType() & Windows) != 0). */
  53. };
  54. /** Returns the type of operating system we're running on.
  55. @returns one of the values from the OperatingSystemType enum.
  56. @see getOperatingSystemName
  57. */
  58. static OperatingSystemType getOperatingSystemType();
  59. /** Returns the name of the type of operating system we're running on.
  60. @returns a string describing the OS type.
  61. @see getOperatingSystemType
  62. */
  63. static String getOperatingSystemName();
  64. /** Returns true if the OS is 64-bit, or false for a 32-bit OS.
  65. */
  66. static bool isOperatingSystem64Bit();
  67. /** Returns an environment variable.
  68. If the named value isn't set, this will return the defaultValue string instead.
  69. */
  70. static String getEnvironmentVariable (const String& name, const String& defaultValue);
  71. //==============================================================================
  72. /** Returns the current user's name, if available.
  73. @see getFullUserName()
  74. */
  75. static String getLogonName();
  76. /** Returns the current user's full name, if available.
  77. On some OSes, this may just return the same value as getLogonName().
  78. @see getLogonName()
  79. */
  80. static String getFullUserName();
  81. /** Returns the host-name of the computer. */
  82. static String getComputerName();
  83. /** Returns the language of the user's locale.
  84. The return value is a 2 or 3 letter language code (ISO 639-1 or ISO 639-2)
  85. */
  86. static String getUserLanguage();
  87. /** Returns the region of the user's locale.
  88. The return value is a 2 letter country code (ISO 3166-1 alpha-2).
  89. */
  90. static String getUserRegion();
  91. /** Returns the user's display language.
  92. The return value is a 2 or 3 letter language code (ISO 639-1 or ISO 639-2)
  93. */
  94. static String getDisplayLanguage();
  95. //==============================================================================
  96. // CPU and memory information..
  97. /** Returns the number of CPUs. */
  98. static int getNumCpus() noexcept { return getCPUFlags().numCpus; }
  99. /** Returns the approximate CPU speed.
  100. @returns the speed in megahertz, e.g. 1500, 2500, 32000 (depending on
  101. what year you're reading this...)
  102. */
  103. static int getCpuSpeedInMegaherz();
  104. /** Returns a string to indicate the CPU vendor.
  105. Might not be known on some systems.
  106. */
  107. static String getCpuVendor();
  108. /** Checks whether Intel MMX instructions are available. */
  109. static bool hasMMX() noexcept { return getCPUFlags().hasMMX; }
  110. /** Checks whether Intel SSE instructions are available. */
  111. static bool hasSSE() noexcept { return getCPUFlags().hasSSE; }
  112. /** Checks whether Intel SSE2 instructions are available. */
  113. static bool hasSSE2() noexcept { return getCPUFlags().hasSSE2; }
  114. /** Checks whether AMD 3DNOW instructions are available. */
  115. static bool has3DNow() noexcept { return getCPUFlags().has3DNow; }
  116. //==============================================================================
  117. /** Finds out how much RAM is in the machine.
  118. @returns the approximate number of megabytes of memory, or zero if
  119. something goes wrong when finding out.
  120. */
  121. static int getMemorySizeInMegabytes();
  122. /** Returns the system page-size.
  123. This is only used by programmers with beards.
  124. */
  125. static int getPageSize();
  126. private:
  127. //==============================================================================
  128. struct CPUFlags
  129. {
  130. CPUFlags();
  131. int numCpus;
  132. bool hasMMX : 1;
  133. bool hasSSE : 1;
  134. bool hasSSE2 : 1;
  135. bool has3DNow : 1;
  136. };
  137. SystemStats();
  138. static const CPUFlags& getCPUFlags();
  139. JUCE_DECLARE_NON_COPYABLE (SystemStats);
  140. };
  141. #endif // __JUCE_SYSTEMSTATS_JUCEHEADER__