VirtualBox

Changeset 16971 in vbox


Ignore:
Timestamp:
Feb 20, 2009 12:26:19 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
43138
Message:

#3551: “Main: Replace remaining collections with safe arrays”
Converted ostype collection. Tested with VBoxManage list ostypes.

Location:
trunk/src/VBox
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageList.cpp

    r16867 r16971  
    55
    66/*
    7  * Copyright (C) 2006-2007 Sun Microsystems, Inc.
     7 * Copyright (C) 2006-2009 Sun Microsystems, Inc.
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    134134    if (strcmp(a->argv[0], "ostypes") == 0)
    135135    {
    136         ComPtr<IGuestOSTypeCollection> coll;
    137         ComPtr<IGuestOSTypeEnumerator> enumerator;
    138         CHECK_ERROR(a->virtualBox, COMGETTER(GuestOSTypes)(coll.asOutParam()));
    139         if (SUCCEEDED(rc) && coll)
    140         {
    141             CHECK_ERROR(coll, Enumerate(enumerator.asOutParam()));
    142             BOOL hasMore;
    143             while (SUCCEEDED(enumerator->HasMore(&hasMore)) && hasMore)
     136        com::SafeIfaceArray <IGuestOSType> coll;
     137        rc = a->virtualBox->COMGETTER(GuestOSTypes)(ComSafeArrayAsOutParam(coll));
     138        if (SUCCEEDED(rc))
     139        {
     140            /*
     141             * Iterate through the collection.
     142             */
     143            for (size_t i = 0; i < coll.size(); ++ i)
    144144            {
    145145                ComPtr<IGuestOSType> guestOS;
    146                 CHECK_ERROR_BREAK(enumerator, GetNext(guestOS.asOutParam()));
     146                guestOS = coll[i];
    147147                Bstr guestId;
    148148                guestOS->COMGETTER(Id)(guestId.asOutParam());
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobal.cpp

    r16966 r16971  
    66
    77/*
    8  * Copyright (C) 2008 Sun Microsystems, Inc.
     8 * Copyright (C) 2008-2009 Sun Microsystems, Inc.
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    55365536#endif
    55375537
    5538     /* Initialize guest OS Type list */
    5539     CGuestOSTypeCollection coll = mVBox.GetGuestOSTypes();
    5540     int osTypeCount = coll.GetCount();
     5538    /* Initialize guest OS Type list. */
     5539    CGuestOSTypeVector coll = mVBox.GetGuestOSTypes();
     5540    int osTypeCount = coll.size();
    55415541    AssertMsg (osTypeCount > 0, ("Number of OS types must not be zero"));
    55425542    if (osTypeCount > 0)
    55435543    {
    5544         CGuestOSTypeEnumerator en = coll.Enumerate();
    5545 
    5546         /* Here we assume 'Other' type is always the first, so we
    5547          * remember it and will append it to the list when finish */
    5548         CGuestOSType otherType (en.GetNext());
     5544        /* Here we assume the 'Other' type is always the first, so we
     5545         * remember it and will append it to the list when finished. */
     5546        CGuestOSType otherType = coll[0];
    55495547        QString otherFamilyId (otherType.GetFamilyId());
    55505548
    55515549        /* Fill the lists with all the available OS Types except
    5552          * the 'Other' one type, it will be appended. */
    5553         while (en.HasMore())
    5554         {
    5555             CGuestOSType os (en.GetNext());
     5550         * the 'Other' type, which will be appended. */
     5551        for (int i = 1; i < coll.size(); ++i)
     5552        {
     5553            CGuestOSType os = coll[i];
    55565554            QString familyId (os.GetFamilyId());
    55575555            if (!mFamilyIDs.contains (familyId))
     
    55635561        }
    55645562
    5565         /* Append the 'Other' OS Type to the end of list */
     5563        /* Append the 'Other' OS Type to the end of list. */
    55665564        if (!mFamilyIDs.contains (otherFamilyId))
    55675565        {
     
    55725570    }
    55735571
    5574     /* Fill in OS type icon dictionary */
     5572    /* Fill in OS type icon dictionary. */
    55755573    static const char *kOSTypeIcons [][2] =
    55765574    {
  • trunk/src/VBox/Main/VirtualBoxImpl.cpp

    r16966 r16971  
    66
    77/*
    8  * Copyright (C) 2006-2007 Sun Microsystems, Inc.
     8 * Copyright (C) 2006-2009 Sun Microsystems, Inc.
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    692692}
    693693
    694 STDMETHODIMP VirtualBox::COMGETTER(GuestOSTypes) (IGuestOSTypeCollection **aGuestOSTypes)
     694STDMETHODIMP VirtualBox::COMGETTER(GuestOSTypes) (ComSafeArrayOut (IGuestOSType *, aGuestOSTypes))
    695695{
    696696    CheckComArgOutSafeArrayPointerValid(aGuestOSTypes);
     
    699699    CheckComRCReturnRC (autoCaller.rc());
    700700
    701     ComObjPtr <GuestOSTypeCollection> collection;
    702     collection.createObject();
    703 
    704701    AutoReadLock alock (this);
    705     collection->init (mData.mGuestOSTypes);
    706     collection.queryInterfaceTo (aGuestOSTypes);
     702
     703    SafeIfaceArray <IGuestOSType> ostypes (mData.mGuestOSTypes);
     704    ostypes.detachTo (ComSafeArrayOutArg (aGuestOSTypes));
    707705
    708706    return S_OK;
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r16967 r16971  
    4646 *    (<result> extraction for the %Rhrc format specifier)
    4747 *
    48      Copyright (C) 2006-2008 Sun Microsystems, Inc.
     48     Copyright (C) 2006-2009 Sun Microsystems, Inc.
    4949
    5050     This file is part of VirtualBox Open Source Edition (OSE), as
     
    14091409    <attribute name="progressOperations" type="IProgress" readonly="yes" safearray="yes"/>
    14101410
    1411     <attribute name="guestOSTypes" type="IGuestOSTypeCollection" readonly="yes"/>
     1411    <attribute name="guestOSTypes" type="IGuestOSType" readonly="yes" safearray="yes"/>
    14121412
    14131413    <attribute name="sharedFolders" type="ISharedFolder" readonly="yes" safearray="yes">
     
    71017101  <interface
    71027102    name="IGuestOSType" extends="$unknown"
    7103     uuid="bc415228-eed0-402c-92f5-96fc4e2dd7e4"
     7103    uuid="cfe9e64c-4430-435b-9e7c-e3d8e417bd58"
    71047104    wsmap="struct"
    71057105  >
     
    71517151    </attribute>
    71527152  </interface>
    7153 
    7154 
    7155   <enumerator
    7156      name="IGuestOSTypeEnumerator" type="IGuestOSType"
    7157      uuid="a3335e02-4669-4e3c-80c7-c4dc7056a07c"
    7158      />
    7159 
    7160   <collection
    7161      name="IGuestOSTypeCollection" type="IGuestOSType" enumerator="IGuestOSTypeEnumerator"
    7162      uuid="a5e36749-a610-498b-9f29-2e36c1042d65"
    7163      readonly="yes"
    7164      />
    71657153
    71667154  <interface
  • trunk/src/VBox/Main/include/GuestOSTypeImpl.h

    r15064 r16971  
    55
    66/*
    7  * Copyright (C) 2006-2007 Sun Microsystems, Inc.
     7 * Copyright (C) 2006-2009 Sun Microsystems, Inc.
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    101101};
    102102
    103 COM_DECL_READONLY_ENUM_AND_COLLECTION (GuestOSType)
    104 
    105103#endif // ____H_GUESTOSTYPEIMPL
    106104/* vi: set tabstop=4 shiftwidth=4 expandtab: */
  • trunk/src/VBox/Main/include/VirtualBoxImpl.h

    r16966 r16971  
    77
    88/*
    9  * Copyright (C) 2006-2007 Sun Microsystems, Inc.
     9 * Copyright (C) 2006-2009 Sun Microsystems, Inc.
    1010 *
    1111 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    130130    STDMETHOD(COMGETTER(FloppyImages)) (ComSafeArrayOut (IFloppyImage *, aFloppyImages));
    131131    STDMETHOD(COMGETTER(ProgressOperations)) (ComSafeArrayOut (IProgress *, aOperations));
    132     STDMETHOD(COMGETTER(GuestOSTypes)) (IGuestOSTypeCollection **aGuestOSTypes);
     132    STDMETHOD(COMGETTER(GuestOSTypes)) (ComSafeArrayOut (IGuestOSType *, aGuestOSTypes));
    133133    STDMETHOD(COMGETTER(SharedFolders)) (ComSafeArrayOut (ISharedFolder *, aSharedFolders));
    134134    STDMETHOD(COMGETTER(PerformanceCollector)) (IPerformanceCollector **aPerformanceCollector);
  • trunk/src/VBox/Main/xpcom/server.cpp

    r16966 r16971  
    55
    66/*
    7  * Copyright (C) 2006-2007 Sun Microsystems, Inc.
     7 * Copyright (C) 2006-2009 Sun Microsystems, Inc.
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    243243
    244244COM_IMPL_READONLY_ENUM_AND_COLLECTION(Snapshot)
    245 COM_IMPL_READONLY_ENUM_AND_COLLECTION(GuestOSType)
    246245COM_IMPL_READONLY_ENUM_AND_COLLECTION(HostDVDDrive)
    247246COM_IMPL_READONLY_ENUM_AND_COLLECTION(HostFloppyDrive)
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