VirtualC64 v5.0 beta
Commodore 64 Emulator
Loading...
Searching...
No Matches
Configurable.h
1// -----------------------------------------------------------------------------
2// This file is part of VirtualC64
3//
4// Copyright (C) Dirk W. Hoffmann. www.dirkwhoffmann.de
5// This FILE is dual-licensed. You are free to choose between:
6//
7// - The GNU General Public License v3 (or any later version)
8// - The Mozilla Public License v2
9//
10// SPDX-License-Identifier: GPL-3.0-or-later OR MPL-2.0
11// -----------------------------------------------------------------------------
12
13#pragma once
14
15#include "OptionTypes.h"
16#include "Reflection.h"
17#include "Defaults.h"
18#include <algorithm>
19
20namespace vc64 {
21
22typedef std::vector<Option> ConfigOptions;
23
24class Configurable
25{
26 const static ConfigOptions options;
27
28public:
29
30 virtual ~Configurable() = default;
31
32 // Returns the available config options
33 virtual const ConfigOptions &getOptions() const { return options; }
34
35 // Returns true iff a specific option is available
36 bool isValidOption(Option opt) const;
37
38 // Gets a config option
39 virtual i64 getOption(Option opt) const { return 0; }
40
41 // Gets the fallback for a config option
42 virtual i64 getFallback(Option opt) const { return 0; }
43
44 // Throws an exception of if the given option/value pair is invalid
45 virtual void checkOption(Option opt, i64 value) { }
46 void checkOption(Option opt, const string &value);
47 void checkOption(const string &opt, const string &value);
48
49 // Sets a config option
50 virtual void setOption(Option opt, i64 value) { }
51 void setOption(Option opt, const string &value);
52 void setOption(const string &opt, const string &value);
53
54 // Resets all config options
55 void resetConfig(const Defaults &defaults, isize objid = 0);
56
57 // Dumps the current configuration
58 void dumpConfig(std::ostream& os) const;
59
60 // Returns a textual description for all available options
61 string keyList() { return OptionEnum::keyList([&](Option i) { return isValidOption(i); }); }
62 string argList() { return OptionEnum::argList([&](Option i) { return isValidOption(i); }); }
63
64};
65
66}
VirtualC64 project namespace.
Definition CmdQueue.cpp:16