openMSX
ThrottleManager.hh
Go to the documentation of this file.
1#ifndef THROTTLEMANAGER_HH
2#define THROTTLEMANAGER_HH
3
4#include "Subject.hh"
5#include "BooleanSetting.hh"
6
7namespace openmsx {
8
9class CommandController;
10
17class ThrottleManager final : public Subject<ThrottleManager>
18 , private Observer<Setting>
19{
20public:
21 explicit ThrottleManager(CommandController& commandController);
23
29 [[nodiscard]] bool isThrottled() const { return throttle; }
30
31 [[nodiscard]] auto& getFullSpeedLoadingSetting() { return fullSpeedLoadingSetting; }
32
33private:
34 friend class LoadingIndicator;
35
43 void indicateLoadingState(bool state);
44
45 void updateStatus();
46
47 // Observer<Setting>
48 void update(const Setting& setting) noexcept override;
49
50private:
51 BooleanSetting throttleSetting;
52 BooleanSetting fullSpeedLoadingSetting;
53 int loading = 0;
54 bool throttle = true;
55};
56
61{
62public:
63 explicit LoadingIndicator(ThrottleManager& throttleManager);
65
69 void update(bool newState);
70
71private:
72 ThrottleManager& throttleManager;
73 bool isLoading = false;
74};
75
76} // namespace openmsx
77
78#endif
BaseSetting * setting
Used by a device to indicate when it is loading.
void update(bool newState)
Called by the device to indicate its loading state may have changed.
Generic Gang-of-Four Observer class, templatized edition.
Definition Observer.hh:10
Generic Gang-of-Four Subject class of the Observer pattern, templatized edition.
Definition Subject.hh:18
Manages the throttle state of openMSX.
bool isThrottled() const
Ask if throttling is enabled.
This file implemented 3 utility functions:
Definition Autofire.cc:11