Overte C++ Documentation
PerformanceManager.h
1 //
2 // PerformanceManager.h
3 // interface/src/
4 //
5 // Created by Sam Gateau on 2019-05-29.
6 // Copyright 2019 High Fidelity, Inc.
7 //
8 // Distributed under the Apache License, Version 2.0.
9 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
10 //
11 
12 #ifndef hifi_PerformanceManager_h
13 #define hifi_PerformanceManager_h
14 
15 #include <string>
16 
17 #include <SettingHandle.h>
18 #include <shared/ReadWriteLockable.h>
19 
20 class PerformanceManager {
21 public:
22  enum PerformancePreset {
23  UNKNOWN = 0, // Matching the platform Tier profiles enumeration for coherence
24  LOW_POWER,
25  LOW,
26  MID,
27  HIGH,
28  CUSTOM,
29  PROFILE_COUNT
30  };
31  static bool isValidPerformancePreset(int value) { return (value >= PerformancePreset::UNKNOWN && value <= PerformancePreset::CUSTOM); }
32 
33  PerformanceManager();
34  ~PerformanceManager() = default;
35 
36  // Setup the PerformanceManager which will enforce the several settings to match the Preset
37  // If evaluatePlatformTier is true, the Preset is evaluated from the Platform::Profiler::profilePlatform()
38  void setupPerformancePresetSettings(bool evaluatePlatformTier);
39 
40  void setPerformancePreset(PerformancePreset performancePreset);
41  PerformancePreset getPerformancePreset() const;
42 
43 private:
44  mutable ReadWriteLockable _performancePresetSettingLock;
45  Setting::Handle<int> _performancePresetSetting { "performancePreset", PerformanceManager::PerformancePreset::UNKNOWN };
46 
47  // The concrete performance preset changes
48  void applyPerformancePreset(PerformanceManager::PerformancePreset performancePreset);
49 };
50 
51 #endif