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
31private:
32 friend class LoadingIndicator;
33
41 void indicateLoadingState(bool state);
42
43 void updateStatus();
44
45 // Observer<Setting>
46 void update(const Setting& setting) noexcept override;
47
48private:
49 BooleanSetting throttleSetting;
50 BooleanSetting fullSpeedLoadingSetting;
51 int loading = 0;
52 bool throttle = true;
53};
54
59{
60public:
61 explicit LoadingIndicator(ThrottleManager& throttleManager);
63
67 void update(bool newState);
68
69private:
70 ThrottleManager& throttleManager;
71 bool isLoading = false;
72};
73
74} // namespace openmsx
75
76#endif
BaseSetting * setting
Definition: Interpreter.cc:28
Used by a device to indicate when it is loading.
LoadingIndicator(ThrottleManager &throttleManager)
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.
ThrottleManager(CommandController &commandController)
This file implemented 3 utility functions:
Definition: Autofire.cc:9