Bug fix: check if vm exists
[avr-sim.git] / DeviceSettings.h
blobc012f221efdc191c8c6ed30b97c24ee813fda88f
1 #ifndef AVR_DEVICESETTINGS_H
2 #define AVR_DEVICESETTINGS_H
4 #include "Exception.h"
5 #include <string>
7 struct _xmlNode;
9 namespace avr {
11 class ParseException : public util::Exception {
12 public:
13 ParseException() : Exception("Parse Exception") {}
14 ParseException(const char * msg) : Exception(msg) {}
15 ParseException(const std::string & msg) : Exception(msg) {}
18 class Device;
19 class XmlHandle;
21 /**
22 * The Settings class allows reading Hardware settings
23 * from the xml file without exposing the xml related
24 * bits.
26 class HardwareSettings {
27 public:
28 HardwareSettings(XmlHandle & doc, _xmlNode *node);
30 public:
31 int intAttribute(const char *name, int base = 10) const;
32 int intAttributeDef(const char *name, int def = 0, int base = 10) const;
33 std::string strAttribute(const char *name) const;
35 public:
36 bool getBinding(std::string & name, std::string & binding);
38 private:
39 XmlHandle & doc;
40 _xmlNode *node;
41 _xmlNode *reg;
44 /**
45 * This class allows reading device settings from xml files
47 class DeviceSettings {
48 public:
49 static void listAll();
50 static void load(Device *dev, const char *devicename);
52 private:
53 static void parseMemory(Device *dev, _xmlNode *memory);
54 static void parseRegisters(Device *dev, _xmlNode *registers);
55 static void parseInterrupts(Device *dev, _xmlNode *interrupts);
56 static void parseHardware(Device *dev, XmlHandle & doc, _xmlNode *hardware);
60 #endif /*AVR_DEVICESETTINGS_H*/