VirtualBox

Changeset 29028 in vbox


Ignore:
Timestamp:
May 4, 2010 2:33:45 PM (15 years ago)
Author:
vboxsync
Message:

Main/Medium: New API method for directly querying the MediumFormat object associated with a medium object. Getting the backend name and then use the list of all medium format objects to find it is lots of work and quite inefficient.

Location:
trunk/src/VBox/Main
Files:
3 edited

Legend:

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

    r28888 r29028  
    989989    m->devType = aDeviceType;
    990990
    991     LogFlowThisFunc(("m->locationFull='%s', m->format=%s, m->id={%RTuuid}\n",
     991    LogFlowThisFunc(("m->strLocationFull='%s', m->strFormat=%s, m->id={%RTuuid}\n",
    992992                     m->strLocationFull.raw(), m->strFormat.raw(), m->id.raw()));
    993993
     
    13461346    if (FAILED(autoCaller.rc())) return autoCaller.rc();
    13471347
    1348     /* no need to lock, m->format is const */
     1348    /* no need to lock, m->strFormat is const */
    13491349    m->strFormat.cloneTo(aFormat);
     1350
     1351    return S_OK;
     1352}
     1353
     1354STDMETHODIMP Medium::COMGETTER(MediumFormat)(IMediumFormat **aMediumFormat)
     1355{
     1356    CheckComArgOutPointerValid(aMediumFormat);
     1357
     1358    AutoCaller autoCaller(this);
     1359    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     1360
     1361    /* no need to lock, m->formatObj is const */
     1362    m->formatObj.queryInterfaceTo(aMediumFormat);
    13501363
    13511364    return S_OK;
     
    25782591
    25792592/**
    2580  * Internal method to return the medium's format. Must have caller + locking!
     2593 * Internal method to return the medium's format string. Must have caller + locking!
    25812594 * @return
    25822595 */
     
    25842597{
    25852598    return m->strFormat;
     2599}
     2600
     2601/**
     2602 * Internal method to return the medium's format object. Must have caller + locking!
     2603 * @return
     2604 */
     2605const ComObjPtr<MediumFormat> & Medium::getMediumFormat() const
     2606{
     2607    return m->formatObj;
    25862608}
    25872609
     
    31593181    AssertComRCReturn(autoCaller.rc(), strFormat);
    31603182
    3161     /* m->format is const, no need to lock */
     3183    /* m->strFormat is const, no need to lock */
    31623184    strFormat = m->strFormat;
    31633185
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r28959 r29028  
    93589358  <interface
    93599359    name="IMedium" extends="$unknown"
    9360     uuid="d709160c-303f-4ead-b7ef-53ffa26aa861"
     9360    uuid="1d578f43-5ef1-4415-b556-7592d3ccdc8f"
    93619361    wsmap="managed"
    93629362  >
     
    98209820        installation can be obtained using
    98219821        <link to="ISystemProperties::mediumFormats"/>.
     9822      </desc>
     9823    </attribute>
     9824
     9825    <attribute name="mediumFormat" type="IMediumFormat" readonly="yes">
     9826      <desc>
     9827        Storage medium format object corresponding to this medium.
     9828
     9829        The value of this attribute is a reference to the medium format object
     9830        that specifies the backend properties used to store medium data. The
     9831        storage format is defined when you create a new medium or automatically
     9832        detected when you open an existing medium, and cannot be changed later.
     9833
     9834        <note>@c null is returned if there is no associated medium format
     9835        object. This can e.g. happen for medium objects representing host
     9836        drives and other special medium objects.</note>
    98229837      </desc>
    98239838    </attribute>
  • trunk/src/VBox/Main/include/MediumImpl.h

    r28872 r29028  
    2525
    2626class Progress;
     27class MediumFormat;
    2728
    2829namespace settings
     
    105106    STDMETHOD(COMGETTER(Size))(ULONG64 *aSize);
    106107    STDMETHOD(COMGETTER(Format))(BSTR *aFormat);
     108    STDMETHOD(COMGETTER(MediumFormat))(IMediumFormat **aMediumFormat);
    107109    STDMETHOD(COMGETTER(Type))(MediumType_T *aType);
    108110    STDMETHOD(COMSETTER(Type))(MediumType_T aType);
     
    158160    const Utf8Str& getLocationFull() const;
    159161    const Utf8Str& getFormat() const;
     162    const ComObjPtr<MediumFormat> & getMediumFormat() const;
    160163    uint64_t getSize() const;
    161164    MediumType_T getType() const;
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