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
7#include "hash_map.hh"
8#include "xxhash.hh"
9
10#include <string>
11#include <string_view>
12
13namespace openmsx {
14
15class FileContext;
16class HotKey;
17class GlobalCommandController;
18class CommandController;
19class Shortcuts;
20
22{
23public:
24 SettingsConfig(GlobalCommandController& globalCommandController,
25 HotKey& hotKey);
27
28 void loadSetting(const FileContext& context, std::string_view filename);
29 void saveSetting(std::string filename = {});
30 void setSaveSettings(bool save) { mustSaveSettings = save; }
31 void setSaveFilename(const FileContext& context, std::string_view filename);
32
33 [[nodiscard]] SettingsManager& getSettingsManager() { return settingsManager; }
34
35 // manipulate info that would be stored in settings.xml
36 [[nodiscard]] const std::string* getValueForSetting(std::string_view setting) const;
37 void setValueForSetting(std::string_view setting, std::string_view value);
38 void removeValueForSetting(std::string_view setting);
39
40 void setShortcuts(Shortcuts& shortcuts_) { shortcuts = &shortcuts_; };
41
42private:
43 CommandController& commandController;
44 Shortcuts* shortcuts;
45
46 struct SaveSettingsCommand final : Command {
47 explicit SaveSettingsCommand(CommandController& commandController);
48 void execute(std::span<const TclObject> tokens, TclObject& result) override;
49 [[nodiscard]] std::string help(std::span<const TclObject> tokens) const override;
50 void tabCompletion(std::vector<std::string>& tokens) const override;
51 } saveSettingsCommand;
52
53 struct LoadSettingsCommand final : Command {
54 explicit LoadSettingsCommand(CommandController& commandController);
55 void execute(std::span<const TclObject> tokens, TclObject& result) override;
56 [[nodiscard]] std::string help(std::span<const TclObject> tokens) const override;
57 void tabCompletion(std::vector<std::string>& tokens) const override;
58 } loadSettingsCommand;
59
60 SettingsManager settingsManager;
62 HotKey& hotKey;
63 std::string saveName;
64 bool mustSaveSettings = false;
65};
66
67} // namespace openmsx
68
69#endif
BaseSetting * setting
void saveSetting(std::string filename={})
void setShortcuts(Shortcuts &shortcuts_)
void loadSetting(const FileContext &context, std::string_view filename)
SettingsManager & getSettingsManager()
void setSaveFilename(const FileContext &context, std::string_view filename)
void removeValueForSetting(std::string_view setting)
void setValueForSetting(std::string_view setting, std::string_view value)
const std::string * getValueForSetting(std::string_view setting) const
void setSaveSettings(bool save)
Manages all settings.
This file implemented 3 utility functions:
Definition Autofire.cc:11