Changeset 26156 in vbox for trunk/src/VBox/Main/xml/Settings.cpp
- Timestamp:
- Feb 2, 2010 4:30:28 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 57170
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/xml/Settings.cpp
r26043 r26156 147 147 // or SettingsVersion_Null if none 148 148 149 void copyFrom(const Data &d) 150 { 151 strFilename = d.strFilename; 152 fFileExists = d.fFileExists; 153 strSettingsVersionFull = d.strSettingsVersionFull; 154 sv = d.sv; 155 svRead = d.svRead; 156 } 157 149 158 void cleanup() 150 159 { … … 704 713 } 705 714 715 /** 716 * Copies the base variables from another instance. Used by Machine::saveSettings 717 * so that the settings version does not get lost when a copy of the Machine settings 718 * file is made to see if settings have actually changed. 719 * @param b 720 */ 721 void ConfigFileBase::copyBaseFrom(const ConfigFileBase &b) 722 { 723 m->copyFrom(*b.m); 724 } 725 726 //////////////////////////////////////////////////////////////////////////////// 727 // 728 // Structures shared between Machine XML and VirtualBox.xml 729 // 730 //////////////////////////////////////////////////////////////////////////////// 731 732 /** 733 * Comparison operator. This gets called from MachineConfigFile::operator==, 734 * which in turn gets called from Machine::saveSettings to figure out whether 735 * machine settings have really changed and thus need to be written out to disk. 736 */ 737 bool USBDeviceFilter::operator==(const USBDeviceFilter &u) const 738 { 739 return ( (this == &u) 740 || ( (strName == u.strName) 741 && (fActive == u.fActive) 742 && (strVendorId == u.strVendorId) 743 && (strProductId == u.strProductId) 744 && (strRevision == u.strRevision) 745 && (strManufacturer == u.strManufacturer) 746 && (strProduct == u.strProduct) 747 && (strSerialNumber == u.strSerialNumber) 748 && (strPort == u.strPort) 749 && (action == u.action) 750 && (strRemote == u.strRemote) 751 && (ulMaskedInterfaces == u.ulMaskedInterfaces) 752 ) 753 ); 754 } 706 755 707 756 //////////////////////////////////////////////////////////////////////////////// … … 1242 1291 } 1243 1292 1293 //////////////////////////////////////////////////////////////////////////////// 1294 // 1295 // Machine XML structures 1296 // 1297 //////////////////////////////////////////////////////////////////////////////// 1298 1299 /** 1300 * Comparison operator. This gets called from MachineConfigFile::operator==, 1301 * which in turn gets called from Machine::saveSettings to figure out whether 1302 * machine settings have really changed and thus need to be written out to disk. 1303 */ 1304 bool VRDPSettings::operator==(const VRDPSettings& v) const 1305 { 1306 return ( (this == &v) 1307 || ( (fEnabled == v.fEnabled) 1308 && (strPort == v.strPort) 1309 && (strNetAddress == v.strNetAddress) 1310 && (authType == v.authType) 1311 && (ulAuthTimeout == v.ulAuthTimeout) 1312 && (fAllowMultiConnection == v.fAllowMultiConnection) 1313 && (fReuseSingleConnection == v.fReuseSingleConnection) 1314 ) 1315 ); 1316 } 1317 1318 /** 1319 * Comparison operator. This gets called from MachineConfigFile::operator==, 1320 * which in turn gets called from Machine::saveSettings to figure out whether 1321 * machine settings have really changed and thus need to be written out to disk. 1322 */ 1323 bool BIOSSettings::operator==(const BIOSSettings &d) const 1324 { 1325 return ( (this == &d) 1326 || ( fACPIEnabled == d.fACPIEnabled 1327 && fIOAPICEnabled == d.fIOAPICEnabled 1328 && fLogoFadeIn == d.fLogoFadeIn 1329 && fLogoFadeOut == d.fLogoFadeOut 1330 && ulLogoDisplayTime == d.ulLogoDisplayTime 1331 && strLogoImagePath == d.strLogoImagePath 1332 && biosBootMenuMode == d.biosBootMenuMode 1333 && fPXEDebugEnabled == d.fPXEDebugEnabled 1334 && llTimeOffset == d.llTimeOffset) 1335 ); 1336 } 1337 1338 /** 1339 * Comparison operator. This gets called from MachineConfigFile::operator==, 1340 * which in turn gets called from Machine::saveSettings to figure out whether 1341 * machine settings have really changed and thus need to be written out to disk. 1342 */ 1343 bool USBController::operator==(const USBController &u) const 1344 { 1345 return ( (this == &u) 1346 || ( (fEnabled == u.fEnabled) 1347 && (fEnabledEHCI == u.fEnabledEHCI) 1348 && (llDeviceFilters == u.llDeviceFilters) 1349 ) 1350 ); 1351 } 1352 1353 /** 1354 * Comparison operator. This gets called from MachineConfigFile::operator==, 1355 * which in turn gets called from Machine::saveSettings to figure out whether 1356 * machine settings have really changed and thus need to be written out to disk. 1357 */ 1358 bool NetworkAdapter::operator==(const NetworkAdapter &n) const 1359 { 1360 return ( (this == &n) 1361 || ( (ulSlot == n.ulSlot) 1362 && (type == n.type) 1363 && (fEnabled == n.fEnabled) 1364 && (strMACAddress == n.strMACAddress) 1365 && (fCableConnected == n.fCableConnected) 1366 && (ulLineSpeed == n.ulLineSpeed) 1367 && (fTraceEnabled == n.fTraceEnabled) 1368 && (strTraceFile == n.strTraceFile) 1369 && (mode == n.mode) 1370 && (strName == n.strName) 1371 ) 1372 ); 1373 } 1374 1375 /** 1376 * Comparison operator. This gets called from MachineConfigFile::operator==, 1377 * which in turn gets called from Machine::saveSettings to figure out whether 1378 * machine settings have really changed and thus need to be written out to disk. 1379 */ 1380 bool SerialPort::operator==(const SerialPort &s) const 1381 { 1382 return ( (this == &s) 1383 || ( (ulSlot == s.ulSlot) 1384 && (fEnabled == s.fEnabled) 1385 && (ulIOBase == s.ulIOBase) 1386 && (ulIRQ == s.ulIRQ) 1387 && (portMode == s.portMode) 1388 && (strPath == s.strPath) 1389 && (fServer == s.fServer) 1390 ) 1391 ); 1392 } 1393 1394 /** 1395 * Comparison operator. This gets called from MachineConfigFile::operator==, 1396 * which in turn gets called from Machine::saveSettings to figure out whether 1397 * machine settings have really changed and thus need to be written out to disk. 1398 */ 1399 bool ParallelPort::operator==(const ParallelPort &s) const 1400 { 1401 return ( (this == &s) 1402 || ( (ulSlot == s.ulSlot) 1403 && (fEnabled == s.fEnabled) 1404 && (ulIOBase == s.ulIOBase) 1405 && (ulIRQ == s.ulIRQ) 1406 && (strPath == s.strPath) 1407 ) 1408 ); 1409 } 1410 1411 /** 1412 * Comparison operator. This gets called from MachineConfigFile::operator==, 1413 * which in turn gets called from Machine::saveSettings to figure out whether 1414 * machine settings have really changed and thus need to be written out to disk. 1415 */ 1416 bool SharedFolder::operator==(const SharedFolder &g) const 1417 { 1418 return ( (this == &g) 1419 || ( (strName == g.strName) 1420 && (strHostPath == g.strHostPath) 1421 && (fWritable == g.fWritable) 1422 ) 1423 ); 1424 } 1425 1426 /** 1427 * Comparison operator. This gets called from MachineConfigFile::operator==, 1428 * which in turn gets called from Machine::saveSettings to figure out whether 1429 * machine settings have really changed and thus need to be written out to disk. 1430 */ 1431 bool GuestProperty::operator==(const GuestProperty &g) const 1432 { 1433 return ( (this == &g) 1434 || ( (strName == g.strName) 1435 && (strValue == g.strValue) 1436 && (timestamp == g.timestamp) 1437 && (strFlags == g.strFlags) 1438 ) 1439 ); 1440 } 1441 1244 1442 // use a define for the platform-dependent default value of 1245 1443 // hwvirt exclusivity, since we'll need to check that value … … 1285 1483 fPAE = true; 1286 1484 #endif 1485 } 1486 1487 /** 1488 * Comparison operator. This gets called from MachineConfigFile::operator==, 1489 * which in turn gets called from Machine::saveSettings to figure out whether 1490 * machine settings have really changed and thus need to be written out to disk. 1491 */ 1492 bool Hardware::operator==(const Hardware& h) const 1493 { 1494 return ( (this == &h) 1495 || ( (strVersion == h.strVersion) 1496 && (uuid == h.uuid) 1497 && (fHardwareVirt == h.fHardwareVirt) 1498 && (fHardwareVirtExclusive == h.fHardwareVirtExclusive) 1499 && (fNestedPaging == h.fNestedPaging) 1500 && (fVPID == h.fVPID) 1501 && (fSyntheticCpu == h.fSyntheticCpu) 1502 && (fPAE == h.fPAE) 1503 && (cCPUs == h.cCPUs) 1504 && (fCpuHotPlug == h.fCpuHotPlug) 1505 && (llCpus == h.llCpus) 1506 && (llCpuIdLeafs == h.llCpuIdLeafs) 1507 && (ulMemorySizeMB == h.ulMemorySizeMB) 1508 && (mapBootOrder == h.mapBootOrder) 1509 && (ulVRAMSizeMB == h.ulVRAMSizeMB) 1510 && (cMonitors == h.cMonitors) 1511 && (fAccelerate3D == h.fAccelerate3D) 1512 && (fAccelerate2DVideo == h.fAccelerate2DVideo) 1513 && (firmwareType == h.firmwareType) 1514 && (vrdpSettings == h.vrdpSettings) 1515 && (biosSettings == h.biosSettings) 1516 && (usbController == h.usbController) 1517 && (llNetworkAdapters == h.llNetworkAdapters) 1518 && (llSerialPorts == h.llSerialPorts) 1519 && (llParallelPorts == h.llParallelPorts) 1520 && (audioAdapter == h.audioAdapter) 1521 && (llSharedFolders == h.llSharedFolders) 1522 && (clipboardMode == h.clipboardMode) 1523 && (ulMemoryBalloonSize == h.ulMemoryBalloonSize) 1524 && (ulStatisticsUpdateInterval == h.ulStatisticsUpdateInterval) 1525 && (llGuestProperties == h.llGuestProperties) 1526 && (strNotificationPatterns == h.strNotificationPatterns) 1527 ) 1528 ); 1529 } 1530 1531 /** 1532 * Comparison operator. This gets called from MachineConfigFile::operator==, 1533 * which in turn gets called from Machine::saveSettings to figure out whether 1534 * machine settings have really changed and thus need to be written out to disk. 1535 */ 1536 bool AttachedDevice::operator==(const AttachedDevice &a) const 1537 { 1538 return ( (this == &a) 1539 || ( (deviceType == a.deviceType) 1540 && (fPassThrough == a.fPassThrough) 1541 && (lPort == a.lPort) 1542 && (lDevice == a.lDevice) 1543 && (uuid == a.uuid) 1544 && (strHostDriveSrc == a.strHostDriveSrc) 1545 ) 1546 ); 1547 } 1548 1549 /** 1550 * Comparison operator. This gets called from MachineConfigFile::operator==, 1551 * which in turn gets called from Machine::saveSettings to figure out whether 1552 * machine settings have really changed and thus need to be written out to disk. 1553 */ 1554 bool StorageController::operator==(const StorageController &s) const 1555 { 1556 return ( (this == &s) 1557 || ( (strName == s.strName) 1558 && (storageBus == s.storageBus) 1559 && (controllerType == s.controllerType) 1560 && (ulPortCount == s.ulPortCount) 1561 && (ulInstance == s.ulInstance) 1562 && (lIDE0MasterEmulationPort == s.lIDE0MasterEmulationPort) 1563 && (lIDE0SlaveEmulationPort == s.lIDE0SlaveEmulationPort) 1564 && (lIDE1MasterEmulationPort == s.lIDE1MasterEmulationPort) 1565 && (lIDE1SlaveEmulationPort == s.lIDE1SlaveEmulationPort) 1566 && (llAttachedDevices == s.llAttachedDevices) 1567 ) 1568 ); 1569 } 1570 1571 /** 1572 * Comparison operator. This gets called from MachineConfigFile::operator==, 1573 * which in turn gets called from Machine::saveSettings to figure out whether 1574 * machine settings have really changed and thus need to be written out to disk. 1575 */ 1576 bool Storage::operator==(const Storage &s) const 1577 { 1578 return ( (this == &s) 1579 || (llStorageControllers == s.llStorageControllers) // deep compare 1580 ); 1581 } 1582 1583 /** 1584 * Comparison operator. This gets called from MachineConfigFile::operator==, 1585 * which in turn gets called from Machine::saveSettings to figure out whether 1586 * machine settings have really changed and thus need to be written out to disk. 1587 */ 1588 bool Snapshot::operator==(const Snapshot &s) const 1589 { 1590 return ( (this == &s) 1591 || ( (uuid == s.uuid) 1592 && (strName == s.strName) 1593 && (strDescription == s.strDescription) 1594 && (RTTimeSpecIsEqual(×tamp, &s.timestamp)) 1595 && (strStateFile == s.strStateFile) 1596 && (hardware == s.hardware) // deep compare 1597 && (storage == s.storage) // deep compare 1598 && (llChildSnapshots == s.llChildSnapshots) // deep compare 1599 ) 1600 ); 1601 } 1602 1603 //////////////////////////////////////////////////////////////////////////////// 1604 // 1605 // MachineConfigFile 1606 // 1607 //////////////////////////////////////////////////////////////////////////////// 1608 1609 /** 1610 * Constructor. 1611 * 1612 * If pstrFilename is != NULL, this reads the given settings file into the member 1613 * variables and various substructures and lists. Otherwise, the member variables 1614 * are initialized with default values. 1615 * 1616 * Throws variants of xml::Error for I/O, XML and logical content errors, which 1617 * the caller should catch; if this constructor does not throw, then the member 1618 * variables contain meaningful values (either from the file or defaults). 1619 * 1620 * @param strFilename 1621 */ 1622 MachineConfigFile::MachineConfigFile(const Utf8Str *pstrFilename) 1623 : ConfigFileBase(pstrFilename), 1624 fNameSync(true), 1625 fTeleporterEnabled(false), 1626 uTeleporterPort(0), 1627 fRTCUseUTC(false), 1628 fCurrentStateModified(true), 1629 fAborted(false) 1630 { 1631 RTTimeNow(&timeLastStateChange); 1632 1633 if (pstrFilename) 1634 { 1635 // the ConfigFileBase constructor has loaded the XML file, so now 1636 // we need only analyze what is in there 1637 1638 xml::NodesLoop nlRootChildren(*m->pelmRoot); 1639 const xml::ElementNode *pelmRootChild; 1640 while ((pelmRootChild = nlRootChildren.forAllNodes())) 1641 { 1642 if (pelmRootChild->nameEquals("Machine")) 1643 readMachine(*pelmRootChild); 1644 } 1645 1646 // clean up memory allocated by XML engine 1647 clearDocument(); 1648 } 1649 } 1650 1651 /** 1652 * Comparison operator. This gets called from Machine::saveSettings to figure out 1653 * whether machine settings have really changed and thus need to be written out to disk. 1654 * 1655 * Even though this is called operator==, this does NOT compare all fields; the "equals" 1656 * should be understood as "has the same machine config as". The following fields are 1657 * NOT compared: 1658 * -- settings versions and file names inherited from ConfigFileBase; 1659 * -- fCurrentStateModified because that is considered separately in Machine::saveSettings!! 1660 * 1661 * The "deep" comparisons marked below will invoke the operator== functions of the 1662 * structs defined in this file, which may in turn go into comparing lists of 1663 * other structures. As a result, invoking this can be expensive, but it's 1664 * less expensive than writing out XML to disk. 1665 */ 1666 bool MachineConfigFile::operator==(const MachineConfigFile &c) const 1667 { 1668 return ( (this == &c) 1669 || ( (uuid == c.uuid) 1670 && (strName == c.strName) 1671 && (fNameSync == c.fNameSync) 1672 && (strDescription == c.strDescription) 1673 && (strOsType == c.strOsType) 1674 && (strStateFile == c.strStateFile) 1675 && (uuidCurrentSnapshot == c.uuidCurrentSnapshot) 1676 && (strSnapshotFolder == c.strSnapshotFolder) 1677 && (fTeleporterEnabled == c.fTeleporterEnabled) 1678 && (uTeleporterPort == c.uTeleporterPort) 1679 && (strTeleporterAddress == c.strTeleporterAddress) 1680 && (strTeleporterPassword == c.strTeleporterPassword) 1681 && (fRTCUseUTC == c.fRTCUseUTC) 1682 // skip fCurrentStateModified! 1683 && (RTTimeSpecIsEqual(&timeLastStateChange, &c.timeLastStateChange)) 1684 && (fAborted == c.fAborted) 1685 && (hardwareMachine == c.hardwareMachine) // this one's deep 1686 && (storageMachine == c.storageMachine) // this one's deep 1687 && (mapExtraDataItems == c.mapExtraDataItems) // this one's deep 1688 && (llFirstSnapshot == c.llFirstSnapshot) // this one's deep 1689 ) 1690 ); 1287 1691 } 1288 1692 … … 2417 2821 } 2418 2822 2419 ////////////////////////////////////////////////////////////////////////////////2420 //2421 // MachineConfigFile2422 //2423 ////////////////////////////////////////////////////////////////////////////////2424 2425 /**2426 * Constructor.2427 *2428 * If pstrFilename is != NULL, this reads the given settings file into the member2429 * variables and various substructures and lists. Otherwise, the member variables2430 * are initialized with default values.2431 *2432 * Throws variants of xml::Error for I/O, XML and logical content errors, which2433 * the caller should catch; if this constructor does not throw, then the member2434 * variables contain meaningful values (either from the file or defaults).2435 *2436 * @param strFilename2437 */2438 MachineConfigFile::MachineConfigFile(const Utf8Str *pstrFilename)2439 : ConfigFileBase(pstrFilename),2440 fNameSync(true),2441 fTeleporterEnabled(false),2442 uTeleporterPort(0),2443 fRTCUseUTC(false),2444 fCurrentStateModified(true),2445 fAborted(false)2446 {2447 RTTimeNow(&timeLastStateChange);2448 2449 if (pstrFilename)2450 {2451 // the ConfigFileBase constructor has loaded the XML file, so now2452 // we need only analyze what is in there2453 2454 xml::NodesLoop nlRootChildren(*m->pelmRoot);2455 const xml::ElementNode *pelmRootChild;2456 while ((pelmRootChild = nlRootChildren.forAllNodes()))2457 {2458 if (pelmRootChild->nameEquals("Machine"))2459 readMachine(*pelmRootChild);2460 }2461 2462 // clean up memory allocated by XML engine2463 clearDocument();2464 }2465 }2466 2467 2823 /** 2468 2824 * Creates a <Hardware> node under elmParent and then writes out the XML
Note:
See TracChangeset
for help on using the changeset viewer.