| 1 |
#ifndef THROTTLEMANAGER_HH |
| 2 |
#define THROTTLEMANAGER_HH |
| 3 |
|
| 4 |
#include "BooleanSetting.hh" |
| 5 |
|
| 6 |
#include "Subject.hh" |
| 7 |
|
| 8 |
namespace openmsx { |
| 9 |
|
| 10 |
class CommandController; |
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
class ThrottleManager final : public Subject<ThrottleManager> |
| 19 |
, private Observer<Setting> |
| 20 |
{ |
| 21 |
public: |
| 22 |
explicit ThrottleManager(CommandController& commandController); |
| 23 |
~ThrottleManager(); |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
[[nodiscard]] bool isThrottled() const { return throttle; } |
| 31 |
|
| 32 |
[[nodiscard]] auto& getFullSpeedLoadingSetting() { return fullSpeedLoadingSetting; } |
| 33 |
|
| 34 |
private: |
| 35 |
friend class LoadingIndicator; |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
void indicateLoadingState(bool state); |
| 45 |
|
| 46 |
void updateStatus(); |
| 47 |
|
| 48 |
|
| 49 |
void update(const Setting& setting) noexcept override; |
| 50 |
|
| 51 |
private: |
| 52 |
BooleanSetting throttleSetting; |
| 53 |
BooleanSetting fullSpeedLoadingSetting; |
| 54 |
int loading = 0; |
| 55 |
bool throttle = true; |
| 56 |
}; |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
class LoadingIndicator |
| 62 |
{ |
| 63 |
public: |
| 64 |
explicit LoadingIndicator(ThrottleManager& throttleManager); |
| 65 |
~LoadingIndicator(); |
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
void update(bool newState); |
| 71 |
|
| 72 |
private: |
| 73 |
ThrottleManager& throttleManager; |
| 74 |
bool isLoading = false; |
| 75 |
}; |
| 76 |
|
| 77 |
} |
| 78 |
|
| 79 |
#endif |