yum-mirror/VkFFT
git clone https://git.yummers.dev/yum-mirror/VkFFT
ba7001c
develop
1//------------------------------------------------------------------------------------------------------------------------------------------------------------- 2// 3// Foundation/NSProcessInfo.hpp 4// 5// Copyright 2020-2021 Apple Inc. 6// 7// Licensed under the Apache License, Version 2.0 (the "License"); 8// you may not use this file except in compliance with the License. 9// You may obtain a copy of the License at 10// 11// http://www.apache.org/licenses/LICENSE-2.0 12// 13// Unless required by applicable law or agreed to in writing, software 14// distributed under the License is distributed on an "AS IS" BASIS, 15// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16// See the License for the specific language governing permissions and 17// limitations under the License. 18// 19//------------------------------------------------------------------------------------------------------------------------------------------------------------- 20 21#pragma once 22 23//------------------------------------------------------------------------------------------------------------------------------------------------------------- 24 25#include "NSDefines.hpp" 26#include "NSNotification.hpp" 27#include "NSObject.hpp" 28#include "NSPrivate.hpp" 29#include "NSTypes.hpp" 30 31#include <functional> 32 33//------------------------------------------------------------------------------------------------------------------------------------------------------------- 34 35namespace NS 36{ 37_NS_CONST (NotificationName ,ProcessInfoThermalStateDidChangeNotification ); 38_NS_CONST (NotificationName ,ProcessInfoPowerStateDidChangeNotification ); 39 40_NS_ENUM (NS ::Integer ,ProcessInfoThermalState ) { 41ProcessInfoThermalStateNominal = 0 , 42ProcessInfoThermalStateFair = 1 , 43ProcessInfoThermalStateSerious = 2 , 44ProcessInfoThermalStateCritical = 3 45}; 46 47_NS_OPTIONS (std::uint64_t ,ActivityOptions ) { 48ActivityIdleDisplaySleepDisabled = (1ULL <<40 ), 49ActivityIdleSystemSleepDisabled = (1ULL <<20 ), 50ActivitySuddenTerminationDisabled = (1ULL <<14 ), 51ActivityAutomaticTerminationDisabled = (1ULL <<15 ), 52ActivityUserInitiated = (0x00FFFFFFULL |ActivityIdleSystemSleepDisabled ), 53ActivityUserInitiatedAllowingIdleSystemSleep = (ActivityUserInitiated & ~ActivityIdleSystemSleepDisabled ), 54ActivityBackground = 0x000000FFULL , 55ActivityLatencyCritical = 0xFF00000000ULL , 56}; 57 58class ProcessInfo :public Referencing < ProcessInfo > 59{ 60public : 61static ProcessInfo * processInfo (); 62 63class Array * arguments ()const ; 64class Dictionary * environment ()const ; 65class String * hostName ()const ; 66class String * processName ()const ; 67void setProcessName (const String * pString ); 68int processIdentifier ()const ; 69class String * globallyUniqueString ()const ; 70 71class String * userName ()const ; 72class String * fullUserName ()const ; 73 74UInteger operatingSystem ()const ; 75OperatingSystemVersion operatingSystemVersion ()const ; 76class String * operatingSystemVersionString ()const ; 77bool isOperatingSystemAtLeastVersion (OperatingSystemVersion version )const ; 78 79UInteger processorCount ()const ; 80UInteger activeProcessorCount ()const ; 81unsigned long long physicalMemory ()const ; 82TimeInterval systemUptime ()const ; 83 84void disableSuddenTermination (); 85void enableSuddenTermination (); 86 87void disableAutomaticTermination (const class String * pReason ); 88void enableAutomaticTermination (const class String * pReason ); 89bool automaticTerminationSupportEnabled ()const ; 90void setAutomaticTerminationSupportEnabled (bool enabled ); 91 92class Object * beginActivity (ActivityOptions options ,const class String * pReason ); 93void endActivity (class Object * pActivity ); 94void performActivity (ActivityOptions options ,const class String * pReason ,void (^block )(void )); 95void performActivity (ActivityOptions options ,const class String * pReason ,const std::function < void ()>& func ); 96void performExpiringActivity (const class String * pReason ,void (^block )(bool expired )); 97void performExpiringActivity (const class String * pReason ,const std::function < void (bool expired )>& func ); 98 99ProcessInfoThermalState thermalState ()const ; 100bool isLowPowerModeEnabled ()const ; 101 102bool isiOSAppOnMac ()const ; 103bool isMacCatalystApp ()const ; 104}; 105} 106 107//------------------------------------------------------------------------------------------------------------------------------------------------------------- 108 109_NS_PRIVATE_DEF_CONST (NS ::NotificationName ,ProcessInfoThermalStateDidChangeNotification ); 110_NS_PRIVATE_DEF_CONST (NS ::NotificationName ,ProcessInfoPowerStateDidChangeNotification ); 111 112//------------------------------------------------------------------------------------------------------------------------------------------------------------- 113 114_NS_INLINE NS ::ProcessInfo * NS ::ProcessInfo ::processInfo () 115{ 116return Object ::sendMessage < ProcessInfo *> (_NS_PRIVATE_CLS (NSProcessInfo ),_NS_PRIVATE_SEL (processInfo )); 117} 118 119//------------------------------------------------------------------------------------------------------------------------------------------------------------- 120 121_NS_INLINE NS ::Array * NS ::ProcessInfo ::arguments ()const 122{ 123return Object ::sendMessage < Array *> (this ,_NS_PRIVATE_SEL (arguments )); 124} 125 126//------------------------------------------------------------------------------------------------------------------------------------------------------------- 127 128_NS_INLINE NS ::Dictionary * NS ::ProcessInfo ::environment ()const 129{ 130return Object ::sendMessage < Dictionary *> (this ,_NS_PRIVATE_SEL (environment )); 131} 132 133//------------------------------------------------------------------------------------------------------------------------------------------------------------- 134 135_NS_INLINE NS ::String * NS ::ProcessInfo ::hostName ()const 136{ 137return Object ::sendMessage < String *> (this ,_NS_PRIVATE_SEL (hostName )); 138} 139 140//------------------------------------------------------------------------------------------------------------------------------------------------------------- 141 142_NS_INLINE NS ::String * NS ::ProcessInfo ::processName ()const 143{ 144return Object ::sendMessage < String *> (this ,_NS_PRIVATE_SEL (processName )); 145} 146 147//------------------------------------------------------------------------------------------------------------------------------------------------------------- 148 149_NS_INLINE voidNS ::ProcessInfo ::setProcessName (const String * pString ) 150{ 151Object ::sendMessage < void > (this ,_NS_PRIVATE_SEL (setProcessName_ ),pString ); 152} 153 154//------------------------------------------------------------------------------------------------------------------------------------------------------------- 155 156_NS_INLINE intNS ::ProcessInfo ::processIdentifier ()const 157{ 158return Object ::sendMessage < int > (this ,_NS_PRIVATE_SEL (processIdentifier )); 159} 160 161//------------------------------------------------------------------------------------------------------------------------------------------------------------- 162 163_NS_INLINE NS ::String * NS ::ProcessInfo ::globallyUniqueString ()const 164{ 165return Object ::sendMessage < String *> (this ,_NS_PRIVATE_SEL (globallyUniqueString )); 166} 167 168//------------------------------------------------------------------------------------------------------------------------------------------------------------- 169 170_NS_INLINE NS ::String * NS ::ProcessInfo ::userName ()const 171{ 172return Object ::sendMessageSafe < String *> (this ,_NS_PRIVATE_SEL (userName )); 173} 174 175//------------------------------------------------------------------------------------------------------------------------------------------------------------- 176 177_NS_INLINE NS ::String * NS ::ProcessInfo ::fullUserName ()const 178{ 179return Object ::sendMessageSafe < String *> (this ,_NS_PRIVATE_SEL (fullUserName )); 180} 181 182//------------------------------------------------------------------------------------------------------------------------------------------------------------- 183 184_NS_INLINE NS ::UInteger NS ::ProcessInfo ::operatingSystem ()const 185{ 186return Object ::sendMessage < UInteger > (this ,_NS_PRIVATE_SEL (operatingSystem )); 187} 188 189//------------------------------------------------------------------------------------------------------------------------------------------------------------- 190 191_NS_INLINE NS ::OperatingSystemVersion NS ::ProcessInfo ::operatingSystemVersion ()const 192{ 193return Object ::sendMessage < OperatingSystemVersion > (this ,_NS_PRIVATE_SEL (operatingSystemVersion )); 194} 195 196//------------------------------------------------------------------------------------------------------------------------------------------------------------- 197 198_NS_INLINE NS ::String * NS ::ProcessInfo ::operatingSystemVersionString ()const 199{ 200return Object ::sendMessage < String *> (this ,_NS_PRIVATE_SEL (operatingSystemVersionString )); 201} 202 203//------------------------------------------------------------------------------------------------------------------------------------------------------------- 204 205_NS_INLINE boolNS ::ProcessInfo ::isOperatingSystemAtLeastVersion (OperatingSystemVersion version )const 206{ 207return Object ::sendMessage < bool > (this ,_NS_PRIVATE_SEL (isOperatingSystemAtLeastVersion_ ),version ); 208} 209 210//------------------------------------------------------------------------------------------------------------------------------------------------------------- 211 212_NS_INLINE NS ::UInteger NS ::ProcessInfo ::processorCount ()const 213{ 214return Object ::sendMessage < UInteger > (this ,_NS_PRIVATE_SEL (processorCount )); 215} 216 217//------------------------------------------------------------------------------------------------------------------------------------------------------------- 218 219_NS_INLINE NS ::UInteger NS ::ProcessInfo ::activeProcessorCount ()const 220{ 221return Object ::sendMessage < UInteger > (this ,_NS_PRIVATE_SEL (activeProcessorCount )); 222} 223 224//------------------------------------------------------------------------------------------------------------------------------------------------------------- 225 226_NS_INLINE unsigned long long NS ::ProcessInfo ::physicalMemory ()const 227{ 228return Object ::sendMessage < unsigned long long > (this ,_NS_PRIVATE_SEL (physicalMemory )); 229} 230 231//------------------------------------------------------------------------------------------------------------------------------------------------------------- 232 233_NS_INLINE NS ::TimeInterval NS ::ProcessInfo ::systemUptime ()const 234{ 235return Object ::sendMessage < TimeInterval > (this ,_NS_PRIVATE_SEL (systemUptime )); 236} 237 238//------------------------------------------------------------------------------------------------------------------------------------------------------------- 239 240_NS_INLINE voidNS ::ProcessInfo ::disableSuddenTermination () 241{ 242Object ::sendMessageSafe < void > (this ,_NS_PRIVATE_SEL (disableSuddenTermination )); 243} 244 245//------------------------------------------------------------------------------------------------------------------------------------------------------------- 246 247_NS_INLINE voidNS ::ProcessInfo ::enableSuddenTermination () 248{ 249Object ::sendMessageSafe < void > (this ,_NS_PRIVATE_SEL (enableSuddenTermination )); 250} 251 252//------------------------------------------------------------------------------------------------------------------------------------------------------------- 253 254_NS_INLINE voidNS ::ProcessInfo ::disableAutomaticTermination (const String * pReason ) 255{ 256Object ::sendMessageSafe < void > (this ,_NS_PRIVATE_SEL (disableAutomaticTermination_ ),pReason ); 257} 258 259//------------------------------------------------------------------------------------------------------------------------------------------------------------- 260 261_NS_INLINE voidNS ::ProcessInfo ::enableAutomaticTermination (const String * pReason ) 262{ 263Object ::sendMessageSafe < void > (this ,_NS_PRIVATE_SEL (enableAutomaticTermination_ ),pReason ); 264} 265 266//------------------------------------------------------------------------------------------------------------------------------------------------------------- 267 268_NS_INLINE boolNS ::ProcessInfo ::automaticTerminationSupportEnabled ()const 269{ 270return Object ::sendMessageSafe < bool > (this ,_NS_PRIVATE_SEL (automaticTerminationSupportEnabled )); 271} 272 273//------------------------------------------------------------------------------------------------------------------------------------------------------------- 274 275_NS_INLINE voidNS ::ProcessInfo ::setAutomaticTerminationSupportEnabled (bool enabled ) 276{ 277Object ::sendMessageSafe < void > (this ,_NS_PRIVATE_SEL (setAutomaticTerminationSupportEnabled_ ),enabled ); 278} 279 280//------------------------------------------------------------------------------------------------------------------------------------------------------------- 281 282_NS_INLINE NS ::Object * NS ::ProcessInfo ::beginActivity (ActivityOptions options ,const String * pReason ) 283{ 284return Object ::sendMessage < Object *> (this ,_NS_PRIVATE_SEL (beginActivityWithOptions_reason_ ),options ,pReason ); 285} 286 287//------------------------------------------------------------------------------------------------------------------------------------------------------------- 288 289_NS_INLINE voidNS ::ProcessInfo ::endActivity (Object * pActivity ) 290{ 291Object ::sendMessage < void > (this ,_NS_PRIVATE_SEL (endActivity_ ),pActivity ); 292} 293 294//------------------------------------------------------------------------------------------------------------------------------------------------------------- 295 296_NS_INLINE voidNS ::ProcessInfo ::performActivity (ActivityOptions options ,const String * pReason ,void (^block )(void )) 297{ 298Object ::sendMessage < void > (this ,_NS_PRIVATE_SEL (performActivityWithOptions_reason_usingBlock_ ),options ,pReason ,block ); 299} 300 301//------------------------------------------------------------------------------------------------------------------------------------------------------------- 302 303_NS_INLINE voidNS ::ProcessInfo ::performActivity (ActivityOptions options ,const String * pReason ,const std::function < void ()>& function ) 304{ 305__block std::function < void ()> blockFunction = function ; 306 307performActivity (options ,pReason ,^() { blockFunction (); }); 308} 309 310//------------------------------------------------------------------------------------------------------------------------------------------------------------- 311 312_NS_INLINE void NS :: ProcessInfo ::performExpiringActivity( const String * pReason, void (^ block )( bool expired)) 313{ 314Object :: sendMessageSafe < void > (this, _NS_PRIVATE_SEL (performExpiringActivityWithReason_usingBlock_), pReason, block); 315} 316 317//------------------------------------------------------------------------------------------------------------------------------------------------------------- 318 319_NS_INLINE void NS :: ProcessInfo ::performExpiringActivity( const String * pReason, const std:: function < void ( bool expired) >& function) 320{ 321__block std:: function < void ( bool expired) > blockFunction = function; 322 323performExpiringActivity (pReason, ^( bool expired ) { blockFunction (expired); }); 324} 325 326//------------------------------------------------------------------------------------------------------------------------------------------------------------- 327 328_NS_INLINE NS :: ProcessInfoThermalState NS :: ProcessInfo ::thermalState() const 329{ 330return Object :: sendMessage < ProcessInfoThermalState > (this, _NS_PRIVATE_SEL (thermalState)); 331} 332 333//------------------------------------------------------------------------------------------------------------------------------------------------------------- 334 335_NS_INLINE bool NS :: ProcessInfo ::isLowPowerModeEnabled() const 336{ 337return Object :: sendMessageSafe < bool > (this, _NS_PRIVATE_SEL (isLowPowerModeEnabled)); 338} 339 340//------------------------------------------------------------------------------------------------------------------------------------------------------------- 341 342_NS_INLINE bool NS :: ProcessInfo ::isiOSAppOnMac() const 343{ 344return Object :: sendMessageSafe < bool > (this, _NS_PRIVATE_SEL (isiOSAppOnMac)); 345} 346 347//------------------------------------------------------------------------------------------------------------------------------------------------------------- 348 349_NS_INLINE bool NS :: ProcessInfo ::isMacCatalystApp() const 350{ 351return Object :: sendMessageSafe < bool > (this, _NS_PRIVATE_SEL (isMacCatalystApp)); 352} 353 354//-------------------------------------------------------------------------------------------------------------------------------------------------------------