openMSX
UserSettings.hh
Go to the documentation of this file.
1 #ifndef USERSETTINGS_HH
2 #define USERSETTINGS_HH
3 
4 #include "Command.hh"
5 #include "string_ref.hh"
6 #include <vector>
7 #include <memory>
8 
9 namespace openmsx {
10 
11 class Setting;
12 
14 {
15 public:
16  using Settings = std::vector<std::unique_ptr<Setting>>;
17 
18  explicit UserSettings(CommandController& commandController);
19 
20  void addSetting(std::unique_ptr<Setting> setting);
21  void deleteSetting(Setting& setting);
22  Setting* findSetting(string_ref name) const;
23  const Settings& getSettings() const { return settings; }
24 
25 private:
26  class Cmd final : public Command {
27  public:
28  explicit Cmd(CommandController& commandController);
29  void execute(array_ref<TclObject> tokens,
30  TclObject& result) override;
31  std::string help(const std::vector<std::string>& tokens) const override;
32  void tabCompletion(std::vector<std::string>& tokens) const override;
33 
34  private:
35  void create (array_ref<TclObject> tokens, TclObject& result);
36  void destroy(array_ref<TclObject> tokens, TclObject& result);
37  void info (array_ref<TclObject> tokens, TclObject& result);
38 
39  std::unique_ptr<Setting> createString (array_ref<TclObject> tokens);
40  std::unique_ptr<Setting> createBoolean(array_ref<TclObject> tokens);
41  std::unique_ptr<Setting> createInteger(array_ref<TclObject> tokens);
42  std::unique_ptr<Setting> createFloat (array_ref<TclObject> tokens);
43 
44  std::vector<string_ref> getSettingNames() const;
45  } userSettingCommand;
46 
47  Settings settings; // unordered
48 };
49 
50 } // namespace openmsx
51 
52 #endif
std::vector< std::unique_ptr< Setting >> Settings
Definition: UserSettings.hh:16
void addSetting(std::unique_ptr< Setting > setting)
Definition: UserSettings.cc:29
This class implements a subset of the proposal for std::string_ref (proposed for the next c++ standar...
Definition: string_ref.hh:18
This class implements a subset of the proposal for std::array_ref (proposed for the next c++ standard...
Definition: array_ref.hh:19
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
void deleteSetting(Setting &setting)
Definition: UserSettings.cc:35
const Settings & getSettings() const
Definition: UserSettings.hh:23
UserSettings(CommandController &commandController)
Definition: UserSettings.cc:24
unique_ptr< IDEDevice > create(const DeviceConfig &config)
Setting * findSetting(string_ref name) const
Definition: UserSettings.cc:41