VirtualBox

Changeset 13659 in vbox


Ignore:
Timestamp:
Oct 29, 2008 3:45:03 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
38602
Message:

Main: Moved last USB classes to the new locking scheme.

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

Legend:

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

    r8155 r13659  
     1/* $Id$ */
     2
    13/** @file
    24 *
     
    68
    79/*
    8  * Copyright (C) 2006-2007 Sun Microsystems, Inc.
     10 * Copyright (C) 2006-2008 Sun Microsystems, Inc.
    911 *
    1012 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2628#include <VBox/err.h>
    2729
     30#include <VBox/vrdpapi.h>
    2831#include <VBox/vrdpusb.h>
    2932
     
    4043void RemoteUSBDevice::FinalRelease()
    4144{
    42     if (isReady())
    43         uninit();
     45    uninit();
    4446}
    4547
     
    5456HRESULT RemoteUSBDevice::init (uint32_t u32ClientId, VRDPUSBDEVICEDESC *pDevDesc)
    5557{
    56     LogFlowMember (("RemoteUSBDevice::init()\n"));
    57 
    58     AutoWriteLock alock (this);
    59     ComAssertRet (!isReady(), E_UNEXPECTED);
    60 
    61     mId.create();
    62 
    63     mVendorId     = pDevDesc->idVendor;
    64     mProductId    = pDevDesc->idProduct;
    65     mRevision     = pDevDesc->bcdRev;
    66 
    67     mManufacturer = pDevDesc->oManufacturer? (char *)pDevDesc + pDevDesc->oManufacturer: "";
    68     mProduct      = pDevDesc->oProduct? (char *)pDevDesc + pDevDesc->oProduct: "";
    69     mSerialNumber = pDevDesc->oSerialNumber? (char *)pDevDesc + pDevDesc->oSerialNumber: "";
     58    LogFlowThisFunc (("u32ClientId=%d,pDevDesc=%p\n", u32ClientId, pDevDesc));
     59
     60    /* Enclose the state transition NotReady->InInit->Ready */
     61    AutoInitSpan autoInitSpan (this);
     62    AssertReturn (autoInitSpan.isOk(), E_UNEXPECTED);
     63
     64    unconst (mData.id).create();
     65
     66    unconst (mData.vendorId)     = pDevDesc->idVendor;
     67    unconst (mData.productId)    = pDevDesc->idProduct;
     68    unconst (mData.revision)     = pDevDesc->bcdRev;
     69
     70    unconst (mData.manufacturer) = pDevDesc->oManufacturer? (char *)pDevDesc + pDevDesc->oManufacturer: "";
     71    unconst (mData.product)      = pDevDesc->oProduct? (char *)pDevDesc + pDevDesc->oProduct: "";
     72    unconst (mData.serialNumber) = pDevDesc->oSerialNumber? (char *)pDevDesc + pDevDesc->oSerialNumber: "";
    7073
    7174    char id[64];
    7275    RTStrPrintf(id, sizeof (id), REMOTE_USB_BACKEND_PREFIX_S "0x%08X&0x%08X", pDevDesc->id, u32ClientId);
    73     mAddress      = id;
    74 
    75     mPort         = pDevDesc->idPort;
    76     mVersion      = pDevDesc->bcdUSB >> 8;
    77     mPortVersion  = mVersion; /** @todo fix this */
    78 
    79     mState        = USBDeviceState_Available;
    80 
    81     mDirty        = false;
    82     mDevId        = pDevDesc->id;
    83 
    84     mClientId     = u32ClientId;
    85 
    86     setReady (true);
     76    unconst (mData.address)      = id;
     77
     78    unconst (mData.port)         = pDevDesc->idPort;
     79    unconst (mData.version)      = pDevDesc->bcdUSB >> 8;
     80    unconst (mData.portVersion)  = mData.version; /** @todo fix this */
     81
     82    mData.state                  = USBDeviceState_Available;
     83
     84    mData.dirty                  = false;
     85    unconst (mData.devId)        = pDevDesc->id;
     86
     87    unconst (mData.clientId)     = u32ClientId;
     88
     89    /* Confirm a successful initialization */
     90    autoInitSpan.setSucceeded();
     91
    8792    return S_OK;
    8893}
     
    95100void RemoteUSBDevice::uninit()
    96101{
    97     LogFlowMember (("RemoteUSBDevice::uninit()\n"));
    98 
    99     AutoWriteLock alock (this);
    100     AssertReturn (isReady(), (void) 0);
    101 
    102     setReady (false);
     102    LogFlowThisFunc (("\n"));
     103
     104    /* Enclose the state transition Ready->InUninit->NotReady */
     105    AutoUninitSpan autoUninitSpan (this);
     106    if (autoUninitSpan.uninitDone())
     107        return;
     108
     109    unconst (mData.id).clear();
     110
     111    unconst (mData.vendorId) = 0;
     112    unconst (mData.productId) = 0;
     113    unconst (mData.revision) = 0;
     114
     115    unconst (mData.manufacturer).setNull();
     116    unconst (mData.product).setNull();
     117    unconst (mData.serialNumber).setNull();
     118
     119    unconst (mData.address).setNull();
     120
     121    unconst (mData.port) = 0;
     122    unconst (mData.version) = 1;
     123    unconst (mData.portVersion) = 1;
     124
     125    unconst (mData.dirty) = FALSE;
     126
     127    unconst (mData.devId) = 0;
     128    unconst (mData.clientId) = 0;
    103129}
    104130
     
    111137        return E_INVALIDARG;
    112138
    113     AutoWriteLock alock (this);
    114     CHECK_READY();
    115 
    116     mId.cloneTo (aId);
     139    AutoCaller autoCaller (this);
     140    CheckComRCReturnRC (autoCaller.rc());
     141
     142    /* this is const, no need to lock */
     143    mData.id.cloneTo (aId);
     144
    117145    return S_OK;
    118146}
     
    123151        return E_INVALIDARG;
    124152
    125     AutoWriteLock alock (this);
    126     CHECK_READY();
    127 
    128     *aVendorId = mVendorId;
     153    AutoCaller autoCaller (this);
     154    CheckComRCReturnRC (autoCaller.rc());
     155
     156    /* this is const, no need to lock */
     157    *aVendorId = mData.vendorId;
     158
    129159    return S_OK;
    130160}
     
    135165        return E_INVALIDARG;
    136166
    137     AutoWriteLock alock (this);
    138     CHECK_READY();
    139 
    140     *aProductId = mProductId;
     167    AutoCaller autoCaller (this);
     168    CheckComRCReturnRC (autoCaller.rc());
     169
     170    /* this is const, no need to lock */
     171    *aProductId = mData.productId;
     172
    141173    return S_OK;
    142174}
     
    147179        return E_INVALIDARG;
    148180
    149     AutoWriteLock alock (this);
    150     CHECK_READY();
    151 
    152     *aRevision = mRevision;
     181    AutoCaller autoCaller (this);
     182    CheckComRCReturnRC (autoCaller.rc());
     183
     184    /* this is const, no need to lock */
     185    *aRevision = mData.revision;
     186
    153187    return S_OK;
    154188}
     
    159193        return E_INVALIDARG;
    160194
    161     AutoWriteLock alock (this);
    162     CHECK_READY();
    163 
    164     mManufacturer.cloneTo (aManufacturer);
     195    AutoCaller autoCaller (this);
     196    CheckComRCReturnRC (autoCaller.rc());
     197
     198    /* this is const, no need to lock */
     199    mData.manufacturer.cloneTo (aManufacturer);
     200
    165201    return S_OK;
    166202}
     
    171207        return E_INVALIDARG;
    172208
    173     AutoWriteLock alock (this);
    174     CHECK_READY();
    175 
    176     mProduct.cloneTo (aProduct);
     209    AutoCaller autoCaller (this);
     210    CheckComRCReturnRC (autoCaller.rc());
     211
     212    /* this is const, no need to lock */
     213    mData.product.cloneTo (aProduct);
     214
    177215    return S_OK;
    178216}
     
    183221        return E_INVALIDARG;
    184222
    185     AutoWriteLock alock (this);
    186     CHECK_READY();
    187 
    188     mSerialNumber.cloneTo (aSerialNumber);
     223    AutoCaller autoCaller (this);
     224    CheckComRCReturnRC (autoCaller.rc());
     225
     226    /* this is const, no need to lock */
     227    mData.serialNumber.cloneTo (aSerialNumber);
     228
    189229    return S_OK;
    190230}
     
    195235        return E_INVALIDARG;
    196236
    197     AutoWriteLock alock (this);
    198     CHECK_READY();
    199 
    200     mAddress.cloneTo (aAddress);
     237    AutoCaller autoCaller (this);
     238    CheckComRCReturnRC (autoCaller.rc());
     239
     240    /* this is const, no need to lock */
     241    mData.address.cloneTo (aAddress);
     242
    201243    return S_OK;
    202244}
     
    207249        return E_INVALIDARG;
    208250
    209     AutoWriteLock alock (this);
    210     CHECK_READY();
    211 
    212     *aPort = mPort;
     251    AutoCaller autoCaller (this);
     252    CheckComRCReturnRC (autoCaller.rc());
     253
     254    /* this is const, no need to lock */
     255    *aPort = mData.port;
     256
    213257    return S_OK;
    214258}
     
    219263        return E_INVALIDARG;
    220264
    221     AutoWriteLock alock (this);
    222     CHECK_READY();
    223 
    224     *aVersion = mVersion;
     265    AutoCaller autoCaller (this);
     266    CheckComRCReturnRC (autoCaller.rc());
     267
     268    /* this is const, no need to lock */
     269    *aVersion = mData.version;
     270
    225271    return S_OK;
    226272}
     
    231277        return E_INVALIDARG;
    232278
    233     AutoWriteLock alock (this);
    234     CHECK_READY();
    235 
    236     *aPortVersion = mPortVersion;
     279    AutoCaller autoCaller (this);
     280    CheckComRCReturnRC (autoCaller.rc());
     281
     282    /* this is const, no need to lock */
     283    *aPortVersion = mData.portVersion;
     284
    237285    return S_OK;
    238286}
     
    243291        return E_INVALIDARG;
    244292
    245     AutoWriteLock alock (this);
    246     CHECK_READY();
     293    AutoCaller autoCaller (this);
     294    CheckComRCReturnRC (autoCaller.rc());
    247295
    248296    /* RemoteUSBDevice is always remote. */
     297    /* this is const, no need to lock */
    249298    *aRemote = TRUE;
     299
    250300    return S_OK;
    251301}
     
    259309        return E_POINTER;
    260310
    261     AutoWriteLock alock (this);
    262     CHECK_READY();
    263 
    264     *aState = mState;
     311    AutoCaller autoCaller (this);
     312    CheckComRCReturnRC (autoCaller.rc());
     313
     314    AutoReadLock alock (this);
     315
     316    *aState = mData.state;
     317
    265318    return S_OK;
    266319}
  • trunk/src/VBox/Main/USBDeviceImpl.cpp

    r8155 r13659  
     1/* $Id$ */
     2
    13/** @file
    24 *
     
    57
    68/*
    7  * Copyright (C) 2006-2007 Sun Microsystems, Inc.
     9 * Copyright (C) 2006-2008 Sun Microsystems, Inc.
    810 *
    911 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2628/////////////////////////////////////////////////////////////////////////////
    2729
    28 OUSBDevice::OUSBDevice()
    29 {
    30     mVendorId = 0;
    31     mProductId = 0;
    32     mRevision = 0;
    33 
    34     mPort = 0;
    35     mVersion = mPortVersion = 1;
    36     mRemote = FALSE;
    37 }
    38 
    39 OUSBDevice::~OUSBDevice()
    40 {
    41 }
    42 
     30DEFINE_EMPTY_CTOR_DTOR (OUSBDevice)
     31
     32HRESULT OUSBDevice::FinalConstruct()
     33{
     34    return S_OK;
     35}
     36
     37void OUSBDevice::FinalRelease()
     38{
     39    uninit ();
     40}
    4341
    4442// public initializer/uninitializer for internal purposes only
     
    5351HRESULT OUSBDevice::init(IUSBDevice *aUSBDevice)
    5452{
    55     AutoWriteLock alock (this);
    56     AssertReturn (!isReady(), E_UNEXPECTED);
    57 
    58     HRESULT hrc = aUSBDevice->COMGETTER(VendorId)(&mVendorId);
    59     ComAssertComRCRet (hrc, hrc);
    60     ComAssertRet (mVendorId, E_INVALIDARG);
    61 
    62     hrc = aUSBDevice->COMGETTER(ProductId)(&mProductId);
    63     ComAssertComRCRet (hrc, hrc);
    64     ComAssertRet (mProductId, E_INVALIDARG);
    65 
    66     hrc = aUSBDevice->COMGETTER(Revision)(&mRevision);
    67     ComAssertComRCRet (hrc, hrc);
    68 
    69     hrc = aUSBDevice->COMGETTER(Manufacturer)(mManufacturer.asOutParam());
    70     ComAssertComRCRet (hrc, hrc);
    71 
    72     hrc = aUSBDevice->COMGETTER(Product)(mProduct.asOutParam());
    73     ComAssertComRCRet (hrc, hrc);
    74 
    75     hrc = aUSBDevice->COMGETTER(SerialNumber)(mSerialNumber.asOutParam());
    76     ComAssertComRCRet (hrc, hrc);
    77 
    78     hrc = aUSBDevice->COMGETTER(Address)(mAddress.asOutParam());
    79     ComAssertComRCRet (hrc, hrc);
    80 
    81     hrc = aUSBDevice->COMGETTER(Port)(&mPort);
    82     ComAssertComRCRet (hrc, hrc);
    83 
    84     hrc = aUSBDevice->COMGETTER(Port)(&mVersion);
    85     ComAssertComRCRet (hrc, hrc);
    86 
    87     hrc = aUSBDevice->COMGETTER(Port)(&mPortVersion);
    88     ComAssertComRCRet (hrc, hrc);
    89 
    90     hrc = aUSBDevice->COMGETTER(Remote)(&mRemote);
    91     ComAssertComRCRet (hrc, hrc);
    92 
    93     hrc = aUSBDevice->COMGETTER(Id)(mId.asOutParam());
    94     ComAssertComRCRet (hrc, hrc);
    95 
    96     setReady(true);
    97     return S_OK;
    98 }
    99 
     53    LogFlowThisFunc (("aUSBDevice=%p\n", aUSBDevice));
     54
     55    ComAssertRet (aUSBDevice, E_INVALIDARG);
     56
     57    /* Enclose the state transition NotReady->InInit->Ready */
     58    AutoInitSpan autoInitSpan (this);
     59    AssertReturn (autoInitSpan.isOk(), E_UNEXPECTED);
     60
     61    HRESULT hrc = aUSBDevice->COMGETTER(VendorId)(&unconst (mData.vendorId));
     62    ComAssertComRCRet (hrc, hrc);
     63    ComAssertRet (mData.vendorId, E_INVALIDARG);
     64
     65    hrc = aUSBDevice->COMGETTER(ProductId)(&unconst (mData.productId));
     66    ComAssertComRCRet (hrc, hrc);
     67    ComAssertRet (mData.productId, E_INVALIDARG);
     68
     69    hrc = aUSBDevice->COMGETTER(Revision)(&unconst (mData.revision));
     70    ComAssertComRCRet (hrc, hrc);
     71
     72    hrc = aUSBDevice->COMGETTER(Manufacturer)(unconst (mData.manufacturer).asOutParam());
     73    ComAssertComRCRet (hrc, hrc);
     74
     75    hrc = aUSBDevice->COMGETTER(Product)(unconst (mData.product).asOutParam());
     76    ComAssertComRCRet (hrc, hrc);
     77
     78    hrc = aUSBDevice->COMGETTER(SerialNumber)(unconst (mData.serialNumber).asOutParam());
     79    ComAssertComRCRet (hrc, hrc);
     80
     81    hrc = aUSBDevice->COMGETTER(Address)(unconst (mData.address).asOutParam());
     82    ComAssertComRCRet (hrc, hrc);
     83
     84    hrc = aUSBDevice->COMGETTER(Port)(&unconst (mData.port));
     85    ComAssertComRCRet (hrc, hrc);
     86
     87    hrc = aUSBDevice->COMGETTER(Port)(&unconst (mData.version));
     88    ComAssertComRCRet (hrc, hrc);
     89
     90    hrc = aUSBDevice->COMGETTER(Port)(&unconst (mData.portVersion));
     91    ComAssertComRCRet (hrc, hrc);
     92
     93    hrc = aUSBDevice->COMGETTER(Remote)(&unconst (mData.remote));
     94    ComAssertComRCRet (hrc, hrc);
     95
     96    hrc = aUSBDevice->COMGETTER(Id)(unconst (mData.id).asOutParam());
     97    ComAssertComRCRet (hrc, hrc);
     98
     99    /* Confirm a successful initialization */
     100    autoInitSpan.setSucceeded();
     101
     102    return S_OK;
     103}
     104
     105/**
     106 *  Uninitializes the instance and sets the ready flag to FALSE.
     107 *  Called either from FinalRelease() or by the parent when it gets destroyed.
     108 */
     109void OUSBDevice::uninit()
     110{
     111    LogFlowThisFunc (("\n"));
     112
     113    /* Enclose the state transition Ready->InUninit->NotReady */
     114    AutoUninitSpan autoUninitSpan (this);
     115    if (autoUninitSpan.uninitDone())
     116        return;
     117
     118    unconst (mData.id).clear();
     119
     120    unconst (mData.vendorId) = 0;
     121    unconst (mData.productId) = 0;
     122    unconst (mData.revision) = 0;
     123
     124    unconst (mData.manufacturer).setNull();
     125    unconst (mData.product).setNull();
     126    unconst (mData.serialNumber).setNull();
     127
     128    unconst (mData.address).setNull();
     129
     130    unconst (mData.port) = 0;
     131    unconst (mData.version) = 1;
     132    unconst (mData.portVersion) = 1;
     133
     134    unconst (mData.remote) = FALSE;
     135}
    100136
    101137// IUSBDevice properties
     
    113149        return E_POINTER;
    114150
    115     AutoWriteLock alock (this);
    116     CHECK_READY();
    117 
    118     mId.cloneTo(aId);
     151    AutoCaller autoCaller (this);
     152    CheckComRCReturnRC (autoCaller.rc());
     153
     154    /* this is const, no need to lock */
     155    mData.id.cloneTo (aId);
     156
    119157    return S_OK;
    120158}
     
    132170        return E_POINTER;
    133171
    134     AutoWriteLock alock (this);
    135     CHECK_READY();
    136 
    137     *aVendorId = mVendorId;
     172    AutoCaller autoCaller (this);
     173    CheckComRCReturnRC (autoCaller.rc());
     174
     175    /* this is const, no need to lock */
     176    *aVendorId = mData.vendorId;
     177
    138178    return S_OK;
    139179}
     
    151191        return E_POINTER;
    152192
    153     AutoWriteLock alock (this);
    154     CHECK_READY();
    155 
    156     *aProductId = mProductId;
     193    AutoCaller autoCaller (this);
     194    CheckComRCReturnRC (autoCaller.rc());
     195
     196    /* this is const, no need to lock */
     197    *aProductId = mData.productId;
     198
    157199    return S_OK;
    158200}
     
    170212        return E_POINTER;
    171213
    172     AutoWriteLock alock (this);
    173     CHECK_READY();
    174 
    175     *aRevision = mRevision;
     214    AutoCaller autoCaller (this);
     215    CheckComRCReturnRC (autoCaller.rc());
     216
     217    /* this is const, no need to lock */
     218    *aRevision = mData.revision;
     219
    176220    return S_OK;
    177221}
     
    188232        return E_POINTER;
    189233
    190     AutoWriteLock alock (this);
    191     CHECK_READY();
    192 
    193     mManufacturer.cloneTo(aManufacturer);
     234    AutoCaller autoCaller (this);
     235    CheckComRCReturnRC (autoCaller.rc());
     236
     237    /* this is const, no need to lock */
     238    mData.manufacturer.cloneTo (aManufacturer);
     239
    194240    return S_OK;
    195241}
     
    207253        return E_POINTER;
    208254
    209     AutoWriteLock alock (this);
    210     CHECK_READY();
    211 
    212     mProduct.cloneTo(aProduct);
     255    AutoCaller autoCaller (this);
     256    CheckComRCReturnRC (autoCaller.rc());
     257
     258    /* this is const, no need to lock */
     259    mData.product.cloneTo (aProduct);
     260
    213261    return S_OK;
    214262}
     
    226274        return E_POINTER;
    227275
    228     AutoWriteLock alock (this);
    229     CHECK_READY();
    230 
    231     mSerialNumber.cloneTo(aSerialNumber);
     276    AutoCaller autoCaller (this);
     277    CheckComRCReturnRC (autoCaller.rc());
     278
     279    /* this is const, no need to lock */
     280    mData.serialNumber.cloneTo (aSerialNumber);
     281
    232282    return S_OK;
    233283}
     
    245295        return E_POINTER;
    246296
    247     AutoWriteLock alock (this);
    248     CHECK_READY();
    249 
    250     mAddress.cloneTo(aAddress);
     297    AutoCaller autoCaller (this);
     298    CheckComRCReturnRC (autoCaller.rc());
     299
     300    /* this is const, no need to lock */
     301    mData.address.cloneTo (aAddress);
     302
    251303    return S_OK;
    252304}
     
    257309        return E_POINTER;
    258310
    259     AutoWriteLock alock (this);
    260     CHECK_READY();
    261 
    262     *aPort = mPort;
     311    AutoCaller autoCaller (this);
     312    CheckComRCReturnRC (autoCaller.rc());
     313
     314    /* this is const, no need to lock */
     315    *aPort = mData.port;
     316
    263317    return S_OK;
    264318}
     
    269323        return E_POINTER;
    270324
    271     AutoWriteLock alock (this);
    272     CHECK_READY();
    273 
    274     *aVersion = mVersion;
     325    AutoCaller autoCaller (this);
     326    CheckComRCReturnRC (autoCaller.rc());
     327
     328    /* this is const, no need to lock */
     329    *aVersion = mData.version;
     330
    275331    return S_OK;
    276332}
     
    281337        return E_POINTER;
    282338
    283     AutoWriteLock alock (this);
    284     CHECK_READY();
    285 
    286     *aPortVersion = mPortVersion;
     339    AutoCaller autoCaller (this);
     340    CheckComRCReturnRC (autoCaller.rc());
     341
     342    /* this is const, no need to lock */
     343    *aPortVersion = mData.portVersion;
     344
    287345    return S_OK;
    288346}
     
    293351        return E_POINTER;
    294352
    295     AutoWriteLock alock (this);
    296     CHECK_READY();
    297 
    298     *aRemote = mRemote;
     353    AutoCaller autoCaller (this);
     354    CheckComRCReturnRC (autoCaller.rc());
     355
     356    /* this is const, no need to lock */
     357    *aRemote = mData.remote;
     358
    299359    return S_OK;
    300360}
  • trunk/src/VBox/Main/include/RemoteUSBDeviceImpl.h

    r8155 r13659  
     1/* $Id$ */
     2
    13/** @file
    24 *
     
    68
    79/*
    8  * Copyright (C) 2006-2007 Sun Microsystems, Inc.
     10 * Copyright (C) 2006-2008 Sun Microsystems, Inc.
    911 *
    1012 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2628#include "VirtualBoxBase.h"
    2729#include "Collection.h"
    28 #include <VBox/vrdpapi.h>
     30
     31struct _VRDPUSBDEVICEDESC;
     32typedef _VRDPUSBDEVICEDESC VRDPUSBDEVICEDESC;
    2933
    3034class ATL_NO_VTABLE RemoteUSBDevice :
     35    public VirtualBoxBaseNEXT,
    3136    public VirtualBoxSupportErrorInfoImpl <RemoteUSBDevice, IHostUSBDevice>,
    3237    public VirtualBoxSupportTranslation <RemoteUSBDevice>,
    33     public VirtualBoxBase,
    3438    public IHostUSBDevice
    3539{
    3640public:
    3741
    38     DECLARE_NOT_AGGREGATABLE(RemoteUSBDevice)
     42    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (OUSBDevice)
     43
     44    DECLARE_NOT_AGGREGATABLE (RemoteUSBDevice)
    3945
    4046    DECLARE_PROTECT_FINAL_CONSTRUCT()
    4147
    42     BEGIN_COM_MAP(RemoteUSBDevice)
    43         COM_INTERFACE_ENTRY(ISupportErrorInfo)
    44         COM_INTERFACE_ENTRY(IHostUSBDevice)
    45         COM_INTERFACE_ENTRY(IUSBDevice)
     48    BEGIN_COM_MAP (RemoteUSBDevice)
     49        COM_INTERFACE_ENTRY (ISupportErrorInfo)
     50        COM_INTERFACE_ENTRY (IHostUSBDevice)
     51        COM_INTERFACE_ENTRY (IUSBDevice)
    4652    END_COM_MAP()
    4753
     
    7581
    7682    // public methods only for internal purposes
    77     bool dirty (void) { return mDirty; }
    78     void dirty (bool aDirty) { mDirty = aDirty; }
    79 
    80     uint16_t devId (void) { return mDevId; }
    81     uint32_t clientId (void) { return mClientId; }
    82 
    83     bool captured (void) { return mState == USBDeviceState_Captured; }
     83    bool dirty (void) const { return mData.dirty; }
     84    void dirty (bool aDirty) { mData.dirty = aDirty; }
     85
     86    uint16_t devId (void) const { return mData.devId; }
     87    uint32_t clientId (void) { return mData.clientId; }
     88
     89    bool captured (void) const { return mData.state == USBDeviceState_Captured; }
    8490    void captured (bool aCaptured)
    8591    {
    8692        if (aCaptured)
    8793        {
    88             Assert(mState == USBDeviceState_Available);
    89             mState = USBDeviceState_Captured;
     94            Assert(mData.state == USBDeviceState_Available);
     95            mData.state = USBDeviceState_Captured;
    9096        }
    9197        else
    9298        {
    93             Assert(mState == USBDeviceState_Captured);
    94             mState = USBDeviceState_Available;
     99            Assert(mData.state == USBDeviceState_Captured);
     100            mData.state = USBDeviceState_Available;
    95101        }
    96102    }
     
    101107private:
    102108
    103     Guid mId;
    104 
    105     uint16_t mVendorId;
    106     uint16_t mProductId;
    107     uint16_t mRevision;
    108 
    109     Bstr mManufacturer;
    110     Bstr mProduct;
    111     Bstr mSerialNumber;
    112 
    113     Bstr mAddress;
    114 
    115     uint16_t mPort;
    116     uint16_t mVersion;
    117     uint16_t mPortVersion;
    118 
    119     USBDeviceState_T mState;
    120 
    121     bool mDirty;
    122     uint16_t mDevId;
    123     uint32_t mClientId;
     109    struct Data
     110    {
     111        Data() : vendorId (0), productId (0), revision (0), port (0), version (1),
     112                 portVersion (1), dirty (FALSE), devId (0), clientId (0) {}
     113
     114        const Guid id;
     115
     116        const uint16_t vendorId;
     117        const uint16_t productId;
     118        const uint16_t revision;
     119
     120        const Bstr manufacturer;
     121        const Bstr product;
     122        const Bstr serialNumber;
     123
     124        const Bstr address;
     125
     126        const uint16_t port;
     127        const uint16_t version;
     128        const uint16_t portVersion;
     129
     130        USBDeviceState_T state;
     131        bool dirty;
     132
     133        const uint16_t devId;
     134        const uint32_t clientId;
     135    };
     136
     137    Data mData;
    124138};
    125139
  • trunk/src/VBox/Main/include/USBDeviceImpl.h

    r8721 r13659  
     1/* $Id$ */
     2
    13/** @file
    24 * Header file for the OUSBDevice (IUSBDevice) class, VBoxC.
     
    46
    57/*
    6  * Copyright (C) 2006-2007 Sun Microsystems, Inc.
     8 * Copyright (C) 2006-2008 Sun Microsystems, Inc.
    79 *
    810 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3234 */
    3335class ATL_NO_VTABLE OUSBDevice :
     36    public VirtualBoxBaseNEXT,
    3437    public VirtualBoxSupportErrorInfoImpl<OUSBDevice, IUSBDevice>,
    3538    public VirtualBoxSupportTranslation<OUSBDevice>,
    36     public VirtualBoxBase,
    3739    public IUSBDevice
    3840{
    3941public:
    4042
    41     OUSBDevice();
    42     virtual ~OUSBDevice();
     43    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (OUSBDevice)
    4344
    4445    DECLARE_NOT_AGGREGATABLE(OUSBDevice)
     
    4748
    4849    BEGIN_COM_MAP(OUSBDevice)
    49         COM_INTERFACE_ENTRY(ISupportErrorInfo)
    50         COM_INTERFACE_ENTRY(IUSBDevice)
     50        COM_INTERFACE_ENTRY (ISupportErrorInfo)
     51        COM_INTERFACE_ENTRY (IUSBDevice)
    5152    END_COM_MAP()
    5253
    5354    NS_DECL_ISUPPORTS
    5455
     56    DECLARE_EMPTY_CTOR_DTOR (OUSBDevice)
     57
     58    HRESULT FinalConstruct();
     59    void FinalRelease();
     60
    5561    // public initializer/uninitializer for internal purposes only
    56     HRESULT init(IUSBDevice *a_pUSBDevice);
     62    HRESULT init (IUSBDevice *a_pUSBDevice);
     63    void uninit();
    5764
    5865    // IUSBDevice properties
     
    7178
    7279    // public methods only for internal purposes
    73     const Guid &id() { return mId; }
     80    const Guid &id() const { return mData.id; }
    7481
    7582    // for VirtualBoxSupportErrorInfoImpl
     
    7784
    7885private:
    79     /** The UUID of this device. */
    80     Guid mId;
    8186
    82     /** The vendor id of this USB device. */
    83     USHORT mVendorId;
    84     /** The product id of this USB device. */
    85     USHORT mProductId;
    86     /** The product revision number of this USB device.
    87      * (high byte = integer; low byte = decimal) */
    88     USHORT mRevision;
    89     /** The Manufacturer string. (Quite possibly NULL.) */
    90     Bstr mManufacturer;
    91     /** The Product string. (Quite possibly NULL.) */
    92     Bstr mProduct;
    93     /** The SerialNumber string. (Quite possibly NULL.) */
    94     Bstr mSerialNumber;
    95     /** The host specific address of the device. */
    96     Bstr mAddress;
    97     /** The host port number. */
    98     USHORT mPort;
    99     /** The major USB version number of the device. */
    100     USHORT mVersion;
    101     /** The major USB version number of the port the device is attached to. */
    102     USHORT mPortVersion;
    103     /** Remote (VRDP) or local device. */
    104     BOOL mRemote;
     87    struct Data
     88    {
     89        Data() : vendorId (0), productId (0), revision (0), port (0),
     90                 version (1), portVersion (1), remote (FALSE) {}
     91
     92        /** The UUID of this device. */
     93        const Guid id;
     94
     95        /** The vendor id of this USB device. */
     96        const USHORT vendorId;
     97        /** The product id of this USB device. */
     98        const USHORT productId;
     99        /** The product revision number of this USB device.
     100         * (high byte = integer; low byte = decimal) */
     101        const USHORT revision;
     102        /** The Manufacturer string. (Quite possibly NULL.) */
     103        const Bstr manufacturer;
     104        /** The Product string. (Quite possibly NULL.) */
     105        const Bstr product;
     106        /** The SerialNumber string. (Quite possibly NULL.) */
     107        const Bstr serialNumber;
     108        /** The host specific address of the device. */
     109        const Bstr address;
     110        /** The host port number. */
     111        const USHORT port;
     112        /** The major USB version number of the device. */
     113        const USHORT version;
     114        /** The major USB version number of the port the device is attached to. */
     115        const USHORT portVersion;
     116        /** Remote (VRDP) or local device. */
     117        const BOOL remote;
     118    };
     119
     120    Data mData;
    105121};
    106122
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