SystemInformation.hxx.in 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /*============================================================================
  2. KWSys - Kitware System Library
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #ifndef @KWSYS_NAMESPACE@_SystemInformation_h
  11. #define @KWSYS_NAMESPACE@_SystemInformation_h
  12. /* Define these macros temporarily to keep the code readable. */
  13. #if !defined (KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
  14. # define kwsys_stl @KWSYS_NAMESPACE@_stl
  15. # define kwsys_ios @KWSYS_NAMESPACE@_ios
  16. #endif
  17. #include <@KWSYS_NAMESPACE@/stl/string>
  18. #include <stddef.h> /* size_t */
  19. namespace @KWSYS_NAMESPACE@
  20. {
  21. // forward declare the implementation class
  22. class SystemInformationImplementation;
  23. class @KWSYS_NAMESPACE@_EXPORT SystemInformation
  24. {
  25. #if @KWSYS_USE_LONG_LONG@
  26. typedef long long LongLong;
  27. #elif @KWSYS_USE___INT64@
  28. typedef __int64 LongLong;
  29. #else
  30. # error "No Long Long"
  31. #endif
  32. friend class SystemInformationImplementation;
  33. SystemInformationImplementation* Implementation;
  34. public:
  35. SystemInformation ();
  36. ~SystemInformation ();
  37. const char * GetVendorString();
  38. const char * GetVendorID();
  39. kwsys_stl::string GetTypeID();
  40. kwsys_stl::string GetFamilyID();
  41. kwsys_stl::string GetModelID();
  42. kwsys_stl::string GetModelName();
  43. kwsys_stl::string GetSteppingCode();
  44. const char * GetExtendedProcessorName();
  45. const char * GetProcessorSerialNumber();
  46. int GetProcessorCacheSize();
  47. unsigned int GetLogicalProcessorsPerPhysical();
  48. float GetProcessorClockFrequency();
  49. int GetProcessorAPICID();
  50. int GetProcessorCacheXSize(long int);
  51. bool DoesCPUSupportFeature(long int);
  52. // returns an informative general description of the cpu
  53. // on this system.
  54. kwsys_stl::string GetCPUDescription();
  55. const char * GetHostname();
  56. kwsys_stl::string GetFullyQualifiedDomainName();
  57. const char * GetOSName();
  58. const char * GetOSRelease();
  59. const char * GetOSVersion();
  60. const char * GetOSPlatform();
  61. int GetOSIsWindows();
  62. int GetOSIsLinux();
  63. int GetOSIsApple();
  64. // returns an informative general description of the os
  65. // on this system.
  66. kwsys_stl::string GetOSDescription();
  67. bool Is64Bits();
  68. unsigned int GetNumberOfLogicalCPU(); // per physical cpu
  69. unsigned int GetNumberOfPhysicalCPU();
  70. bool DoesCPUSupportCPUID();
  71. // Retrieve id of the current running process
  72. LongLong GetProcessId();
  73. // Retrieve memory information in megabyte.
  74. size_t GetTotalVirtualMemory();
  75. size_t GetAvailableVirtualMemory();
  76. size_t GetTotalPhysicalMemory();
  77. size_t GetAvailablePhysicalMemory();
  78. // returns an informative general description if the installed and
  79. // available ram on this system. See the GetHostMmeoryTotal, and
  80. // Get{Host,Proc}MemoryAvailable methods for more information.
  81. kwsys_stl::string GetMemoryDescription(
  82. const char *hostLimitEnvVarName=NULL,
  83. const char *procLimitEnvVarName=NULL);
  84. // Retrieve amount of physical memory installed on the system in KiB
  85. // units.
  86. LongLong GetHostMemoryTotal();
  87. // Get total system RAM in units of KiB available colectivley to all
  88. // processes in a process group. An example of a process group
  89. // are the processes comprising an mpi program which is running in
  90. // parallel. The amount of memory reported may differ from the host
  91. // total if a host wide resource limit is applied. Such reource limits
  92. // are reported to us via an applicaiton specified environment variable.
  93. LongLong GetHostMemoryAvailable(const char *hostLimitEnvVarName=NULL);
  94. // Get total system RAM in units of KiB available to this process.
  95. // This may differ from the host available if a per-process resource
  96. // limit is applied. per-process memory limits are applied on unix
  97. // system via rlimit api. Resource limits that are not imposed via
  98. // rlimit api may be reported to us via an application specified
  99. // environment variable.
  100. LongLong GetProcMemoryAvailable(
  101. const char *hostLimitEnvVarName=NULL,
  102. const char *procLimitEnvVarName=NULL);
  103. // Get the system RAM used by all processes on the host, in units of KiB.
  104. LongLong GetHostMemoryUsed();
  105. // Get system RAM used by this process id in units of KiB.
  106. LongLong GetProcMemoryUsed();
  107. // enable/disable stack trace signal handler. In order to
  108. // produce an informative stack trace the application should
  109. // be dynamically linked and compiled with debug symbols.
  110. static
  111. void SetStackTraceOnError(int enable);
  112. /** Run the different checks */
  113. void RunCPUCheck();
  114. void RunOSCheck();
  115. void RunMemoryCheck();
  116. };
  117. } // namespace @KWSYS_NAMESPACE@
  118. /* Undefine temporary macros. */
  119. #if !defined (KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
  120. # undef kwsys_stl
  121. # undef kwsys_ios
  122. #endif
  123. #endif