yum-mirror/VkFFT

git clone https://git.yummers.dev/yum-mirror/VkFFT

Tolmachev DmitriiMetal support in VkFFTba7001c

develop
16.3 KiB354 linesraw
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) {
41    ProcessInfoThermalStateNominal = 0,
42    ProcessInfoThermalStateFair = 1,
43    ProcessInfoThermalStateSerious = 2,
44    ProcessInfoThermalStateCritical = 3
45};
46
47_NS_OPTIONS(std::uint64_t, ActivityOptions) {
48    ActivityIdleDisplaySleepDisabled = (1ULL << 40),
49    ActivityIdleSystemSleepDisabled = (1ULL << 20),
50    ActivitySuddenTerminationDisabled = (1ULL << 14),
51    ActivityAutomaticTerminationDisabled = (1ULL << 15),
52    ActivityUserInitiated = (0x00FFFFFFULL | ActivityIdleSystemSleepDisabled),
53    ActivityUserInitiatedAllowingIdleSystemSleep = (ActivityUserInitiated & ~ActivityIdleSystemSleepDisabled),
54    ActivityBackground = 0x000000FFULL,
55    ActivityLatencyCritical = 0xFF00000000ULL,
56};
57
58class ProcessInfo : public Referencing<ProcessInfo>
59{
60public:
61    static ProcessInfo*     processInfo();
62
63    class Array*            arguments() const;
64    class Dictionary*       environment() const;
65    class String*           hostName() const;
66    class String*           processName() const;
67    void                    setProcessName(const String* pString);
68    int                     processIdentifier() const;
69    class String*           globallyUniqueString() const;
70
71    class String*           userName() const;
72    class String*           fullUserName() const;
73
74    UInteger                operatingSystem() const;
75    OperatingSystemVersion  operatingSystemVersion() const;
76    class String*           operatingSystemVersionString() const;
77    bool                    isOperatingSystemAtLeastVersion(OperatingSystemVersion version) const;
78
79    UInteger                processorCount() const;
80    UInteger                activeProcessorCount() const;
81    unsigned long long      physicalMemory() const;
82    TimeInterval            systemUptime() const;
83
84    void                    disableSuddenTermination();
85    void                    enableSuddenTermination();
86
87    void                    disableAutomaticTermination(const class String* pReason);
88    void                    enableAutomaticTermination(const class String* pReason);
89    bool                    automaticTerminationSupportEnabled() const;
90    void                    setAutomaticTerminationSupportEnabled(bool enabled);
91
92    class Object*           beginActivity(ActivityOptions options, const class String* pReason);
93    void                    endActivity(class Object* pActivity);
94    void                    performActivity(ActivityOptions options, const class String* pReason, void (^block)(void));
95    void                    performActivity(ActivityOptions options, const class String* pReason, const std::function<void()>& func);
96    void                    performExpiringActivity(const class String* pReason, void (^block)(bool expired));
97    void                    performExpiringActivity(const class String* pReason, const std::function<void(bool expired)>& func);
98
99    ProcessInfoThermalState thermalState() const;
100    bool                    isLowPowerModeEnabled() const;
101
102    bool                    isiOSAppOnMac() const;
103    bool                    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{
116    return 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{
123    return Object::sendMessage<Array*>(this, _NS_PRIVATE_SEL(arguments));
124}
125
126//-------------------------------------------------------------------------------------------------------------------------------------------------------------
127
128_NS_INLINE NS::Dictionary* NS::ProcessInfo::environment() const
129{
130    return Object::sendMessage<Dictionary*>(this, _NS_PRIVATE_SEL(environment));
131}
132
133//-------------------------------------------------------------------------------------------------------------------------------------------------------------
134
135_NS_INLINE NS::String* NS::ProcessInfo::hostName() const
136{
137    return Object::sendMessage<String*>(this, _NS_PRIVATE_SEL(hostName));
138}
139
140//-------------------------------------------------------------------------------------------------------------------------------------------------------------
141
142_NS_INLINE NS::String* NS::ProcessInfo::processName() const
143{
144    return Object::sendMessage<String*>(this, _NS_PRIVATE_SEL(processName));
145}
146
147//-------------------------------------------------------------------------------------------------------------------------------------------------------------
148
149_NS_INLINE void NS::ProcessInfo::setProcessName(const String* pString)
150{
151    Object::sendMessage<void>(this, _NS_PRIVATE_SEL(setProcessName_), pString);
152}
153
154//-------------------------------------------------------------------------------------------------------------------------------------------------------------
155
156_NS_INLINE int NS::ProcessInfo::processIdentifier() const
157{
158    return Object::sendMessage<int>(this, _NS_PRIVATE_SEL(processIdentifier));
159}
160
161//-------------------------------------------------------------------------------------------------------------------------------------------------------------
162
163_NS_INLINE NS::String* NS::ProcessInfo::globallyUniqueString() const
164{
165    return Object::sendMessage<String*>(this, _NS_PRIVATE_SEL(globallyUniqueString));
166}
167
168//-------------------------------------------------------------------------------------------------------------------------------------------------------------
169
170_NS_INLINE NS::String* NS::ProcessInfo::userName() const
171{
172    return Object::sendMessageSafe<String*>(this, _NS_PRIVATE_SEL(userName));
173}
174
175//-------------------------------------------------------------------------------------------------------------------------------------------------------------
176
177_NS_INLINE NS::String* NS::ProcessInfo::fullUserName() const
178{
179    return Object::sendMessageSafe<String*>(this, _NS_PRIVATE_SEL(fullUserName));
180}
181
182//-------------------------------------------------------------------------------------------------------------------------------------------------------------
183
184_NS_INLINE NS::UInteger NS::ProcessInfo::operatingSystem() const
185{
186    return Object::sendMessage<UInteger>(this, _NS_PRIVATE_SEL(operatingSystem));
187}
188
189//-------------------------------------------------------------------------------------------------------------------------------------------------------------
190
191_NS_INLINE NS::OperatingSystemVersion NS::ProcessInfo::operatingSystemVersion() const
192{
193    return Object::sendMessage<OperatingSystemVersion>(this, _NS_PRIVATE_SEL(operatingSystemVersion));
194}
195
196//-------------------------------------------------------------------------------------------------------------------------------------------------------------
197
198_NS_INLINE NS::String* NS::ProcessInfo::operatingSystemVersionString() const
199{
200    return Object::sendMessage<String*>(this, _NS_PRIVATE_SEL(operatingSystemVersionString));
201}
202
203//-------------------------------------------------------------------------------------------------------------------------------------------------------------
204
205_NS_INLINE bool NS::ProcessInfo::isOperatingSystemAtLeastVersion(OperatingSystemVersion version) const
206{
207    return Object::sendMessage<bool>(this, _NS_PRIVATE_SEL(isOperatingSystemAtLeastVersion_), version);
208}
209
210//-------------------------------------------------------------------------------------------------------------------------------------------------------------
211
212_NS_INLINE NS::UInteger NS::ProcessInfo::processorCount() const
213{
214    return Object::sendMessage<UInteger>(this, _NS_PRIVATE_SEL(processorCount));
215}
216
217//-------------------------------------------------------------------------------------------------------------------------------------------------------------
218
219_NS_INLINE NS::UInteger NS::ProcessInfo::activeProcessorCount() const
220{
221    return Object::sendMessage<UInteger>(this, _NS_PRIVATE_SEL(activeProcessorCount));
222}
223
224//-------------------------------------------------------------------------------------------------------------------------------------------------------------
225
226_NS_INLINE unsigned long long NS::ProcessInfo::physicalMemory() const
227{
228    return Object::sendMessage<unsigned long long>(this, _NS_PRIVATE_SEL(physicalMemory));
229}
230
231//-------------------------------------------------------------------------------------------------------------------------------------------------------------
232
233_NS_INLINE NS::TimeInterval NS::ProcessInfo::systemUptime() const
234{
235    return Object::sendMessage<TimeInterval>(this, _NS_PRIVATE_SEL(systemUptime));
236}
237
238//-------------------------------------------------------------------------------------------------------------------------------------------------------------
239
240_NS_INLINE void NS::ProcessInfo::disableSuddenTermination()
241{
242    Object::sendMessageSafe<void>(this, _NS_PRIVATE_SEL(disableSuddenTermination));
243}
244
245//-------------------------------------------------------------------------------------------------------------------------------------------------------------
246
247_NS_INLINE void NS::ProcessInfo::enableSuddenTermination()
248{
249    Object::sendMessageSafe<void>(this, _NS_PRIVATE_SEL(enableSuddenTermination));
250}
251
252//-------------------------------------------------------------------------------------------------------------------------------------------------------------
253
254_NS_INLINE void NS::ProcessInfo::disableAutomaticTermination(const String* pReason)
255{
256    Object::sendMessageSafe<void>(this, _NS_PRIVATE_SEL(disableAutomaticTermination_), pReason);
257}
258
259//-------------------------------------------------------------------------------------------------------------------------------------------------------------
260
261_NS_INLINE void NS::ProcessInfo::enableAutomaticTermination(const String* pReason)
262{
263    Object::sendMessageSafe<void>(this, _NS_PRIVATE_SEL(enableAutomaticTermination_), pReason);
264}
265
266//-------------------------------------------------------------------------------------------------------------------------------------------------------------
267
268_NS_INLINE bool NS::ProcessInfo::automaticTerminationSupportEnabled() const
269{
270    return Object::sendMessageSafe<bool>(this, _NS_PRIVATE_SEL(automaticTerminationSupportEnabled));
271}
272
273//-------------------------------------------------------------------------------------------------------------------------------------------------------------
274
275_NS_INLINE void NS::ProcessInfo::setAutomaticTerminationSupportEnabled(bool enabled)
276{
277    Object::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{
284    return Object::sendMessage<Object*>(this, _NS_PRIVATE_SEL(beginActivityWithOptions_reason_), options, pReason);
285}
286
287//-------------------------------------------------------------------------------------------------------------------------------------------------------------
288
289_NS_INLINE void NS::ProcessInfo::endActivity(Object* pActivity)
290{
291    Object::sendMessage<void>(this, _NS_PRIVATE_SEL(endActivity_), pActivity);
292}
293
294//-------------------------------------------------------------------------------------------------------------------------------------------------------------
295
296_NS_INLINE void NS::ProcessInfo::performActivity(ActivityOptions options, const String* pReason, void (^block)(void))
297{
298    Object::sendMessage<void>(this, _NS_PRIVATE_SEL(performActivityWithOptions_reason_usingBlock_), options, pReason, block);
299}
300
301//-------------------------------------------------------------------------------------------------------------------------------------------------------------
302
303_NS_INLINE void NS::ProcessInfo::performActivity(ActivityOptions options, const String* pReason, const std::function<void()>& function)
304{
305    __block std::function<void()> blockFunction = function;
306
307    performActivity(options, pReason, ^() { blockFunction(); });
308}
309
310//-------------------------------------------------------------------------------------------------------------------------------------------------------------
311
312_NS_INLINE void NS::ProcessInfo::performExpiringActivity(const String* pReason, void (^block)(bool expired))
313{
314    Object::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
323    performExpiringActivity(pReason, ^(bool expired) { blockFunction(expired); });
324}
325
326//-------------------------------------------------------------------------------------------------------------------------------------------------------------
327
328_NS_INLINE NS::ProcessInfoThermalState NS::ProcessInfo::thermalState() const
329{
330    return Object::sendMessage<ProcessInfoThermalState>(this, _NS_PRIVATE_SEL(thermalState));
331}
332
333//-------------------------------------------------------------------------------------------------------------------------------------------------------------
334
335_NS_INLINE bool NS::ProcessInfo::isLowPowerModeEnabled() const
336{
337    return Object::sendMessageSafe<bool>(this, _NS_PRIVATE_SEL(isLowPowerModeEnabled));
338}
339
340//-------------------------------------------------------------------------------------------------------------------------------------------------------------
341
342_NS_INLINE bool NS::ProcessInfo::isiOSAppOnMac() const
343{
344    return Object::sendMessageSafe<bool>(this, _NS_PRIVATE_SEL(isiOSAppOnMac));
345}
346
347//-------------------------------------------------------------------------------------------------------------------------------------------------------------
348
349_NS_INLINE bool NS::ProcessInfo::isMacCatalystApp() const
350{
351    return Object::sendMessageSafe<bool>(this, _NS_PRIVATE_SEL(isMacCatalystApp));
352}
353
354//-------------------------------------------------------------------------------------------------------------------------------------------------------------