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.

189 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. */
  36. enum OperatingSystemType
  37. {
  38. UnknownOS = 0,
  39. MacOSX = 0x1000,
  40. Linux = 0x2000,
  41. Android = 0x3000,
  42. Win95 = 0x4001,
  43. Win98 = 0x4002,
  44. WinNT351 = 0x4103,
  45. WinNT40 = 0x4104,
  46. Win2000 = 0x4105,
  47. WinXP = 0x4106,
  48. WinVista = 0x4107,
  49. Windows7 = 0x4108,
  50. Windows = 0x4000, /**< To test whether any version of Windows is running,
  51. you can use the expression ((getOperatingSystemType() & Windows) != 0). */
  52. WindowsNT = 0x0100, /**< To test whether the platform is Windows NT or later (i.e. not Win95 or 98),
  53. you can use the expression ((getOperatingSystemType() & WindowsNT) != 0). */
  54. };
  55. /** Returns the type of operating system we're running on.
  56. @returns one of the values from the OperatingSystemType enum.
  57. @see getOperatingSystemName
  58. */
  59. static OperatingSystemType getOperatingSystemType();
  60. /** Returns the name of the type of operating system we're running on.
  61. @returns a string describing the OS type.
  62. @see getOperatingSystemType
  63. */
  64. static String getOperatingSystemName();
  65. /** Returns true if the OS is 64-bit, or false for a 32-bit OS.
  66. */
  67. static bool isOperatingSystem64Bit();
  68. #if JUCE_MAC || DOXYGEN
  69. /** OSX ONLY - Returns the current OS version number.
  70. E.g. if it's running on 10.4, this will be 4, 10.5 will return 5, etc.
  71. */
  72. static int getOSXMinorVersionNumber();
  73. #endif
  74. //==============================================================================
  75. /** Returns the current user's name, if available.
  76. @see getFullUserName()
  77. */
  78. static String getLogonName();
  79. /** Returns the current user's full name, if available.
  80. On some OSes, this may just return the same value as getLogonName().
  81. @see getLogonName()
  82. */
  83. static String getFullUserName();
  84. /** Returns the host-name of the computer. */
  85. static String getComputerName();
  86. /** Returns the user's language.
  87. The return value is a 2 or 3 letter language code (ISO 639-1 or ISO 639-2)
  88. */
  89. static String getUserLanguage();
  90. /** Returns the user's region.
  91. The return value is a 2 letter country code (ISO 3166-1 alpha-2).
  92. */
  93. static String getUserRegion();
  94. //==============================================================================
  95. // CPU and memory information..
  96. /** Returns the number of CPUs. */
  97. static int getNumCpus() noexcept { return getCPUFlags().numCpus; }
  98. /** Returns the approximate CPU speed.
  99. @returns the speed in megahertz, e.g. 1500, 2500, 32000 (depending on
  100. what year you're reading this...)
  101. */
  102. static int getCpuSpeedInMegaherz();
  103. /** Returns a string to indicate the CPU vendor.
  104. Might not be known on some systems.
  105. */
  106. static String getCpuVendor();
  107. /** Checks whether Intel MMX instructions are available. */
  108. static bool hasMMX() noexcept { return getCPUFlags().hasMMX; }
  109. /** Checks whether Intel SSE instructions are available. */
  110. static bool hasSSE() noexcept { return getCPUFlags().hasSSE; }
  111. /** Checks whether Intel SSE2 instructions are available. */
  112. static bool hasSSE2() noexcept { return getCPUFlags().hasSSE2; }
  113. /** Checks whether AMD 3DNOW instructions are available. */
  114. static bool has3DNow() noexcept { return getCPUFlags().has3DNow; }
  115. //==============================================================================
  116. /** Finds out how much RAM is in the machine.
  117. @returns the approximate number of megabytes of memory, or zero if
  118. something goes wrong when finding out.
  119. */
  120. static int getMemorySizeInMegabytes();
  121. /** Returns the system page-size.
  122. This is only used by programmers with beards.
  123. */
  124. static int getPageSize();
  125. private:
  126. //==============================================================================
  127. struct CPUFlags
  128. {
  129. CPUFlags();
  130. int numCpus;
  131. bool hasMMX : 1;
  132. bool hasSSE : 1;
  133. bool hasSSE2 : 1;
  134. bool has3DNow : 1;
  135. };
  136. SystemStats();
  137. static const CPUFlags& getCPUFlags();
  138. JUCE_DECLARE_NON_COPYABLE (SystemStats);
  139. };
  140. #endif // __JUCE_SYSTEMSTATS_JUCEHEADER__