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
38 [[nodiscard]] const auto& getAllSettings() const { return settings; }
39
40private:
41 [[nodiscard]] BaseSetting& getByName(std::string_view cmd, std::string_view name) const;
42 [[nodiscard]] std::vector<std::string> getTabSettingNames() const;
43
44private:
45 struct SettingInfo final : InfoTopic {
46 explicit SettingInfo(InfoCommand& openMSXInfoCommand);
47 void execute(std::span<const TclObject> tokens,
48 TclObject& result) const override;
49 [[nodiscard]] std::string help(std::span<const TclObject> tokens) const override;
50 void tabCompletion(std::vector<std::string>& tokens) const override;
51 } settingInfo;
52
53 struct SetCompleter final : CommandCompleter {
54 explicit SetCompleter(CommandController& commandController);
55 [[nodiscard]] std::string help(std::span<const TclObject> tokens) const override;
56 void tabCompletion(std::vector<std::string>& tokens) const override;
57 } setCompleter;
58
59 class SettingCompleter final : public CommandCompleter {
60 public:
61 SettingCompleter(CommandController& commandController,
62 SettingsManager& manager,
63 const std::string& name);
64 [[nodiscard]] std::string help(std::span<const TclObject> tokens) const override;
65 void tabCompletion(std::vector<std::string>& tokens) const override;
66 private:
67 SettingsManager& manager;
68 };
69 SettingCompleter incrCompleter;
70 SettingCompleter unsetCompleter;
71
72 struct NameFromSetting {
73 [[nodiscard]] const TclObject& operator()(BaseSetting* s) const {
74 return s->getFullNameObj();
75 }
76 };
78};
79
80} // namespace openmsx
81
82#endif
BaseSetting * setting
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)
const auto & getAllSettings() const
void registerSetting(BaseSetting &setting)
This file implemented 3 utility functions:
Definition Autofire.cc:9