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.

194 lines
6.7KB

  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. /** Returns an environment variable.
  75. If the named value isn't set, this will return the defaultValue string instead.
  76. */
  77. static String getEnvironmentVariable (const String& name, const String& defaultValue);
  78. //==============================================================================
  79. /** Returns the current user's name, if available.
  80. @see getFullUserName()
  81. */
  82. static String getLogonName();
  83. /** Returns the current user's full name, if available.
  84. On some OSes, this may just return the same value as getLogonName().
  85. @see getLogonName()
  86. */
  87. static String getFullUserName();
  88. /** Returns the host-name of the computer. */
  89. static String getComputerName();
  90. /** Returns the user's language.
  91. The return value is a 2 or 3 letter language code (ISO 639-1 or ISO 639-2)
  92. */
  93. static String getUserLanguage();
  94. /** Returns the user's region.
  95. The return value is a 2 letter country code (ISO 3166-1 alpha-2).
  96. */
  97. static String getUserRegion();
  98. //==============================================================================
  99. // CPU and memory information..
  100. /** Returns the number of CPUs. */
  101. static int getNumCpus() noexcept { return getCPUFlags().numCpus; }
  102. /** Returns the approximate CPU speed.
  103. @returns the speed in megahertz, e.g. 1500, 2500, 32000 (depending on
  104. what year you're reading this...)
  105. */
  106. static int getCpuSpeedInMegaherz();
  107. /** Returns a string to indicate the CPU vendor.
  108. Might not be known on some systems.
  109. */
  110. static String getCpuVendor();
  111. /** Checks whether Intel MMX instructions are available. */
  112. static bool hasMMX() noexcept { return getCPUFlags().hasMMX; }
  113. /** Checks whether Intel SSE instructions are available. */
  114. static bool hasSSE() noexcept { return getCPUFlags().hasSSE; }
  115. /** Checks whether Intel SSE2 instructions are available. */
  116. static bool hasSSE2() noexcept { return getCPUFlags().hasSSE2; }
  117. /** Checks whether AMD 3DNOW instructions are available. */
  118. static bool has3DNow() noexcept { return getCPUFlags().has3DNow; }
  119. //==============================================================================
  120. /** Finds out how much RAM is in the machine.
  121. @returns the approximate number of megabytes of memory, or zero if
  122. something goes wrong when finding out.
  123. */
  124. static int getMemorySizeInMegabytes();
  125. /** Returns the system page-size.
  126. This is only used by programmers with beards.
  127. */
  128. static int getPageSize();
  129. private:
  130. //==============================================================================
  131. struct CPUFlags
  132. {
  133. CPUFlags();
  134. int numCpus;
  135. bool hasMMX : 1;
  136. bool hasSSE : 1;
  137. bool hasSSE2 : 1;
  138. bool has3DNow : 1;
  139. };
  140. SystemStats();
  141. static const CPUFlags& getCPUFlags();
  142. JUCE_DECLARE_NON_COPYABLE (SystemStats);
  143. };
  144. #endif // __JUCE_SYSTEMSTATS_JUCEHEADER__