VirtualBox

Changeset 26171 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Feb 2, 2010 8:37:36 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
57185
Message:

Main: get rid of Backupable<>::hasActualChanges and the operator== in all the machine data structures which it required; nuke obsolete Shareable.h

Location:
trunk/src/VBox/Main
Files:
1 deleted
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/AudioAdapterImpl.cpp

    r26167 r26171  
    429429 *  @note Locks this object for writing.
    430430 */
    431 bool AudioAdapter::rollback()
     431void AudioAdapter::rollback()
    432432{
    433433    /* sanity */
    434434    AutoCaller autoCaller(this);
    435     AssertComRCReturn (autoCaller.rc(), false);
     435    AssertComRCReturnVoid(autoCaller.rc());
    436436
    437437    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    438438
    439     bool changed = false;
    440 
    441     if (mData.isBackedUp())
    442     {
    443         /* we need to check all data to see whether anything will be changed
    444          * after rollback */
    445         changed = mData.hasActualChanges();
    446         mData.rollback();
    447     }
    448 
    449     return changed;
     439    mData.rollback();
    450440}
    451441
  • trunk/src/VBox/Main/MachineImpl.cpp

    r26167 r26171  
    198198}
    199199
    200 bool Machine::HWData::operator==(const HWData &that) const
    201 {
    202     if (this == &that)
    203         return true;
    204 
    205     if (mHWVersion != that.mHWVersion ||
    206         mHardwareUUID != that.mHardwareUUID ||
    207         mMemorySize != that.mMemorySize ||
    208         mMemoryBalloonSize != that.mMemoryBalloonSize ||
    209         mStatisticsUpdateInterval != that.mStatisticsUpdateInterval ||
    210         mVRAMSize != that.mVRAMSize ||
    211         mFirmwareType != that.mFirmwareType ||
    212         mAccelerate3DEnabled != that.mAccelerate3DEnabled ||
    213         mAccelerate2DVideoEnabled != that.mAccelerate2DVideoEnabled ||
    214         mMonitorCount != that.mMonitorCount ||
    215         mHWVirtExEnabled != that.mHWVirtExEnabled ||
    216         mHWVirtExNestedPagingEnabled != that.mHWVirtExNestedPagingEnabled ||
    217         mHWVirtExVPIDEnabled != that.mHWVirtExVPIDEnabled ||
    218         mHWVirtExExclusive != that.mHWVirtExExclusive ||
    219         mPAEEnabled != that.mPAEEnabled ||
    220         mSyntheticCpu != that.mSyntheticCpu ||
    221         mCPUCount != that.mCPUCount ||
    222         mCPUHotPlugEnabled != that.mCPUHotPlugEnabled ||
    223         mClipboardMode != that.mClipboardMode)
    224         return false;
    225 
    226     for (size_t i = 0; i < RT_ELEMENTS (mBootOrder); ++i)
    227         if (mBootOrder [i] != that.mBootOrder [i])
    228             return false;
    229 
    230 
    231     for (size_t i = 0; i < RT_ELEMENTS(mCPUAttached); i++)
    232     {
    233         if (mCPUAttached[i] != that.mCPUAttached[i])
    234             return false;
    235     }
    236 
    237     if (mSharedFolders.size() != that.mSharedFolders.size())
    238         return false;
    239 
    240     if (mSharedFolders.size() == 0)
    241         return true;
    242 
    243     /* Make copies to speed up comparison */
    244     SharedFolderList folders = mSharedFolders;
    245     SharedFolderList thatFolders = that.mSharedFolders;
    246 
    247     SharedFolderList::iterator it = folders.begin();
    248     while (it != folders.end())
    249     {
    250         bool found = false;
    251         SharedFolderList::iterator thatIt = thatFolders.begin();
    252         while (thatIt != thatFolders.end())
    253         {
    254             if (    (*it)->getName() == (*thatIt)->getName()
    255                  && RTPathCompare(Utf8Str((*it)->getHostPath()).c_str(),
    256                                   Utf8Str((*thatIt)->getHostPath()).c_str()
    257                                  ) == 0)
    258             {
    259                 thatFolders.erase (thatIt);
    260                 found = true;
    261                 break;
    262             }
    263             else
    264                 ++thatIt;
    265         }
    266         if (found)
    267             it = folders.erase (it);
    268         else
    269             return false;
    270     }
    271 
    272     Assert (folders.size() == 0 && thatFolders.size() == 0);
    273 
    274     return true;
    275 }
    276 
    277200/////////////////////////////////////////////////////////////////////////////
    278201// Machine::HDData structure
     
    285208Machine::MediaData::~MediaData()
    286209{
    287 }
    288 
    289 bool Machine::MediaData::operator==(const MediaData &that) const
    290 {
    291     if (this == &that)
    292         return true;
    293 
    294     if (mAttachments.size() != that.mAttachments.size())
    295         return false;
    296 
    297     if (mAttachments.size() == 0)
    298         return true;
    299 
    300     /* Make copies to speed up comparison */
    301     AttachmentList atts = mAttachments;
    302     AttachmentList thatAtts = that.mAttachments;
    303 
    304     AttachmentList::iterator it = atts.begin();
    305     while (it != atts.end())
    306     {
    307         bool found = false;
    308         AttachmentList::iterator thatIt = thatAtts.begin();
    309         while (thatIt != thatAtts.end())
    310         {
    311             if (    (*it)->matches((*thatIt)->getControllerName(),
    312                                    (*thatIt)->getPort(),
    313                                    (*thatIt)->getDevice())
    314                  && (*it)->getPassthrough() == (*thatIt)->getPassthrough()
    315                  && (*it)->getMedium().equalsTo((*thatIt)->getMedium())
    316                )
    317             {
    318                 thatAtts.erase(thatIt);
    319                 found = true;
    320                 break;
    321             }
    322             else
    323                 ++thatIt;
    324         }
    325         if (found)
    326             it = atts.erase (it);
    327         else
    328             return false;
    329     }
    330 
    331     Assert (atts.size() == 0 && thatAtts.size() == 0);
    332 
    333     return true;
    334210}
    335211
     
    83338209    if (m_flModifications & IsModified_NetworkAdapters)
    83348210        for (ULONG slot = 0; slot < RT_ELEMENTS(mNetworkAdapters); slot++)
    8335             if (mNetworkAdapters[slot])
    8336                 if (mNetworkAdapters[slot]->rollback())
    8337                     networkAdapters[slot] = mNetworkAdapters[slot];
     8211            if (    mNetworkAdapters[slot]
     8212                 && mNetworkAdapters[slot]->isModified())
     8213            {
     8214                mNetworkAdapters[slot]->rollback();
     8215                networkAdapters[slot] = mNetworkAdapters[slot];
     8216            }
    83388217
    83398218    if (m_flModifications & IsModified_SerialPorts)
    83408219        for (ULONG slot = 0; slot < RT_ELEMENTS(mSerialPorts); slot++)
    8341             if (mSerialPorts[slot])
    8342                 if (mSerialPorts[slot]->rollback())
    8343                     serialPorts[slot] = mSerialPorts[slot];
     8220            if (    mSerialPorts[slot]
     8221                 && mSerialPorts[slot]->isModified())
     8222            {
     8223                mSerialPorts[slot]->rollback();
     8224                serialPorts[slot] = mSerialPorts[slot];
     8225            }
    83448226
    83458227    if (m_flModifications & IsModified_ParallelPorts)
    83468228        for (ULONG slot = 0; slot < RT_ELEMENTS(mParallelPorts); slot++)
    8347             if (mParallelPorts[slot])
    8348                 if (mParallelPorts[slot]->rollback())
    8349                     parallelPorts[slot] = mParallelPorts[slot];
     8229            if (    mParallelPorts[slot]
     8230                 && mParallelPorts[slot]->isModified())
     8231            {
     8232                mParallelPorts[slot]->rollback();
     8233                parallelPorts[slot] = mParallelPorts[slot];
     8234            }
    83508235
    83518236    if (aNotify)
  • trunk/src/VBox/Main/MediumAttachmentImpl.cpp

    r26167 r26171  
    4444    { }
    4545
    46     bool operator==(const BackupableMediumAttachmentData &that) const
    47     {
    48         return    this == &that
    49                || (fPassthrough == that.fPassthrough);
    50     }
    51 
    5246    ComObjPtr<Medium>   pMedium;
    5347    /* Since MediumAttachment is not a first class citizen when it
     
    282276 *  @note Locks this object for writing.
    283277 */
    284 bool MediumAttachment::rollback()
     278void MediumAttachment::rollback()
    285279{
    286280    LogFlowThisFunc(("ENTER - %s\n", getLogName()));
     
    288282    /* sanity */
    289283    AutoCaller autoCaller(this);
    290     AssertComRCReturn (autoCaller.rc(), false);
     284    AssertComRCReturnVoid(autoCaller.rc());
    291285
    292286    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    293287
    294     bool changed = false;
    295 
    296     if (m->bd.isBackedUp())
    297     {
    298         /* we need to check all data to see whether anything will be changed
    299          * after rollback */
    300         changed = m->bd.hasActualChanges();
    301         m->bd.rollback();
    302     }
    303 
    304     LogFlowThisFunc(("LEAVE - %s - returning %RTbool\n", getLogName(), changed));
    305     return changed;
     288    m->bd.rollback();
     289
     290    LogFlowThisFunc(("LEAVE - %s\n", getLogName()));
    306291}
    307292
  • trunk/src/VBox/Main/NetworkAdapterImpl.cpp

    r26167 r26171  
    11261126
    11271127/**
     1128 * Returns true if any setter method has modified settings of this instance.
     1129 * @return
     1130 */
     1131bool NetworkAdapter::isModified()
     1132{
     1133    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     1134    return m_fModified;
     1135}
     1136
     1137/**
    11281138 *  @note Locks this object for writing.
    11291139 */
    1130 bool NetworkAdapter::rollback()
     1140void NetworkAdapter::rollback()
    11311141{
    11321142    /* sanity */
    11331143    AutoCaller autoCaller(this);
    1134     AssertComRCReturn (autoCaller.rc(), false);
    1135 
    1136     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    1137 
    1138     bool changed = false;
    1139 
    1140     if (mData.isBackedUp())
    1141     {
    1142         /* we need to check all data to see whether anything will be changed
    1143          * after rollback */
    1144         changed = mData.hasActualChanges();
    1145         mData.rollback();
    1146     }
    1147 
    1148     return changed;
     1144    AssertComRCReturnVoid(autoCaller.rc());
     1145
     1146    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     1147
     1148    mData.rollback();
    11491149}
    11501150
  • trunk/src/VBox/Main/ParallelPortImpl.cpp

    r26167 r26171  
    462462
    463463/**
     464 * Returns true if any setter method has modified settings of this instance.
     465 * @return
     466 */
     467bool ParallelPort::isModified()
     468{
     469    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     470    return m->fModified;
     471}
     472
     473/**
    464474 *  @note Locks this object for writing.
    465475 */
    466 bool ParallelPort::rollback()
     476void ParallelPort::rollback()
    467477{
    468478    /* sanity */
    469479    AutoCaller autoCaller(this);
    470     AssertComRCReturn (autoCaller.rc(), false);
     480    AssertComRCReturnVoid(autoCaller.rc());
    471481
    472482    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    473483
    474     bool changed = false;
    475 
    476     if (m->bd.isBackedUp())
    477     {
    478         /* we need to check all data to see whether anything will be changed
    479          * after rollback */
    480         changed = m->bd.hasActualChanges();
    481         m->bd.rollback();
    482     }
    483 
    484     return changed;
     484    m->bd.rollback();
    485485}
    486486
  • trunk/src/VBox/Main/SerialPortImpl.cpp

    r26167 r26171  
    579579
    580580/**
     581 * Returns true if any setter method has modified settings of this instance.
     582 * @return
     583 */
     584bool SerialPort::isModified()
     585{
     586    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     587    return m->fModified;
     588}
     589
     590/**
    581591 *  @note Locks this object for writing.
    582592 */
    583 bool SerialPort::rollback()
     593void SerialPort::rollback()
    584594{
    585595    /* sanity */
    586596    AutoCaller autoCaller(this);
    587     AssertComRCReturn (autoCaller.rc(), false);
    588 
    589     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    590 
    591     bool changed = false;
    592 
    593     if (m->bd.isBackedUp())
    594     {
    595         /* we need to check all data to see whether anything will be changed
    596          * after rollback */
    597         changed = m->bd.hasActualChanges();
    598         m->bd.rollback();
    599     }
    600 
    601     return changed;
     597    AssertComRCReturnVoid(autoCaller.rc());
     598
     599    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     600
     601    m->bd.rollback();
    602602}
    603603
  • trunk/src/VBox/Main/StorageControllerImpl.cpp

    r26167 r26171  
    5454          mPortIde1Slave(3)
    5555    { }
    56 
    57     bool operator==(const BackupableStorageControllerData &that) const
    58     {
    59         return    this == &that
    60                 || (    (mStorageControllerType == that.mStorageControllerType)
    61                     && (strName           == that.strName)
    62                     && (mPortCount   == that.mPortCount)
    63                     && (mPortIde0Master == that.mPortIde0Master)
    64                     && (mPortIde0Slave  == that.mPortIde0Slave)
    65                     && (mPortIde1Master == that.mPortIde1Master)
    66                     && (mPortIde1Slave  == that.mPortIde1Slave));
    67     }
    6856
    6957    /** Unique name of the storage controller. */
     
    718706
    719707/** @note Locks objects for writing! */
    720 bool StorageController::rollback()
    721 {
    722     AutoCaller autoCaller(this);
    723     AssertComRCReturn (autoCaller.rc(), false);
     708void StorageController::rollback()
     709{
     710    AutoCaller autoCaller(this);
     711    AssertComRCReturnVoid(autoCaller.rc());
    724712
    725713    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    726714
    727     bool dataChanged = false;
    728 
    729     if (m->bd.isBackedUp())
    730     {
    731         /* we need to check all data to see whether anything will be changed
    732          * after rollback */
    733         dataChanged = m->bd.hasActualChanges();
    734         m->bd.rollback();
    735     }
    736 
    737     return dataChanged;
     715    m->bd.rollback();
    738716}
    739717
  • trunk/src/VBox/Main/USBControllerImpl.cpp

    r26167 r26171  
    5555          fEnabledEHCI(false)
    5656    { }
    57 
    58     bool operator==(const BackupableUSBData &that) const
    59     {
    60         return this == &that || (fEnabled == that.fEnabled && fEnabledEHCI == that.fEnabledEHCI);
    61     }
    6257
    6358    BOOL fEnabled;
     
    727722
    728723/** @note Locks objects for writing! */
    729 bool USBController::rollback()
    730 {
    731     AutoCaller autoCaller(this);
    732     AssertComRCReturn (autoCaller.rc(), false);
     724void USBController::rollback()
     725{
     726    AutoCaller autoCaller(this);
     727    AssertComRCReturnVoid(autoCaller.rc());
    733728
    734729    /* we need the machine state */
    735730    AutoAnyStateDependency adep(m->pParent);
    736     AssertComRCReturn (adep.rc(), false);
     731    AssertComRCReturnVoid(adep.rc());
    737732
    738733    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    739734
    740     bool dataChanged = false;
    741 
    742     if (m->bd.isBackedUp())
    743     {
    744         /* we need to check all data to see whether anything will be changed
    745          * after rollback */
    746         dataChanged = m->bd.hasActualChanges();
    747         m->bd.rollback();
    748     }
     735    m->bd.rollback();
    749736
    750737#ifdef VBOX_WITH_USB
     
    753740    {
    754741        USBProxyService *service = m->pParent->getVirtualBox()->host()->usbProxyService();
    755         ComAssertRet (service, false);
     742        Assert(service);
    756743
    757744        /* uninitialize all new filters (absent in the backed up list) */
     
    768755                {
    769756                    USBDeviceFilter *filter = *it;
    770                     ComAssertRet(filter->getId() != NULL, false);
     757                    Assert(filter->getId() != NULL);
    771758                    service->removeFilter(filter->getId());
    772759                    filter->getId() = NULL;
     
    792779                    {
    793780                        USBDeviceFilter *flt = *it; /* resolve ambiguity */
    794                         ComAssertRet(flt->getId() == NULL, false);
     781                        Assert(flt->getId() == NULL);
    795782                        flt->getId() = service->insertFilter(&flt->getData().mUSBFilter);
    796783                    }
     
    815802            (*it)->rollback();
    816803            /* call this to notify the USB proxy about changes */
    817             onDeviceFilterChange (*it);
     804            onDeviceFilterChange(*it);
    818805        }
    819         ++ it;
     806        ++it;
    820807    }
    821808
    822809#endif /* VBOX_WITH_USB */
    823 
    824     return dataChanged;
    825810}
    826811
  • trunk/src/VBox/Main/include/AudioAdapterImpl.h

    r26167 r26171  
    4444        Data();
    4545
    46         bool operator== (const Data &that) const
    47         {
    48             return this == &that ||
    49                    (mEnabled == that.mEnabled &&
    50                     mAudioDriver == that.mAudioDriver &&
    51                     mAudioController == that.mAudioController);
    52         }
    53 
    5446        BOOL mEnabled;
    5547        AudioDriverType_T mAudioDriver;
     
    9284    HRESULT saveSettings(settings::AudioAdapter &data);
    9385
    94     bool rollback();
     86    void rollback();
    9587    void commit();
    9688    void copyFrom(AudioAdapter *aThat);
  • trunk/src/VBox/Main/include/MachineImpl.h

    r26167 r26171  
    225225        ~UserData();
    226226
    227         bool operator==(const UserData &that) const
    228         {
    229             return this == &that
    230                 || (   mName                 == that.mName
    231                     && mNameSync             == that.mNameSync
    232                     && mDescription          == that.mDescription
    233                     && mOSTypeId             == that.mOSTypeId
    234                     && mSnapshotFolderFull   == that.mSnapshotFolderFull
    235                     && mTeleporterEnabled    == that.mTeleporterEnabled
    236                     && mTeleporterPort       == that.mTeleporterPort
    237                     && mTeleporterAddress    == that.mTeleporterAddress
    238                     && mTeleporterPassword   == that.mTeleporterPassword
    239                     && mRTCUseUTC            == that.mRTCUseUTC);
    240         }
    241 
    242227        Bstr    mName;
    243228        BOOL    mNameSync;
     
    279264        HWData();
    280265        ~HWData();
    281 
    282         bool operator==(const HWData &that) const;
    283266
    284267        Bstr           mHWVersion;
     
    333316        MediaData();
    334317        ~MediaData();
    335 
    336         bool operator==(const MediaData &that) const;
    337318
    338319        typedef std::list< ComObjPtr<MediumAttachment> > AttachmentList;
  • trunk/src/VBox/Main/include/MediumAttachmentImpl.h

    r26044 r26171  
    6868
    6969    // public internal methods
    70     bool rollback();
     70    void rollback();
    7171    void commit();
    7272
  • trunk/src/VBox/Main/include/NetworkAdapterImpl.h

    r26167 r26171  
    5050                 mNATNetwork("") /* cannot be null */
    5151        {}
    52 
    53         bool operator== (const Data &that) const
    54         {
    55             return this == &that ||
    56                    (mSlot == that.mSlot &&
    57                     mEnabled == that.mEnabled &&
    58                     mMACAddress == that.mMACAddress &&
    59                     mAttachmentType == that.mAttachmentType &&
    60                     mCableConnected == that.mCableConnected &&
    61                     mLineSpeed == that.mLineSpeed &&
    62                     mTraceEnabled == that.mTraceEnabled &&
    63                     mHostInterface == that.mHostInterface &&
    64                     mInternalNetwork == that.mInternalNetwork &&
    65                     mNATNetwork == that.mNATNetwork);
    66         }
    6752
    6853        NetworkAdapterType_T mAdapterType;
     
    139124    HRESULT saveSettings(settings::NetworkAdapter &data);
    140125
    141     bool rollback();
     126    bool isModified();
     127    void rollback();
    142128    void commit();
    143129    void copyFrom (NetworkAdapter *aThat);
  • trunk/src/VBox/Main/include/ParallelPortImpl.h

    r26167 r26171  
    7878    HRESULT saveSettings(settings::ParallelPort &data);
    7979
    80     bool rollback();
     80    bool isModified();
     81    void rollback();
    8182    void commit();
    8283    void copyFrom(ParallelPort *aThat);
  • trunk/src/VBox/Main/include/SerialPortImpl.h

    r26167 r26171  
    8484    HRESULT saveSettings(settings::SerialPort &data);
    8585
    86     bool rollback();
     86    bool isModified();
     87    void rollback();
    8788    void commit();
    8889    void copyFrom(SerialPort *aThat);
  • trunk/src/VBox/Main/include/StorageControllerImpl.h

    r26167 r26171  
    8989    ULONG getInstance() const;
    9090
    91     bool rollback();
     91    void rollback();
    9292    void commit();
    9393
  • trunk/src/VBox/Main/include/USBControllerImpl.h

    r26167 r26171  
    8383    HRESULT saveSettings(settings::USBController &data);
    8484
    85     bool rollback();
     85    void rollback();
    8686    void commit();
    8787    void copyFrom (USBController *aThat);
  • trunk/src/VBox/Main/include/VRDPServerImpl.h

    r26167 r26171  
    4444    struct Data
    4545    {
    46         bool operator== (const Data &that) const
    47         {
    48             return this == &that ||
    49                    (mEnabled == that.mEnabled &&
    50                     mVRDPPorts == that.mVRDPPorts &&
    51                     mVRDPAddress == that.mVRDPAddress &&
    52                     mAuthType == that.mAuthType &&
    53                     mAuthTimeout == that.mAuthTimeout &&
    54                     mAllowMultiConnection == that.mAllowMultiConnection &&
    55                     mReuseSingleConnection == that.mReuseSingleConnection);
    56         }
    57 
    5846        BOOL mEnabled;
    5947        Bstr mVRDPPorts;
     
    11199    HRESULT saveSettings(settings::VRDPSettings &data);
    112100
    113     bool rollback();
     101    void rollback();
    114102    void commit();
    115103    void copyFrom (VRDPServer *aThat);
  • trunk/src/VBox/Main/include/VirtualBoxBase.h

    r26044 r26171  
    16801680    }
    16811681
    1682     bool hasActualChanges() const
    1683     {
    1684         AssertMsg(this->mData, ("data must not be NULL"));
    1685         return this->mData != NULL && mBackupData != NULL &&
    1686                !(*this->mData == *mBackupData);
    1687     }
    1688 
    16891682    D *backedUpData() const
    16901683    {
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette