SystemInformation.hxx.in 4.57 KB
Newer Older
1 2
/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
   file Copyright.txt or https://cmake.org/licensing#kwsys for details.  */
3 4 5
#ifndef @KWSYS_NAMESPACE@_SystemInformation_h
#define @KWSYS_NAMESPACE@_SystemInformation_h

Brad King's avatar
Brad King committed
6
#include <@KWSYS_NAMESPACE@/Configure.hxx>
7

8
#include <stddef.h> /* size_t */
Brad King's avatar
Brad King committed
9
#include <string>
10

11
namespace @KWSYS_NAMESPACE@ {
12

13
// forward declare the implementation class
14
class SystemInformationImplementation;
15 16

class @KWSYS_NAMESPACE@_EXPORT SystemInformation
17
{
18 19 20 21 22
#if @KWSYS_USE_LONG_LONG@
  typedef long long LongLong;
#elif @KWSYS_USE___INT64@
  typedef __int64 LongLong;
#else
23
#error "No Long Long"
24 25 26 27
#endif
  friend class SystemInformationImplementation;
  SystemInformationImplementation* Implementation;

28 29 30
public:
  SystemInformation();
  ~SystemInformation();
31

32 33
  const char* GetVendorString();
  const char* GetVendorID();
Brad King's avatar
Brad King committed
34 35 36 37 38
  std::string GetTypeID();
  std::string GetFamilyID();
  std::string GetModelID();
  std::string GetModelName();
  std::string GetSteppingCode();
39 40
  const char* GetExtendedProcessorName();
  const char* GetProcessorSerialNumber();
41
  int GetProcessorCacheSize();
42
  unsigned int GetLogicalProcessorsPerPhysical();
43 44 45 46
  float GetProcessorClockFrequency();
  int GetProcessorAPICID();
  int GetProcessorCacheXSize(long int);
  bool DoesCPUSupportFeature(long int);
47 48 49

  // returns an informative general description of the cpu
  // on this system.
Brad King's avatar
Brad King committed
50
  std::string GetCPUDescription();
51

52
  const char* GetHostname();
Brad King's avatar
Brad King committed
53
  std::string GetFullyQualifiedDomainName();
54

55 56 57 58
  const char* GetOSName();
  const char* GetOSRelease();
  const char* GetOSVersion();
  const char* GetOSPlatform();
59

60 61 62 63 64 65
  int GetOSIsWindows();
  int GetOSIsLinux();
  int GetOSIsApple();

  // returns an informative general description of the os
  // on this system.
Brad King's avatar
Brad King committed
66
  std::string GetOSDescription();
67

68 69
  bool Is64Bits();

70
  unsigned int GetNumberOfLogicalCPU();
71 72 73 74
  unsigned int GetNumberOfPhysicalCPU();

  bool DoesCPUSupportCPUID();

75
  // Retrieve id of the current running process
76
  LongLong GetProcessId();
77

78
  // Retrieve memory information in megabyte.
79 80 81
  size_t GetTotalVirtualMemory();
  size_t GetAvailableVirtualMemory();
  size_t GetTotalPhysicalMemory();
82 83
  size_t GetAvailablePhysicalMemory();

84 85 86
  // returns an informative general description if the installed and
  // available ram on this system. See the  GetHostMmeoryTotal, and
  // Get{Host,Proc}MemoryAvailable methods for more information.
87 88
  std::string GetMemoryDescription(const char* hostLimitEnvVarName = NULL,
                                   const char* procLimitEnvVarName = NULL);
89 90 91 92 93 94 95 96 97 98 99

  // Retrieve amount of physical memory installed on the system in KiB
  // units.
  LongLong GetHostMemoryTotal();

  // Get total system RAM in units of KiB available colectivley to all
  // processes in a process group. An example of a process group
  // are the processes comprising an mpi program which is running in
  // parallel. The amount of memory reported may differ from the host
  // total if a host wide resource limit is applied. Such reource limits
  // are reported to us via an applicaiton specified environment variable.
100
  LongLong GetHostMemoryAvailable(const char* hostLimitEnvVarName = NULL);
101 102 103 104

  // Get total system RAM in units of KiB available to this process.
  // This may differ from the host available if a per-process resource
  // limit is applied. per-process memory limits are applied on unix
105 106
  // system via rlimit API. Resource limits that are not imposed via
  // rlimit API may be reported to us via an application specified
107
  // environment variable.
108 109
  LongLong GetProcMemoryAvailable(const char* hostLimitEnvVarName = NULL,
                                  const char* procLimitEnvVarName = NULL);
110 111 112 113 114 115 116

  // Get the system RAM used by all processes on the host, in units of KiB.
  LongLong GetHostMemoryUsed();

  // Get system RAM used by this process id in units of KiB.
  LongLong GetProcMemoryUsed();

117 118 119 120
  // Return the load average of the machine or -0.0 if it cannot
  // be determined.
  double GetLoadAverage();

121 122 123
  // enable/disable stack trace signal handler. In order to
  // produce an informative stack trace the application should
  // be dynamically linked and compiled with debug symbols.
124
  static void SetStackTraceOnError(int enable);
125

126 127 128
  // format and return the current program stack in a string. In
  // order to produce an informative stack trace the application
  // should be dynamically linked and compiled with debug symbols.
129
  static std::string GetProgramStack(int firstFrame, int wholePath);
130

131 132 133 134 135
  /** Run the different checks */
  void RunCPUCheck();
  void RunOSCheck();
  void RunMemoryCheck();
};
136

137
} // namespace @KWSYS_NAMESPACE@
138

139
#endif