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 
7 namespace openmsx {
8 
9 class CommandController;
10 
17 class ThrottleManager final : public Subject<ThrottleManager>
18  , private Observer<Setting>
19 {
20 public:
21  explicit ThrottleManager(CommandController& commandController);
23 
29  bool isThrottled() const { return throttle; }
30 
31 private:
32  friend class LoadingIndicator;
33 
41  void indicateLoadingState(bool state);
42 
43  void updateStatus();
44 
45  // Observer<Setting>
46  void update(const Setting& setting) override;
47 
48  BooleanSetting throttleSetting;
49  BooleanSetting fullSpeedLoadingSetting;
50  int loading;
51  bool throttle;
52 };
53 
58 {
59 public:
60  explicit LoadingIndicator(ThrottleManager& throttleManager);
62 
66  void update(bool newState);
67 
68 private:
69  ThrottleManager& throttleManager;
70  bool isLoading;
71 };
72 
73 } // namespace openmsx
74 
75 #endif
bool isThrottled() const
Ask if throttling is enabled.
ThrottleManager(CommandController &commandController)
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
Generic Gang-of-Four Subject class of the Observer pattern, templatized edition.
Definition: Subject.hh:17
Used by a device to indicate when it is loading.
Manages the throttle state of openMSX.
Generic Gang-of-Four Observer class, templatized edition.
Definition: Observer.hh:9