openMSX
SettingsConfig.hh
Go to the documentation of this file.
1 #ifndef SETTINGSCONFIG_HH
2 #define SETTINGSCONFIG_HH
3 
4 #include "SettingsManager.hh"
5 #include "Command.hh"
6 #include "XMLElement.hh"
7 #include <string>
8 #include <string_view>
9 
10 namespace openmsx {
11 
12 class FileContext;
13 class HotKey;
14 class GlobalCommandController;
15 class CommandController;
16 
18 {
19 public:
20  SettingsConfig(GlobalCommandController& globalCommandController,
21  HotKey& hotKey);
23 
24  void loadSetting(const FileContext& context, std::string_view filename);
25  void saveSetting(std::string filename = {});
26  void setSaveSettings(bool save) { mustSaveSettings = save; }
27  void setSaveFilename(const FileContext& context, std::string_view filename);
28 
29  [[nodiscard]] SettingsManager& getSettingsManager() { return settingsManager; }
30  [[nodiscard]] XMLElement& getXMLElement() { return xmlElement; }
31 
32 private:
33  CommandController& commandController;
34 
35  struct SaveSettingsCommand final : Command {
36  explicit SaveSettingsCommand(CommandController& commandController);
37  void execute(span<const TclObject> tokens, TclObject& result) override;
38  [[nodiscard]] std::string help(const std::vector<std::string>& tokens) const override;
39  void tabCompletion(std::vector<std::string>& tokens) const override;
40  } saveSettingsCommand;
41 
42  struct LoadSettingsCommand final : Command {
43  explicit LoadSettingsCommand(CommandController& commandController);
44  void execute(span<const TclObject> tokens, TclObject& result) override;
45  [[nodiscard]] std::string help(const std::vector<std::string>& tokens) const override;
46  void tabCompletion(std::vector<std::string>& tokens) const override;
47  } loadSettingsCommand;
48 
49  SettingsManager settingsManager;
50  XMLElement xmlElement;
51  HotKey& hotKey;
52  std::string saveName;
53  bool mustSaveSettings;
54 };
55 
56 } // namespace openmsx
57 
58 #endif
SettingsConfig(GlobalCommandController &globalCommandController, HotKey &hotKey)
SettingsManager & getSettingsManager()
void saveSetting(std::string filename={})
void loadSetting(const FileContext &context, std::string_view filename)
void setSaveFilename(const FileContext &context, std::string_view filename)
XMLElement & getXMLElement()
void setSaveSettings(bool save)
Manages all settings.
Definition: span.hh:126
std::unique_ptr< Context > context
Definition: GLContext.cc:9
This file implemented 3 utility functions:
Definition: Autofire.cc:9
constexpr const char *const filename