SysInfo caching for iOS
This commit is contained in:
@@ -27,7 +27,12 @@ namespace OpenVulkano
|
|||||||
|
|
||||||
size_t SystemInfo::GetSystemRam()
|
size_t SystemInfo::GetSystemRam()
|
||||||
{
|
{
|
||||||
return [NSProcessInfo processInfo].physicalMemory;
|
static size_t ram;
|
||||||
|
if (ram == 0)
|
||||||
|
{
|
||||||
|
ram = [NSProcessInfo processInfo].physicalMemory;
|
||||||
|
}
|
||||||
|
return ram;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t SystemInfo::GetSystemRamAvailable()
|
size_t SystemInfo::GetSystemRamAvailable()
|
||||||
@@ -70,12 +75,22 @@ namespace OpenVulkano
|
|||||||
|
|
||||||
std::string SystemInfo::GetHostName()
|
std::string SystemInfo::GetHostName()
|
||||||
{
|
{
|
||||||
return [[NSProcessInfo processInfo].hostName UTF8String];
|
static std::string hostName;
|
||||||
|
if (hostName.empty())
|
||||||
|
{
|
||||||
|
hostName = [[NSProcessInfo processInfo].hostName UTF8String];
|
||||||
|
}
|
||||||
|
return hostName;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string SystemInfo::GetDeviceName()
|
std::string SystemInfo::GetDeviceName()
|
||||||
{
|
{
|
||||||
return [[[UIDevice currentDevice] name] UTF8String];
|
static std::string devName;
|
||||||
|
if (devName.empty())
|
||||||
|
{
|
||||||
|
devName = [[[UIDevice currentDevice] name] UTF8String];
|
||||||
|
}
|
||||||
|
return devName;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string SystemInfo::GetDeviceVendorName()
|
std::string SystemInfo::GetDeviceVendorName()
|
||||||
@@ -98,43 +113,79 @@ namespace OpenVulkano
|
|||||||
|
|
||||||
std::string SystemInfo::GetOsName()
|
std::string SystemInfo::GetOsName()
|
||||||
{
|
{
|
||||||
return [[[UIDevice currentDevice] systemName] UTF8String];
|
static std::string osName;
|
||||||
|
if (osName.empty())
|
||||||
|
{
|
||||||
|
osName = [[[UIDevice currentDevice] systemName] UTF8String];
|
||||||
|
}
|
||||||
|
return osName;
|
||||||
}
|
}
|
||||||
|
|
||||||
OsVersion SystemInfo::GetOsVersion()
|
OsVersion SystemInfo::GetOsVersion()
|
||||||
{
|
{
|
||||||
NSOperatingSystemVersion osVersion = [NSProcessInfo processInfo].operatingSystemVersion;
|
static OsVersion osv;
|
||||||
return { static_cast<int>(osVersion.majorVersion), static_cast<int>(osVersion.minorVersion), static_cast<int>(osVersion.patchVersion), 0 };
|
if (osv.major == 0 && osv.minor == 0)
|
||||||
|
{
|
||||||
|
NSOperatingSystemVersion osVersion = [NSProcessInfo processInfo].operatingSystemVersion;
|
||||||
|
osv = { static_cast<int>(osVersion.majorVersion), static_cast<int>(osVersion.minorVersion),
|
||||||
|
static_cast<int>(osVersion.patchVersion), 0 };
|
||||||
|
}
|
||||||
|
return osv;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string SystemInfo::GetOsNameHumanReadable()
|
std::string SystemInfo::GetOsNameHumanReadable()
|
||||||
{
|
{
|
||||||
OsVersion osVersion = GetOsVersion();
|
static std::string hrName;
|
||||||
return fmt::format("{} {}.{}", GetOsName(), osVersion.major, osVersion.minor);
|
if (hrName.empty())
|
||||||
|
{
|
||||||
|
OsVersion osVersion = GetOsVersion();
|
||||||
|
hrName = fmt::format("{} {}.{}", GetOsName(), osVersion.major, osVersion.minor);
|
||||||
|
}
|
||||||
|
return hrName;
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceType SystemInfo::GetDeviceType()
|
DeviceType SystemInfo::GetDeviceType()
|
||||||
{
|
{
|
||||||
switch ([UIDevice currentDevice].userInterfaceIdiom)
|
static DeviceType devType = DeviceType::Unknown;
|
||||||
|
if (devType == DeviceType::Unknown)
|
||||||
{
|
{
|
||||||
case UIUserInterfaceIdiomPhone: return DeviceType::Phone;
|
switch ([UIDevice currentDevice].userInterfaceIdiom)
|
||||||
case UIUserInterfaceIdiomPad: return DeviceType::Tablet;
|
{
|
||||||
case UIUserInterfaceIdiomTV: return DeviceType::TV;
|
case UIUserInterfaceIdiomPhone:
|
||||||
case UIUserInterfaceIdiomMac: return DeviceType::PC;
|
devType = DeviceType::Phone;
|
||||||
case UIUserInterfaceIdiomVision: return DeviceType::VR;
|
case UIUserInterfaceIdiomPad:
|
||||||
default: break;
|
devType = DeviceType::Tablet;
|
||||||
|
case UIUserInterfaceIdiomTV:
|
||||||
|
devType = DeviceType::TV;
|
||||||
|
case UIUserInterfaceIdiomMac:
|
||||||
|
devType = DeviceType::PC;
|
||||||
|
case UIUserInterfaceIdiomVision:
|
||||||
|
devType = DeviceType::VR;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return DeviceType::Unknown;
|
return devType;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t SystemInfo::GetCpuCoreCount()
|
size_t SystemInfo::GetCpuCoreCount()
|
||||||
{
|
{
|
||||||
return [NSProcessInfo processInfo].processorCount;
|
static size_t coreCount;
|
||||||
|
if (coreCount == 0)
|
||||||
|
{
|
||||||
|
coreCount = [NSProcessInfo processInfo].processorCount;
|
||||||
|
}
|
||||||
|
return coreCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t SystemInfo::GetCpuThreadCount()
|
size_t SystemInfo::GetCpuThreadCount()
|
||||||
{
|
{
|
||||||
return [NSProcessInfo processInfo].activeProcessorCount;
|
static size_t threadCount;
|
||||||
|
if (threadCount == 0)
|
||||||
|
{
|
||||||
|
threadCount = [NSProcessInfo processInfo].activeProcessorCount;
|
||||||
|
}
|
||||||
|
return threadCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t SystemInfo::GetCpuTemperature()
|
int32_t SystemInfo::GetCpuTemperature()
|
||||||
|
|||||||
Reference in New Issue
Block a user