VirtualBox

Ignore:
Timestamp:
Dec 14, 2007 7:23:03 PM (17 years ago)
Author:
vboxsync
Message:

Merged dmik/s2 branch (r25959:26751) to the trunk.

File:
1 edited

Legend:

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

    r5999 r6076  
    161161
    162162/**
     163 *  Loads settings from the given port node.
     164 *  May be called once right after this object creation.
     165 *
     166 *  @param aPortNode <Port> node.
     167 *
     168 *  @note Locks this object for writing.
     169 */
     170HRESULT ParallelPort::loadSettings (const settings::Key &aPortNode)
     171{
     172    using namespace settings;
     173
     174    AssertReturn (!aPortNode.isNull(), E_FAIL);
     175
     176    AutoCaller autoCaller (this);
     177    AssertComRCReturnRC (autoCaller.rc());
     178
     179    AutoLock alock (this);
     180
     181    /* Note: we assume that the default values for attributes of optional
     182     * nodes are assigned in the Data::Data() constructor and don't do it
     183     * here. It implies that this method may only be called after constructing
     184     * a new BIOSSettings object while all its data fields are in the default
     185     * values. Exceptions are fields whose creation time defaults don't match
     186     * values that should be applied when these fields are not explicitly set
     187     * in the settings file (for backwards compatibility reasons). This takes
     188     * place when a setting of a newly created object must default to A while
     189     * the same setting of an object loaded from the old settings file must
     190     * default to B. */
     191
     192    /* enabled (required) */
     193    mData->mEnabled = aPortNode.value <bool> ("enabled");
     194    /* I/O base (required) */
     195    mData->mIOBase = aPortNode.value <ULONG> ("IOBase");
     196    /* IRQ (required) */
     197    mData->mIRQ = aPortNode.value <ULONG> ("IRQ");
     198    /* device path (may be null) */
     199    /// @todo report an error if enabled is true and path is empty or null!
     200    //  The same applies to COMSETTER(Path).
     201    mData->mPath = aPortNode.stringValue ("path");
     202
     203    return S_OK;
     204}
     205
     206/**
     207 *  Saves settings to the given port node.
     208 *
     209 *  Note that the given Port node is comletely empty on input.
     210 *
     211 *  @param aPortNode <Port> node.
     212 *
     213 *  @note Locks this object for reading.
     214 */
     215HRESULT ParallelPort::saveSettings (settings::Key &aPortNode)
     216{
     217    using namespace settings;
     218
     219    AssertReturn (!aPortNode.isNull(), E_FAIL);
     220
     221    AutoCaller autoCaller (this);
     222    AssertComRCReturnRC (autoCaller.rc());
     223
     224    AutoReaderLock alock (this);
     225
     226    aPortNode.setValue <bool> ("enabled", !!mData->mEnabled);
     227    aPortNode.setValue <ULONG> ("IOBase", mData->mIOBase, 16);
     228    aPortNode.setValue <ULONG> ("IRQ", mData->mIRQ);
     229
     230    /* 'path' is optional in XML */
     231    if (!mData->mPath.isEmpty())
     232        aPortNode.setValue <Bstr> ("path", mData->mPath);
     233
     234    return S_OK;
     235}
     236
     237/**
    163238 *  @note Locks this object for writing.
    164239 */
     
    233308    /* this will back up current data */
    234309    mData.assignCopy (aThat->mData);
    235 }
    236 
    237 HRESULT ParallelPort::loadSettings (CFGNODE aNode, ULONG aSlot)
    238 {
    239     LogFlowThisFunc (("aMachine=%p\n", aNode));
    240 
    241     AssertReturn (aNode, E_FAIL);
    242 
    243     AutoCaller autoCaller (this);
    244     AssertComRCReturnRC (autoCaller.rc());
    245 
    246     AutoLock alock (this);
    247 
    248     CFGNODE portNode = NULL;
    249     CFGLDRGetChildNode (aNode, "Port", aSlot, &portNode);
    250 
    251     /* slot number (required) */
    252     /* slot unicity is guaranteed by XML Schema */
    253     uint32_t uSlot = 0;
    254     CFGLDRQueryUInt32 (portNode, "slot", &uSlot);
    255     /* enabled (required) */
    256     bool fEnabled = false;
    257     CFGLDRQueryBool (portNode, "enabled", &fEnabled);
    258     /* I/O base (required) */
    259     uint32_t uIOBase;
    260     CFGLDRQueryUInt32 (portNode, "IOBase", &uIOBase);
    261     /* IRQ (required) */
    262     uint32_t uIRQ;
    263     CFGLDRQueryUInt32 (portNode, "IRQ", &uIRQ);
    264     /* device path */
    265     Bstr path;
    266     CFGLDRQueryBSTR   (portNode, "path", path.asOutParam());
    267 
    268     mData->mEnabled = fEnabled;
    269     mData->mSlot    = uSlot;
    270     mData->mIOBase  = uIOBase;
    271     mData->mIRQ     = uIRQ;
    272     mData->mPath    = path;
    273 
    274     return S_OK;
    275 }
    276 
    277 /**
    278  *  Saves the port settings to the given <Port> node.
    279  *
    280  *  Note that the given node is always empty so it is not necessary to delete
    281  *  old values.
    282  *
    283  *  @param aNode Node to save the settings to.
    284  *
    285  *  @return
    286  */
    287 HRESULT ParallelPort::saveSettings (CFGNODE aNode)
    288 {
    289     AssertReturn (aNode, E_FAIL);
    290 
    291     AutoCaller autoCaller (this);
    292     CheckComRCReturnRC (autoCaller.rc());
    293 
    294     AutoReaderLock alock (this);
    295 
    296     CFGNODE portNode = 0;
    297     int vrc = CFGLDRAppendChildNode (aNode, "Port", &portNode);
    298     ComAssertRCRet (vrc, E_FAIL);
    299 
    300     CFGLDRSetUInt32   (portNode, "slot",    mData->mSlot);
    301     CFGLDRSetBool     (portNode, "enabled", !!mData->mEnabled);
    302     CFGLDRSetUInt32Ex (portNode, "IOBase",  mData->mIOBase, 16);
    303     CFGLDRSetUInt32   (portNode, "IRQ",     mData->mIRQ);
    304 
    305     /* 'path' is optional in XML */
    306     if (!mData->mPath.isEmpty())
    307         CFGLDRSetBSTR (portNode, "path", mData->mPath);
    308 
    309     return S_OK;
    310310}
    311311
Note: See TracChangeset for help on using the changeset viewer.

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