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.

182 lines
6.3KB

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