VirtualBox

Changeset 6909 in vbox


Ignore:
Timestamp:
Feb 11, 2008 8:00:12 PM (17 years ago)
Author:
vboxsync
Message:

Main: Added IMachine::machines2 that returns the array instead of the collection (will supercede IMachine::machines after web services are fixed).

Location:
trunk/src/VBox
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMListBox.cpp

    r6822 r6909  
    228228    clear();
    229229
    230     CMachineEnumerator en = mVBox.GetMachines().Enumerate();
    231     while (en.HasMore())
    232     {
    233         CMachine m = en.GetNext();
    234         new VBoxVMListBoxItem (this, m);
    235     }
     230    CMachineVector vec = mVBox.GetMachines2();
     231    for (CMachineVector::ConstIterator m = vec.begin();
     232         m != vec.end(); ++ m)
     233        new VBoxVMListBoxItem (this, *m);
    236234
    237235    sort();
  • trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMSettingsDlg.ui.h

    r6784 r6909  
    10281028    /* clear inner list */
    10291029    mNetworksList.clear();
    1030     /* loading internal networks list */
     1030
     1031    /* load internal network list */
    10311032    CVirtualBox vbox = vboxGlobal().virtualBox();
    10321033    ulong count = vbox.GetSystemProperties().GetNetworkAdapterCount();
    1033     CMachineEnumerator en = vbox.GetMachines().Enumerate();
    1034     while (en.HasMore())
    1035     {
    1036         CMachine machine = en.GetNext();
     1034    CMachineVector vec =  vbox.GetMachines2();
     1035    for (CMachineVector::ConstIterator m = vec.begin();
     1036         m != vec.end(); ++ m)
     1037    {
    10371038        for (ulong slot = 0; slot < count; ++ slot)
    10381039        {
    1039             CNetworkAdapter adapter = machine.GetNetworkAdapter (slot);
     1040            CNetworkAdapter adapter = m->GetNetworkAdapter (slot);
    10401041            if (adapter.GetAttachmentType() == CEnums::InternalNetworkAttachment &&
    10411042                !mNetworksList.contains (adapter.GetInternalNetwork()))
     
    10431044        }
    10441045    }
     1046
    10451047    mLockNetworkListUpdate = false;
    10461048}
  • trunk/src/VBox/Main/VirtualBoxImpl.cpp

    r6384 r6909  
    5757
    5858#include <VBox/com/com.h>
     59#include <VBox/com/array.h>
    5960
    6061#include <algorithm>
     
    467468}
    468469
    469 STDMETHODIMP VirtualBox::COMGETTER(SystemProperties) (ISystemProperties **aSystemProperties)
     470STDMETHODIMP
     471VirtualBox::COMGETTER(SystemProperties) (ISystemProperties **aSystemProperties)
    470472{
    471473    if (!aSystemProperties)
     
    479481}
    480482
    481 /** @note Locks this object for reading. */
     483/**
     484 * @note Locks this object for reading.
     485 */
    482486STDMETHODIMP VirtualBox::COMGETTER(Machines) (IMachineCollection **aMachines)
    483487{
     
    498502}
    499503
    500 /** @note Locks this object for reading. */
     504/**
     505 * @note Locks this object for reading.
     506 */
     507STDMETHODIMP
     508VirtualBox::COMGETTER(Machines2) (ComSafeArrayOut (IMachine *, aMachines))
     509{
     510    if (ComSafeArrayOutIsNull (aMachines))
     511        return E_POINTER;
     512
     513    AutoCaller autoCaller (this);
     514    CheckComRCReturnRC (autoCaller.rc());
     515
     516    AutoReaderLock alock (this);
     517
     518    SafeIfaceArray <IMachine> machines (mData.mMachines);
     519    machines.detachTo (ComSafeArrayOutArg (aMachines));
     520
     521    return S_OK;
     522}
     523
     524/**
     525 * @note Locks this object for reading.
     526 */
    501527STDMETHODIMP VirtualBox::COMGETTER(HardDisks) (IHardDiskCollection **aHardDisks)
    502528{
     
    517543}
    518544
    519 /** @note Locks this object for reading. */
     545/**
     546 * @note Locks this object for reading.
     547 */
    520548STDMETHODIMP VirtualBox::COMGETTER(DVDImages) (IDVDImageCollection **aDVDImages)
    521549{
     
    536564}
    537565
    538 /** @note Locks this object for reading. */
     566/**
     567 * @note Locks this object for reading.
     568 */
    539569STDMETHODIMP VirtualBox::COMGETTER(FloppyImages) (IFloppyImageCollection **aFloppyImages)
    540570{
     
    555585}
    556586
    557 /** @note Locks this object for reading. */
     587/**
     588 * @note Locks this object for reading.
     589 */
    558590STDMETHODIMP VirtualBox::COMGETTER(ProgressOperations) (IProgressCollection **aOperations)
    559591{
     
    574606}
    575607
    576 /** @note Locks this object for reading. */
     608/**
     609 * @note Locks this object for reading.
     610 */
    577611STDMETHODIMP VirtualBox::COMGETTER(GuestOSTypes) (IGuestOSTypeCollection **aGuestOSTypes)
    578612{
     
    40614095}
    40624096
    4063 /** 
     4097/**
    40644098 * Helper method to load the setting tree and turn expected exceptions into
    40654099 * COM errors, according to arguments.
    4066  * 
     4100 *
    40674101 * Note that this method will not catch unexpected errors so it may still
    40684102 * throw something.
     
    41204154}
    41214155
    4122 /** 
     4156/**
    41234157 * Helper method to save the settings tree and turn expected exceptions to COM
    41244158 * errors.
     
    41264160 * Note that this method will not catch unexpected errors so it may still
    41274161 * throw something.
    4128  * 
     4162 *
    41294163 * @param aTree Tree to save.
    41304164 * @param aFile File to save the tree to.
     
    41514185}
    41524186
    4153 /** 
     4187/**
    41544188 * Handles unexpected exceptions by turning them into COM errors in release
    41554189 * builds or by hitting a breakpoint in the release builds.
     
    41704204        }
    41714205 * @endcode
    4172  * 
     4206 *
    41734207 * @param RT_SRC_POS_DECL "RT_SRC_POS" macro instantiation.
    41744208 */
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r6852 r6909  
    4343 *
    4444     Copyright (C) 2006-2007 innotek GmbH
    45    
     45
    4646     This file is part of VirtualBox Open Source Edition (OSE), as
    4747     available from http://www.virtualbox.org. This file is free software;
     
    814814     wsmap="managed"
    815815     >
    816     <desc> The main interface exposed by the product that provides virtual
    817       machine management.
     816    <desc>
     817      The IVirtualBox interface represents the main interface exposed by the
     818      product that provides virtual machine management.
    818819
    819820      An instance of IVirtualBox is required for the product to do anything
     
    859860    </attribute>
    860861
    861     <attribute name="machines" type="IMachineCollection" readonly="yes"/>
     862        <attribute name="machines" type="IMachineCollection" readonly="yes">
     863      <desc>
     864        Collection of machine objects registered within this VirtualBox
     865        instance.
     866      </desc>
     867    </attribute>
     868
     869    <attribute name="machines2" type="IMachine" readonly="yes" safearray="yes">
     870      <desc>
     871        Array of machine objects registered within this VirtualBox instance.
     872      </desc>
     873    </attribute>
    862874
    863875    <attribute name="hardDisks" type="IHardDiskCollection" readonly="yes">
    864876      <desc>
    865         A collection of hard disk objects registered within this
    866         VirtualBox instance.
    867         This collection contains only "top-level" (basic or independent)
    868         hard disk images, but not differencing ones. All differencing
    869         images of the given top-level image (i.e. all its children) can
    870         be enumerated using <link to="IHardDisk::children"/>.
     877        Collection of hard disk objects registered within this VirtualBox
     878        instance.
     879
     880        This collection contains only "top-level" (basic or independent) hard
     881        disk images, but not differencing ones. All differencing images of the
     882        given top-level image (i.e. all its children) can be enumerated using
     883        <link to="IHardDisk::children"/>.
    871884      </desc>
    872885    </attribute>
     
    90649077      </desc>
    90659078    </attribute>
    9066    
     9079
    90679080    <attribute name="writable" type="boolean" readonly="yes">
    90689081      <desc>
  • trunk/src/VBox/Main/include/VirtualBoxImpl.h

    r6384 r6909  
    112112    STDMETHOD(COMGETTER(SystemProperties)) (ISystemProperties **aSystemProperties);
    113113    STDMETHOD(COMGETTER(Machines)) (IMachineCollection **aMachines);
     114    STDMETHOD(COMGETTER(Machines2)) (ComSafeArrayOut (IMachine *, aMachines));
    114115    STDMETHOD(COMGETTER(HardDisks)) (IHardDiskCollection **aHardDisks);
    115116    STDMETHOD(COMGETTER(DVDImages)) (IDVDImageCollection **aDVDImages);
     
    269270                                     bool aAddDefaults);
    270271
    271     /** 
     272    /**
    272273     * Shortcut to loadSettingsTree (aTree, aFile, true, true, true).
    273274     *
     
    281282    }
    282283
    283     /** 
     284    /**
    284285     * Shortcut to loadSettingsTree (aTree, aFile, true, false, true).
    285286     *
     
    295296    }
    296297
    297     /** 
     298    /**
    298299     * Shortcut to loadSettingsTree (aTree, aFile, true, false, false).
    299300     *
  • trunk/src/VBox/Main/testcase/tstAPI.cpp

    r5999 r6909  
    2121#include <VBox/com/com.h>
    2222#include <VBox/com/string.h>
     23#include <VBox/com/array.h>
    2324#include <VBox/com/Guid.h>
    2425#include <VBox/com/ErrorInfo.h>
     
    222223    Utf8Str nullUtf8Str;
    223224    printf ("nullUtf8Str='%s'\n", nullUtf8Str.raw());
    224    
     225
    225226    Utf8Str simpleUtf8Str = "simpleUtf8Str";
    226227    printf ("simpleUtf8Str='%s'\n", simpleUtf8Str.raw());
     
    248249    }
    249250
    250 #if 1
     251#if 0
    251252    // IUnknown identity test
    252253    ////////////////////////////////////////////////////////////////////////////
     
    333334        CHECK_ERROR_BREAK (virtualBox, COMGETTER(Version) (version.asOutParam()));
    334335        printf ("VirtualBox version = %ls\n", version.raw());
     336    }
     337#endif
     338
     339#if 1
     340    // Array test
     341    ////////////////////////////////////////////////////////////////////////////
     342    {
     343        printf ("Calling IVirtualBox::Machines...\n");
     344
     345        com::SafeArray <ULONG> aaa (10);
     346
     347        com::SafeIfaceArray <IMachine> machines;
     348        CHECK_ERROR_BREAK (virtualBox,
     349                           COMGETTER(Machines2) (ComSafeArrayAsOutParam (machines)));
     350
     351        printf ("%u machines registered.\n", machines.size());
     352
     353        for (size_t i = 0; i < machines.size(); ++ i)
     354        {
     355            Bstr name;
     356            CHECK_ERROR_BREAK (machines [i], COMGETTER(Name) (name.asOutParam()));
     357            printf ("machines[%u]='%s'\n", i, Utf8Str (name).raw());
     358        }
    335359    }
    336360#endif
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