Changeset 31464 in vbox for trunk/include/VBox
- Timestamp:
- Aug 9, 2010 9:15:40 AM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 64546
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/settings.h
r31303 r31464 60 60 61 61 class ConfigFileError; 62 63 ////////////////////////////////////////////////////////////////////////////////64 //65 // Helper classes66 //67 ////////////////////////////////////////////////////////////////////////////////68 69 // ExtraDataItem (used by both VirtualBox.xml and machines XML)70 typedef std::map<com::Utf8Str, com::Utf8Str> ExtraDataItemsMap;71 struct USBDeviceFilter;72 typedef std::list<USBDeviceFilter> USBDeviceFiltersList;73 74 /**75 * Common base class for both MainConfigFile and MachineConfigFile76 * which contains some common logic for both.77 */78 class ConfigFileBase79 {80 public:81 bool fileExists();82 83 void copyBaseFrom(const ConfigFileBase &b);84 85 protected:86 ConfigFileBase(const com::Utf8Str *pstrFilename);87 ~ConfigFileBase();88 89 void parseUUID(com::Guid &guid,90 const com::Utf8Str &strUUID) const;91 void parseTimestamp(RTTIMESPEC ×tamp,92 const com::Utf8Str &str) const;93 94 com::Utf8Str makeString(const RTTIMESPEC &tm);95 96 void readExtraData(const xml::ElementNode &elmExtraData,97 ExtraDataItemsMap &map);98 void readUSBDeviceFilters(const xml::ElementNode &elmDeviceFilters,99 USBDeviceFiltersList &ll);100 101 void setVersionAttribute(xml::ElementNode &elm);102 void createStubDocument();103 104 void writeExtraData(xml::ElementNode &elmParent, const ExtraDataItemsMap &me);105 void writeUSBDeviceFilters(xml::ElementNode &elmParent,106 const USBDeviceFiltersList &ll,107 bool fHostMode);108 109 void clearDocument();110 111 struct Data;112 Data *m;113 114 private:115 // prohibit copying (Data contains pointers to XML which cannot be copied)116 ConfigFileBase(const ConfigFileBase&);117 118 friend class ConfigFileError;119 };120 62 121 63 //////////////////////////////////////////////////////////////////////////////// … … 157 99 }; 158 100 101 typedef std::map<com::Utf8Str, com::Utf8Str> PropertiesMap; 102 103 // ExtraDataItem (used by both VirtualBox.xml and machines XML) 104 typedef std::map<com::Utf8Str, com::Utf8Str> ExtraDataItemsMap; 105 struct USBDeviceFilter; 106 typedef std::list<USBDeviceFilter> USBDeviceFiltersList; 107 108 struct Medium; 109 typedef std::list<Medium> MediaList; 110 111 /** 112 * NOTE: If you add any fields in here, you must update a) the constructor and b) 113 * the operator== which is used by MachineConfigFile::operator==(), or otherwise 114 * your settings might never get saved. 115 */ 116 struct Medium 117 { 118 com::Guid uuid; 119 com::Utf8Str strLocation; 120 com::Utf8Str strDescription; 121 122 // the following are for hard disks only: 123 com::Utf8Str strFormat; 124 bool fAutoReset; // optional, only for diffs, default is false 125 PropertiesMap properties; 126 MediumType_T hdType; 127 128 MediaList llChildren; // only used with hard disks 129 130 bool operator==(const Medium &m) const; 131 }; 132 133 /** 134 * NOTE: If you add any fields in here, you must update a) the constructor and b) 135 * the operator== which is used by MachineConfigFile::operator==(), or otherwise 136 * your settings might never get saved. 137 */ 138 struct MediaRegistry 139 { 140 MediaList llHardDisks, 141 llDvdImages, 142 llFloppyImages; 143 144 bool operator==(const MediaRegistry &m) const; 145 }; 146 147 /** 148 * Common base class for both MainConfigFile and MachineConfigFile 149 * which contains some common logic for both. 150 */ 151 class ConfigFileBase 152 { 153 public: 154 bool fileExists(); 155 156 void copyBaseFrom(const ConfigFileBase &b); 157 158 protected: 159 ConfigFileBase(const com::Utf8Str *pstrFilename); 160 ~ConfigFileBase(); 161 162 void parseUUID(com::Guid &guid, 163 const com::Utf8Str &strUUID) const; 164 void parseTimestamp(RTTIMESPEC ×tamp, 165 const com::Utf8Str &str) const; 166 167 com::Utf8Str makeString(const RTTIMESPEC &tm); 168 169 void readExtraData(const xml::ElementNode &elmExtraData, 170 ExtraDataItemsMap &map); 171 void readUSBDeviceFilters(const xml::ElementNode &elmDeviceFilters, 172 USBDeviceFiltersList &ll); 173 typedef enum {Error, HardDisk, DVDImage, FloppyImage} MediaType; 174 void readMedium(MediaType t, const xml::ElementNode &elmMedium, MediaList &llMedia); 175 void readMediaRegistry(const xml::ElementNode &elmMediaRegistry, MediaRegistry &mr); 176 177 void setVersionAttribute(xml::ElementNode &elm); 178 void createStubDocument(); 179 180 void buildExtraData(xml::ElementNode &elmParent, const ExtraDataItemsMap &me); 181 void buildUSBDeviceFilters(xml::ElementNode &elmParent, 182 const USBDeviceFiltersList &ll, 183 bool fHostMode); 184 void buildHardDisk(xml::ElementNode &elmMedium, 185 const Medium &m, 186 uint32_t level); 187 void buildMediaRegistry(xml::ElementNode &elmParent, 188 const MediaRegistry &mr); 189 void clearDocument(); 190 191 struct Data; 192 Data *m; 193 194 private: 195 // prohibit copying (Data contains pointers to XML which cannot be copied) 196 ConfigFileBase(const ConfigFileBase&); 197 198 friend class ConfigFileError; 199 }; 200 159 201 //////////////////////////////////////////////////////////////////////////////// 160 202 // … … 182 224 }; 183 225 184 typedef std::map<com::Utf8Str, com::Utf8Str> PropertiesMap;185 186 struct Medium;187 typedef std::list<Medium> MediaList;188 189 struct Medium190 {191 com::Guid uuid;192 com::Utf8Str strLocation;193 com::Utf8Str strDescription;194 195 // the following are for hard disks only:196 com::Utf8Str strFormat;197 bool fAutoReset; // optional, only for diffs, default is false198 PropertiesMap properties;199 MediumType_T hdType;200 201 MediaList llChildren; // only used with hard disks202 };203 204 226 struct MachineRegistryEntry 205 227 { … … 225 247 MainConfigFile(const com::Utf8Str *pstrFilename); 226 248 227 typedef enum {Error, HardDisk, DVDImage, FloppyImage} MediaType;228 void readMedium(MediaType t, const xml::ElementNode &elmMedium, MediaList &llMedia);229 void readMediaRegistry(const xml::ElementNode &elmMediaRegistry);230 249 void readMachineRegistry(const xml::ElementNode &elmMachineRegistry); 231 250 void readDHCPServers(const xml::ElementNode &elmDHCPServers); 232 251 233 void writeHardDisk(xml::ElementNode &elmMedium,234 const Medium &m,235 uint32_t level);236 252 void write(const com::Utf8Str strFilename); 237 253 238 254 Host host; 239 255 SystemProperties systemProperties; 240 MediaList llHardDisks, 241 llDvdImages, 242 llFloppyImages; 256 MediaRegistry mediaRegistry; 243 257 MachinesRegistry llMachines; 244 258 DHCPServersList llDhcpServers; … … 865 879 Hardware hardwareMachine; 866 880 Storage storageMachine; 881 MediaRegistry mediaRegistry; 867 882 868 883 ExtraDataItemsMap mapExtraDataItems; … … 882 897 BuildMachineXML_IncludeSnapshots = 0x01, 883 898 BuildMachineXML_WriteVboxVersionAttribute = 0x02, 884 BuildMachineXML_SkipRemovableMedia = 0x02 899 BuildMachineXML_SkipRemovableMedia = 0x04, 900 BuildMachineXML_MediaRegistry = 0x08 885 901 }; 886 902 void buildMachineXML(xml::ElementNode &elmMachine,
Note:
See TracChangeset
for help on using the changeset viewer.