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