| 1 |
#ifndef DEVICECONFIG_HH |
| 2 |
#define DEVICECONFIG_HH |
| 3 |
|
| 4 |
#include <cassert> |
| 5 |
#include <string_view> |
| 6 |
|
| 7 |
namespace openmsx { |
| 8 |
|
| 9 |
class XMLElement; |
| 10 |
class XMLDocument; |
| 11 |
class HardwareConfig; |
| 12 |
class FileContext; |
| 13 |
class MSXMotherBoard; |
| 14 |
class MSXCliComm; |
| 15 |
class CommandController; |
| 16 |
class Scheduler; |
| 17 |
class Reactor; |
| 18 |
class GlobalSettings; |
| 19 |
|
| 20 |
class DeviceConfig |
| 21 |
{ |
| 22 |
public: |
| 23 |
DeviceConfig() = default; |
| 24 |
DeviceConfig(HardwareConfig& hwConf_, XMLElement& devConf_) |
| 25 |
: hwConf(&hwConf_), devConf(&devConf_) |
| 26 |
{ |
| 27 |
} |
| 28 |
DeviceConfig(HardwareConfig& hwConf_, XMLElement& devConf_, |
| 29 |
XMLElement* primary_, XMLElement* secondary_) |
| 30 |
: hwConf(&hwConf_), devConf(&devConf_) |
| 31 |
, primary(primary_), secondary(secondary_) |
| 32 |
{ |
| 33 |
} |
| 34 |
DeviceConfig(const DeviceConfig& other, XMLElement& devConf_) |
| 35 |
: hwConf(other.hwConf), devConf(&devConf_) |
| 36 |
{ |
| 37 |
} |
| 38 |
DeviceConfig(const DeviceConfig& other, 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]] HardwareConfig& getHardwareConfig() |
| 49 |
{ |
| 50 |
assert(hwConf); |
| 51 |
return *hwConf; |
| 52 |
} |
| 53 |
[[nodiscard]] const XMLElement* getXML() const |
| 54 |
{ |
| 55 |
return devConf; |
| 56 |
} |
| 57 |
[[nodiscard]] XMLElement* getXML() |
| 58 |
{ |
| 59 |
return devConf; |
| 60 |
} |
| 61 |
[[nodiscard]] XMLElement* getPrimary() const |
| 62 |
{ |
| 63 |
return primary; |
| 64 |
} |
| 65 |
[[nodiscard]] XMLElement* getSecondary() const |
| 66 |
{ |
| 67 |
return secondary; |
| 68 |
} |
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
[[nodiscard]] const FileContext& getFileContext() const; |
| 73 |
[[nodiscard]] MSXMotherBoard& getMotherBoard() const; |
| 74 |
[[nodiscard]] MSXCliComm& getCliComm() const; |
| 75 |
[[nodiscard]] CommandController& getCommandController() const; |
| 76 |
[[nodiscard]] Scheduler& getScheduler() const; |
| 77 |
[[nodiscard]] Reactor& getReactor() const; |
| 78 |
[[nodiscard]] GlobalSettings& getGlobalSettings() const; |
| 79 |
[[nodiscard]] XMLDocument& getXMLDocument(); |
| 80 |
|
| 81 |
[[nodiscard]] const XMLElement& getChild(std::string_view name) const; |
| 82 |
[[nodiscard]] XMLElement& getChild(std::string_view name); |
| 83 |
[[nodiscard]] std::string_view getChildData(std::string_view name) const; |
| 84 |
[[nodiscard]] std::string_view getChildData(std::string_view name, |
| 85 |
std::string_view defaultValue) const; |
| 86 |
[[nodiscard]] int getChildDataAsInt(std::string_view name, int defaultValue) const; |
| 87 |
[[nodiscard]] bool getChildDataAsBool(std::string_view name, |
| 88 |
bool defaultValue = false) const; |
| 89 |
[[nodiscard]] const XMLElement* findChild(std::string_view name) const; |
| 90 |
[[nodiscard]] XMLElement* findChild(std::string_view name); |
| 91 |
[[nodiscard]] std::string_view getAttributeValue(std::string_view attName) const; |
| 92 |
[[nodiscard]] int getAttributeValueAsInt(std::string_view attName, int defaultValue) const; |
| 93 |
|
| 94 |
private: |
| 95 |
HardwareConfig* hwConf = nullptr; |
| 96 |
XMLElement* devConf = nullptr; |
| 97 |
XMLElement* primary = nullptr; |
| 98 |
XMLElement* secondary = nullptr; |
| 99 |
}; |
| 100 |
|
| 101 |
} |
| 102 |
|
| 103 |
#endif |