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