openMSX
DeviceConfig.hh
Go to the documentation of this file.
1#ifndef DEVICECONFIG_HH
2#define DEVICECONFIG_HH
3
4#include <cassert>
5#include <string_view>
6
7namespace openmsx {
8
9class XMLElement;
10class XMLDocument;
11class HardwareConfig;
12class FileContext;
13class MSXMotherBoard;
14class MSXCliComm;
15class CommandController;
16class Scheduler;
17class Reactor;
18class GlobalSettings;
19
21{
22public:
23 DeviceConfig() = default;
24 DeviceConfig(const HardwareConfig& hwConf_, const XMLElement& devConf_)
25 : hwConf(&hwConf_), devConf(&devConf_)
26 {
27 }
28 DeviceConfig(const HardwareConfig& hwConf_, const XMLElement& devConf_,
29 const XMLElement* primary_, const XMLElement* secondary_)
30 : hwConf(&hwConf_), devConf(&devConf_)
31 , primary(primary_), secondary(secondary_)
32 {
33 }
34 DeviceConfig(const DeviceConfig& other, const XMLElement& devConf_)
35 : hwConf(other.hwConf), devConf(&devConf_)
36 {
37 }
38 DeviceConfig(const DeviceConfig& other, const XMLElement* devConf_)
39 : hwConf(other.hwConf), devConf(devConf_)
40 {
41 }
42
43 [[nodiscard]] const HardwareConfig& getHardwareConfig() const
44 {
45 assert(hwConf);
46 return *hwConf;
47 }
48 [[nodiscard]] const XMLElement* getXML() const
49 {
50 return devConf;
51 }
52 [[nodiscard]] XMLElement* getPrimary() const
53 {
54 return const_cast<XMLElement*>(primary);
55 }
56 [[nodiscard]] XMLElement* getSecondary() const
57 {
58 return const_cast<XMLElement*>(secondary);
59 }
60
61 // convenience methods:
62 // methods below simply delegate to HardwareConfig or XMLElement
63 [[nodiscard]] const FileContext& getFileContext() const;
64 [[nodiscard]] MSXMotherBoard& getMotherBoard() const;
65 [[nodiscard]] MSXCliComm& getCliComm() const;
66 [[nodiscard]] CommandController& getCommandController() const;
67 [[nodiscard]] Scheduler& getScheduler() const;
68 [[nodiscard]] Reactor& getReactor() const;
69 [[nodiscard]] GlobalSettings& getGlobalSettings() const;
70 [[nodiscard]] XMLDocument& getXMLDocument();
71
72 [[nodiscard]] const XMLElement& getChild(std::string_view name) const;
73 [[nodiscard]] std::string_view getChildData(std::string_view name) const;
74 [[nodiscard]] std::string_view getChildData(std::string_view name,
75 std::string_view defaultValue) const;
76 [[nodiscard]] int getChildDataAsInt(std::string_view name, int defaultValue) const;
77 [[nodiscard]] bool getChildDataAsBool(std::string_view name,
78 bool defaultValue = false) const;
79 [[nodiscard]] const XMLElement* findChild(std::string_view name) const;
80 [[nodiscard]] std::string_view getAttributeValue(std::string_view attName) const;
81 [[nodiscard]] int getAttributeValueAsInt(std::string_view attName, int defaultValue) const;
82
83private:
84 const HardwareConfig* hwConf = nullptr;
85 const XMLElement* devConf = nullptr;
86 const XMLElement* primary = nullptr;
87 const XMLElement* secondary = nullptr;
88};
89
90} // namespace openmsx
91
92#endif
XMLElement * getPrimary() const
Reactor & getReactor() const
bool getChildDataAsBool(std::string_view name, bool defaultValue=false) const
DeviceConfig(const HardwareConfig &hwConf_, const XMLElement &devConf_, const XMLElement *primary_, const XMLElement *secondary_)
MSXCliComm & getCliComm() const
DeviceConfig(const HardwareConfig &hwConf_, const XMLElement &devConf_)
const FileContext & getFileContext() const
const XMLElement * findChild(std::string_view name) const
DeviceConfig(const DeviceConfig &other, const XMLElement &devConf_)
GlobalSettings & getGlobalSettings() const
int getChildDataAsInt(std::string_view name, int defaultValue) const
XMLDocument & getXMLDocument()
DeviceConfig(const DeviceConfig &other, const XMLElement *devConf_)
MSXMotherBoard & getMotherBoard() const
CommandController & getCommandController() const
std::string_view getChildData(std::string_view name) const
Scheduler & getScheduler() const
const XMLElement & getChild(std::string_view name) const
const HardwareConfig & getHardwareConfig() const
XMLElement * getSecondary() const
const XMLElement * getXML() const
int getAttributeValueAsInt(std::string_view attName, int defaultValue) const
std::string_view getAttributeValue(std::string_view attName) const
This class contains settings that are used by several other class (including some singletons).
Contains the main loop of openMSX.
Definition Reactor.hh:72
This file implemented 3 utility functions:
Definition Autofire.cc:9