openMSX
SettingsManager.hh
Go to the documentation of this file.
1#ifndef SETTINGSMANAGER_HH
2#define SETTINGSMANAGER_HH
3
4#include "Command.hh"
5#include "InfoTopic.hh"
6#include "Setting.hh"
7#include "hash_set.hh"
8#include "TclObject.hh"
9#include <string_view>
10
11namespace openmsx {
12
13class SettingsConfig;
14class GlobalCommandController;
15
19{
20public:
23
24 explicit SettingsManager(GlobalCommandController& commandController);
26
30 [[nodiscard]] BaseSetting* findSetting(std::string_view name) const;
31 [[nodiscard]] BaseSetting* findSetting(std::string_view prefix, std::string_view baseName) const;
32
33 void loadSettings(const SettingsConfig& config);
34
37
38private:
39 [[nodiscard]] BaseSetting& getByName(std::string_view cmd, std::string_view name) const;
40 [[nodiscard]] std::vector<std::string> getTabSettingNames() const;
41
42private:
43 struct SettingInfo final : InfoTopic {
44 explicit SettingInfo(InfoCommand& openMSXInfoCommand);
45 void execute(std::span<const TclObject> tokens,
46 TclObject& result) const override;
47 [[nodiscard]] std::string help(std::span<const TclObject> tokens) const override;
48 void tabCompletion(std::vector<std::string>& tokens) const override;
49 } settingInfo;
50
51 struct SetCompleter final : CommandCompleter {
52 explicit SetCompleter(CommandController& commandController);
53 [[nodiscard]] std::string help(std::span<const TclObject> tokens) const override;
54 void tabCompletion(std::vector<std::string>& tokens) const override;
55 } setCompleter;
56
57 class SettingCompleter final : public CommandCompleter {
58 public:
59 SettingCompleter(CommandController& commandController,
60 SettingsManager& manager,
61 const std::string& name);
62 [[nodiscard]] std::string help(std::span<const TclObject> tokens) const override;
63 void tabCompletion(std::vector<std::string>& tokens) const override;
64 private:
65 SettingsManager& manager;
66 };
67 SettingCompleter incrCompleter;
68 SettingCompleter unsetCompleter;
69
70 struct NameFromSetting {
71 [[nodiscard]] const TclObject& operator()(BaseSetting* s) const {
72 return s->getFullNameObj();
73 }
74 };
76};
77
78} // namespace openmsx
79
80#endif
BaseSetting * setting
Definition: Interpreter.cc:28
Manages all settings.
SettingsManager & operator=(const SettingsManager &)=delete
BaseSetting * findSetting(std::string_view name) const
Find the setting with given name.
SettingsManager(const SettingsManager &)=delete
void unregisterSetting(BaseSetting &setting)
void loadSettings(const SettingsConfig &config)
void registerSetting(BaseSetting &setting)
This file implemented 3 utility functions:
Definition: Autofire.cc:9