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.

179 lines
6.1KB

  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. //==============================================================================
  87. // CPU and memory information..
  88. /** Returns the approximate CPU speed.
  89. @returns the speed in megahertz, e.g. 1500, 2500, 32000 (depending on
  90. what year you're reading this...)
  91. */
  92. static int getCpuSpeedInMegaherz();
  93. /** Returns a string to indicate the CPU vendor.
  94. Might not be known on some systems.
  95. */
  96. static String getCpuVendor();
  97. /** Checks whether Intel MMX instructions are available. */
  98. static bool hasMMX() noexcept { return getCPUFlags().hasMMX; }
  99. /** Checks whether Intel SSE instructions are available. */
  100. static bool hasSSE() noexcept { return getCPUFlags().hasSSE; }
  101. /** Checks whether Intel SSE2 instructions are available. */
  102. static bool hasSSE2() noexcept { return getCPUFlags().hasSSE2; }
  103. /** Checks whether AMD 3DNOW instructions are available. */
  104. static bool has3DNow() noexcept { return getCPUFlags().has3DNow; }
  105. /** Returns the number of CPUs. */
  106. static int getNumCpus() noexcept { return getCPUFlags().numCpus; }
  107. //==============================================================================
  108. /** Finds out how much RAM is in the machine.
  109. @returns the approximate number of megabytes of memory, or zero if
  110. something goes wrong when finding out.
  111. */
  112. static int getMemorySizeInMegabytes();
  113. /** Returns the system page-size.
  114. This is only used by programmers with beards.
  115. */
  116. static int getPageSize();
  117. private:
  118. //==============================================================================
  119. struct CPUFlags
  120. {
  121. CPUFlags();
  122. int numCpus;
  123. bool hasMMX : 1;
  124. bool hasSSE : 1;
  125. bool hasSSE2 : 1;
  126. bool has3DNow : 1;
  127. };
  128. SystemStats();
  129. static const CPUFlags& getCPUFlags();
  130. JUCE_DECLARE_NON_COPYABLE (SystemStats);
  131. };
  132. #endif // __JUCE_SYSTEMSTATS_JUCEHEADER__