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 "TclObject.hh"
8
9#include "hash_set.hh"
10
11#include <string_view>
12
13namespace openmsx {
14
15class SettingsConfig;
16class GlobalCommandController;
17
21{
22public:
23 explicit SettingsManager(GlobalCommandController& commandController);
29
33 [[nodiscard]] BaseSetting* findSetting(std::string_view name) const;
34 [[nodiscard]] BaseSetting* findSetting(std::string_view prefix, std::string_view baseName) const;
35
36 void loadSettings(const SettingsConfig& config) const;
37
40
41 [[nodiscard]] const auto& getAllSettings() const { return settings; }
42
43private:
44 [[nodiscard]] BaseSetting& getByName(std::string_view cmd, std::string_view name) const;
45 [[nodiscard]] std::vector<std::string> getTabSettingNames() const;
46
47private:
48 struct SettingInfo final : InfoTopic {
49 explicit SettingInfo(InfoCommand& openMSXInfoCommand);
50 void execute(std::span<const TclObject> tokens,
51 TclObject& result) const override;
52 [[nodiscard]] std::string help(std::span<const TclObject> tokens) const override;
53 void tabCompletion(std::vector<std::string>& tokens) const override;
54 } settingInfo;
55
56 struct SetCompleter final : CommandCompleter {
57 explicit SetCompleter(CommandController& commandController);
58 [[nodiscard]] std::string help(std::span<const TclObject> tokens) const override;
59 void tabCompletion(std::vector<std::string>& tokens) const override;
60 } setCompleter;
61
62 class SettingCompleter final : public CommandCompleter {
63 public:
64 SettingCompleter(CommandController& commandController,
65 SettingsManager& manager,
66 const std::string& name);
67 [[nodiscard]] std::string help(std::span<const TclObject> tokens) const override;
68 void tabCompletion(std::vector<std::string>& tokens) const override;
69 private:
70 SettingsManager& manager;
71 };
72 SettingCompleter incrCompleter;
73 SettingCompleter unsetCompleter;
74
75 struct NameFromSetting {
76 [[nodiscard]] const TclObject& operator()(const BaseSetting* s) const {
77 return s->getFullNameObj();
78 }
79 };
81};
82
83} // namespace openmsx
84
85#endif
BaseSetting * setting
Manages all settings.
SettingsManager & operator=(const SettingsManager &)=delete
BaseSetting * findSetting(std::string_view name) const
Find the setting with given name.
void loadSettings(const SettingsConfig &config) const
SettingsManager(const SettingsManager &)=delete
void unregisterSetting(BaseSetting &setting)
const auto & getAllSettings() const
SettingsManager & operator=(SettingsManager &&)=delete
SettingsManager(SettingsManager &&)=delete
void registerSetting(BaseSetting &setting)
This file implemented 3 utility functions:
Definition Autofire.cc:11